Skip to content
Snippets Groups Projects
Unverified Commit 137c421a authored by John's avatar John Committed by GitHub
Browse files

Merge pull request #82 from StarArawn/forward-attrs

Forwarded attributes on functional widgets
parents c2494886 1b365205
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ use kayak_render_macros::{rsx, use_state, widget, WidgetProps}; ...@@ -5,6 +5,7 @@ use kayak_render_macros::{rsx, use_state, widget, WidgetProps};
#[derive(WidgetProps, Clone, Default, Debug, PartialEq)] #[derive(WidgetProps, Clone, Default, Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
struct TestProps { struct TestProps {
/// A test prop
foo: u32, foo: u32,
#[prop_field(Styles)] #[prop_field(Styles)]
styles: Option<Style>, styles: Option<Style>,
...@@ -15,6 +16,7 @@ struct TestProps { ...@@ -15,6 +16,7 @@ struct TestProps {
} }
#[widget] #[widget]
/// A test widget
fn Test(props: TestProps) { fn Test(props: TestProps) {
let _ = use_state!(props.foo); let _ = use_state!(props.foo);
let children = props.get_children(); let children = props.get_children();
......
...@@ -28,12 +28,14 @@ pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments ...@@ -28,12 +28,14 @@ pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments
return TokenStream::new(); return TokenStream::new();
}; };
let attrs = f.attrs;
let block = f.block; let block = f.block;
let vis = f.vis; let vis = f.vis;
let kayak_core = get_core_crate(); let kayak_core = get_core_crate();
TokenStream::from(quote! { TokenStream::from(quote! {
#(#attrs)*
#[derive(Default, Debug, PartialEq, Clone)] #[derive(Default, Debug, PartialEq, Clone)]
#vis struct #struct_name #impl_generics { #vis struct #struct_name #impl_generics {
pub id: #kayak_core::Index, pub id: #kayak_core::Index,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment