Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
enricozb committed Sep 19, 2022
1 parent 6be2b55 commit 50ab82f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions intuitive/src/components/experimental_components/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ use crate::{
/// }
/// ```
///
/// [`VStack`]: struct.VStack.html
/// [`Flex::Block`]: stack/enum.Flex.html#variant.Block
/// [`VStack`]: ../../struct.VStack.html
/// [`Flex::Block`]: ../../stack/enum.Flex.html#variant.Block
#[component(Input)]
pub fn render(title: Spans, border: Style, on_key: KeyHandler, on_mouse: MouseHandler) {
let cursor = use_state(|| 0usize);
Expand Down
26 changes: 26 additions & 0 deletions intuitive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,32 @@ pub mod text;
/// have only a single child), and therefore the `on_key` handler could have been
/// provided to any of the [`Centered`], [`Section`], or [`Text`] components above.
///
/// # Generics
/// When requiring generics, for example when accepting a variable number of children,
/// they can be added into the attribute and then used in the parameters. For example:
/// ```rust
/// # use intuitive::{component, components::{Centered, children::Children, Section, Text}, on_key, state::use_state, render};
/// #
/// #[component(Root<const N: usize>)]
/// pub fn render(title: String, children: Children<N>) {
/// let text = use_state(String::new);
///
/// let on_key = on_key! { [text]
/// KeyEvent { code: Char(c), .. } => text.mutate(|text| text.push(c)),
/// KeyEvent { code: Char(c), .. } => text.mutate(|text| text.pop()),
/// KeyEvent { code: Esc, .. } => event::quit(),
/// };
///
/// render! {
/// Centered() {
/// Section(title) {
/// Text(text: text.get(), on_key)
/// }
/// }
/// }
/// }
/// ```
///
/// # Generated Component
/// The generated component is a structure that implements the [`Component`] trait. It
/// also has a an associated function `new() -> component::Any` that is used to create the
Expand Down

0 comments on commit 50ab82f

Please sign in to comment.