Add system for creating component attributes + new #[component] attribute (#1448)
* Add `#[component]` attribute + system for creating component attributes + other stuff * Delete inlineprops.rs * Update inline_props.rs * Cargo fmt * Fix clippy warnings and paths in props/mods.rs * Include where clause in `#[inline_props]` output * Allow Clippy type complexity in `LinkProps` * Allow the type complexity lint for the entire link.rs file * Remove snake_case -> PascalCase converter, but rather enforce PascalCase Also: - Put the second function inside the main one instead of besides it. - Simplify * Simplify type check lints so they don't return false positives They will not always work, but they won't return any false positives, like for aliases. This is likely going to be replaced by a more polished Clippy-backed linting system. * Fix #583 * Cargo fmt * Add docs for `deserialize()` and remove useless comment * Add `#[component]` to prelude * Merge branch 'master' of https://github.com/tigerros/dioxus * #[inline_props] is no more. Except in the docs folder, but that's going to be removed * Remove docs folder * Remove docs from workspace * Resolve `DeserializerOutput` conversation
This commit is contained in:
1 parent
b68a1f57e0
commit
c866ae602b
281 files changed
+1122
-12818
No files matched your search
@@ -30,13 +30,14 @@ pub struct HistoryButtonProps<'a> {
|
||||
/// Index {},
|
||||
/// }
|
||||
///
|
||||
/// #[component]
|
||||
/// fn App(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// Router::<Route> {}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// GoBackButton {
|
||||
@@ -52,7 +53,7 @@ pub struct HistoryButtonProps<'a> {
|
||||
/// # r#"<button disabled="true" dioxus-prevent-default="onclick">go back</button>"#
|
||||
/// # );
|
||||
/// ```
|
||||
#[allow(non_snake_case)]
|
||||
#[component]
|
||||
pub fn GoBackButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
|
||||
let HistoryButtonProps { children } = cx.props;
|
||||
|
||||
@@ -101,13 +102,14 @@ pub fn GoBackButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
|
||||
/// Index {},
|
||||
/// }
|
||||
///
|
||||
/// #[component]
|
||||
/// fn App(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// Router::<Route> {}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// GoForwardButton {
|
||||
@@ -123,7 +125,7 @@ pub fn GoBackButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
|
||||
/// # r#"<button disabled="true" dioxus-prevent-default="onclick">go forward</button>"#
|
||||
/// # );
|
||||
/// ```
|
||||
#[allow(non_snake_case)]
|
||||
#[component]
|
||||
pub fn GoForwardButton<'a>(cx: Scope<'a, HistoryButtonProps<'a>>) -> Element {
|
||||
let HistoryButtonProps { children } = cx.props;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::type_complexity)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
@@ -133,13 +135,14 @@ impl Debug for LinkProps<'_> {
|
||||
/// Index {},
|
||||
/// }
|
||||
///
|
||||
/// #[component]
|
||||
/// fn App(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// Router::<Route> {}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// render! {
|
||||
|
||||
@@ -29,7 +29,7 @@ use dioxus::prelude::*;
|
||||
/// Index {},
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// div {
|
||||
@@ -38,7 +38,7 @@ use dioxus::prelude::*;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Wrapper(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// h1 { "App" }
|
||||
@@ -46,7 +46,7 @@ use dioxus::prelude::*;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Child(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// p {
|
||||
@@ -55,6 +55,7 @@ use dioxus::prelude::*;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// # #[component]
|
||||
/// # fn App(cx: Scope) -> Element {
|
||||
/// # render! {
|
||||
/// # Router::<Route> {
|
||||
|
||||
@@ -20,9 +20,9 @@ where
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
|
||||
@@ -48,9 +48,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -86,7 +86,7 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -112,9 +112,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -144,9 +144,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -177,9 +177,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -210,9 +210,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
@@ -239,9 +239,9 @@ pub trait HistoryProvider<R: Routable> {
|
||||
/// ```rust
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element { todo!() }
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn OtherPage(cx: Scope) -> Element { todo!() }
|
||||
/// #[derive(Clone, Routable, Debug, PartialEq)]
|
||||
/// enum Route {
|
||||
|
||||
@@ -17,13 +17,14 @@ use crate::prelude::{Navigator, RouterContext};
|
||||
/// Dynamic { id: usize },
|
||||
/// }
|
||||
///
|
||||
/// #[component]
|
||||
/// fn App(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// Router::<Route> {}
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// let navigator = use_navigator(&cx);
|
||||
///
|
||||
@@ -35,7 +36,7 @@ use crate::prelude::{Navigator, RouterContext};
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Dynamic(cx: Scope, id: usize) -> Element {
|
||||
/// render! {
|
||||
/// p {
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::utils::use_router_internal::use_router_internal;
|
||||
/// - Otherwise the current route.
|
||||
///
|
||||
/// # Panic
|
||||
/// - When the calling component is not nested within a [`Link`] component durring a debug build.
|
||||
/// - When the calling component is not nested within a [`Link`] component during a debug build.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
@@ -25,6 +25,7 @@ use crate::utils::use_router_internal::use_router_internal;
|
||||
/// Index {},
|
||||
/// }
|
||||
///
|
||||
/// #[component]
|
||||
/// fn App(cx: Scope) -> Element {
|
||||
/// render! {
|
||||
/// h1 { "App" }
|
||||
@@ -32,7 +33,7 @@ use crate::utils::use_router_internal::use_router_internal;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Index(cx: Scope) -> Element {
|
||||
/// let path = use_route(&cx).unwrap();
|
||||
/// render! {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Exentsions to the incremental renderer to support pre-caching static routes.
|
||||
//! Extensions to the incremental renderer to support pre-caching static routes.
|
||||
use core::pin::Pin;
|
||||
use std::future::Future;
|
||||
use std::str::FromStr;
|
||||
@@ -87,7 +87,7 @@ where
|
||||
<Rt as FromStr>::Err: std::fmt::Display,
|
||||
W: tokio::io::AsyncWrite + Unpin + Send,
|
||||
{
|
||||
#[inline_props]
|
||||
#[component]
|
||||
fn RenderPath<R>(cx: Scope, path: R) -> Element
|
||||
where
|
||||
R: Routable,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub enum NavigationTarget<R> {
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus_router::navigation::NavigationTarget;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
@@ -38,7 +38,7 @@ pub enum NavigationTarget<R> {
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus_router::navigation::NavigationTarget;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
|
||||
@@ -177,9 +177,9 @@ pub trait Routable: FromStr + Display + Clone + 'static {
|
||||
/// use dioxus_router::prelude::*;
|
||||
/// use dioxus::prelude::*;
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Home(cx: Scope) -> Element { todo!() }
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn About(cx: Scope) -> Element { todo!() }
|
||||
///
|
||||
/// #[derive(Routable, Clone, PartialEq, Debug)]
|
||||
@@ -219,9 +219,9 @@ pub trait Routable: FromStr + Display + Clone + 'static {
|
||||
/// use dioxus_router::prelude::*;
|
||||
/// use dioxus::prelude::*;
|
||||
///
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn Home(cx: Scope) -> Element { todo!() }
|
||||
/// #[inline_props]
|
||||
/// #[component]
|
||||
/// fn About(cx: Scope) -> Element { todo!() }
|
||||
///
|
||||
/// #[derive(Routable, Clone, PartialEq, Debug)]
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::prelude::*;
|
||||
/// ```rust,no_run
|
||||
/// # use dioxus_router::prelude::*;
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # #[inline_props]
|
||||
/// # #[component]
|
||||
/// # fn Index(cx: Scope) -> Element {
|
||||
/// # todo!()
|
||||
/// # }
|
||||
|
||||
Reference in new issue
Block a user