Remove lower case components that use the paran syntax (#551)

* chore: remove lowercase components

* chore: add docs are lowercase components

* docs: also add docs around lowercase components in current scope
This commit is contained in:
Jon Kelley authored and GitHub committed 2022-09-12 20:01:03 -07:00
1 parent d4d5d2733e
commit 38e8745db9
5 files changed
+56 -46

No files matched your search

+21 -8
View File
@@ -184,11 +184,8 @@ fn app(cx: Scope) -> Element {
// Can take children too!
Taller { a: "asd", div {"hello world!"} }
// Components can be used with the `call` syntax
// This component's props are defined *inline* with the `inline_props` macro
with_inline(
text: "using functionc all syntax"
)
WithInline { text: "using functionc all syntax" }
// Components can be geneirc too
// This component takes i32 type to give you typed input
@@ -196,8 +193,14 @@ fn app(cx: Scope) -> Element {
// Type inference can be used too
TypedInput { initial: 10.0 }
// geneircs with the `inline_props` macro
label(text: "hello geneirc world!")
label(text: 99.9)
Label { text: "hello geneirc world!" }
Label { text: 99.9 }
// Lowercase components work too, as long as they are access using a path
baller::lowercase_component {}
// For in-scope lowercase components, use the `self` keyword
self::lowercase_helper {}
// helper functions
// Single values must be wrapped in braces or `Some` to satisfy `IntoIterator`
@@ -212,6 +215,12 @@ fn helper<'a>(cx: &'a ScopeState, text: &str) -> Element<'a> {
})
}
fn lowercase_helper(cx: Scope) -> Element {
cx.render(rsx! {
"asd"
})
}
mod baller {
use super::*;
#[derive(Props, PartialEq)]
@@ -222,6 +231,10 @@ mod baller {
pub fn Baller(_: Scope<BallerProps>) -> Element {
todo!()
}
pub fn lowercase_component(cx: Scope) -> Element {
cx.render(rsx! { "look ma, no uppercase" })
}
}
#[derive(Props)]
@@ -255,7 +268,7 @@ where
}
#[inline_props]
fn with_inline<'a>(cx: Scope<'a>, text: &'a str) -> Element {
fn WithInline<'a>(cx: Scope<'a>, text: &'a str) -> Element {
cx.render(rsx! {
p { "{text}" }
})
@@ -263,7 +276,7 @@ fn with_inline<'a>(cx: Scope<'a>, text: &'a str) -> Element {
// generic component with inline_props too
#[inline_props]
fn label<T>(cx: Scope, text: T) -> Element
fn Label<T>(cx: Scope, text: T) -> Element
where
T: Display,
{
+2 -2
View File
@@ -73,7 +73,7 @@ pub fn app(cx: Scope<()>) -> Element {
}
}
ul { class: "todo-list",
filtered_todos.iter().map(|id| rsx!(todo_entry( key: "{id}", id: *id, todos: todos )))
filtered_todos.iter().map(|id| rsx!(TodoEntry { key: "{id}", id: *id, todos: todos }))
}
(!todos.is_empty()).then(|| rsx!(
footer { class: "footer",
@@ -111,7 +111,7 @@ pub struct TodoEntryProps<'a> {
id: u32,
}
pub fn todo_entry<'a>(cx: Scope<'a, TodoEntryProps<'a>>) -> Element {
pub fn TodoEntry<'a>(cx: Scope<'a, TodoEntryProps<'a>>) -> Element {
let is_editing = use_state(&cx, || false);
let todos = cx.props.todos.get();