mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* Add no_implicit_prelude to derive_props test * Add no_implicit_prelude to html_macro tests * Fix function_component macro tests function_component macro tests weren't being run by try build due to change in dir name. Imports corrected now that function_component is now in yew. Adds no_implicit_prelude to *-pass tests * Add no_implicit_prelude to props_macro tests * fix typo in comment
87 lines
4.2 KiB
Rust
87 lines
4.2 KiB
Rust
#![no_implicit_prelude]
|
|
|
|
fn compile_pass() {
|
|
let onclick = <::yew::Callback<::yew::MouseEvent> as ::std::convert::From<_>>::from(
|
|
|_: ::yew::MouseEvent| (),
|
|
);
|
|
let parent_ref = <::yew::NodeRef as ::std::default::Default>::default();
|
|
|
|
let dyn_tag = || <::std::string::String as ::std::convert::From<&str>>::from("test");
|
|
let mut extra_tags_iter = ::std::iter::IntoIterator::into_iter(::std::vec!["a", "b"]);
|
|
|
|
let cow_none: ::std::option::Option<::std::borrow::Cow<'static, str>> =
|
|
::std::option::Option::None;
|
|
|
|
::yew::html! {
|
|
<div>
|
|
<div data-key="abc"></div>
|
|
<div ref={parent_ref} class="parent">
|
|
<span class="child" value="anything"></span>
|
|
<label for="first-name">{"First Name"}</label>
|
|
<input type="text" id="first-name" value="placeholder" />
|
|
<input type="checkbox" checked=true />
|
|
<textarea value="write a story" />
|
|
<select name="status">
|
|
<option selected=true disabled=false value="">{"Selected"}</option>
|
|
<option selected=false disabled=true value="">{"Unselected"}</option>
|
|
</select>
|
|
<video autoplay=true controls=true />
|
|
</div>
|
|
<svg width="149" height="147" viewBox="0 0 149 147" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M60.5776 13.8268L51.8673 42.6431L77.7475 37.331L60.5776 13.8268Z" fill="#DEB819"/>
|
|
<path d="M108.361 94.9937L138.708 90.686L115.342 69.8642" stroke="black" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
<g filter="url(#filter0_d)">
|
|
<circle cx="75.3326" cy="73.4918" r="55" fill="#FDD630"/>
|
|
<circle cx="75.3326" cy="73.4918" r="52.5" stroke="black" stroke-width="5"/>
|
|
</g>
|
|
<circle cx="71" cy="99" r="5" fill="white" fill-opacity="0.75" stroke="black" stroke-width="3"/>
|
|
<defs>
|
|
<filter id="filter0_d" x="16.3326" y="18.4918" width="118" height="118" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
<feGaussianBlur stdDeviation="2"/>
|
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
|
|
</filter>
|
|
</defs>
|
|
</svg>
|
|
<img class={::yew::classes!("avatar", "hidden")} src="http://pic.com" />
|
|
<img class="avatar hidden" />
|
|
<button onclick={&onclick} {onclick} />
|
|
<a href="http://google.com" />
|
|
<custom-tag-a>
|
|
<custom-tag-b />
|
|
</custom-tag-a>
|
|
<@{dyn_tag()}>
|
|
<@{::std::iter::Iterator::next(&mut extra_tags_iter).unwrap()} class="extra-a"/>
|
|
<@{::std::iter::Iterator::next(&mut extra_tags_iter).unwrap()} class="extra-b"/>
|
|
</@>
|
|
|
|
<@{
|
|
let tag = dyn_tag();
|
|
if tag == "test" {
|
|
"div"
|
|
} else {
|
|
"a"
|
|
}
|
|
}/>
|
|
|
|
<a href={::std::option::Option::Some(::std::borrow::Cow::Borrowed("http://google.com"))} media={::std::clone::Clone::clone(&cow_none)} />
|
|
<track kind={::std::option::Option::Some(::std::borrow::Cow::Borrowed("subtitles"))} src={::std::clone::Clone::clone(&cow_none)} />
|
|
<track kind={::std::option::Option::Some(::std::borrow::Cow::Borrowed("5"))} mixed="works" />
|
|
<input value={::std::option::Option::Some(::std::borrow::Cow::Borrowed("value"))}
|
|
onblur={::std::option::Option::Some(<::yew::Callback<::yew::FocusEvent> as ::std::convert::From<_>>::from(|_| ()))}
|
|
/>
|
|
</div>
|
|
};
|
|
|
|
let children = ::std::vec![
|
|
::yew::html! { <span>{ "Hello" }</span> },
|
|
::yew::html! { <span>{ "World" }</span> },
|
|
];
|
|
::yew::html! { <div>{children}</div> };
|
|
|
|
// handle misleading angle brackets
|
|
::yew::html! { <div data-val={<::std::string::String as ::std::default::Default>::default()}></div> };
|
|
::yew::html! { <div><a data-val={<::std::string::String as ::std::default::Default>::default()} /></div> };
|
|
}
|
|
|
|
fn main() {}
|