From 3bf70967ab86cc59b3a6a1d30044e8095594cf49 Mon Sep 17 00:00:00 2001 From: Piotr PAWLICKI Date: Sun, 13 Jun 2021 00:08:22 +0200 Subject: [PATCH 1/2] fix(ci): add `cargo test` in CI workflow --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c15cc07..0f27d40 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,3 +24,6 @@ jobs: - uses: actions-rs/cargo@v1 with: command: build + - uses: actions-rs/cargo@v1 + with: + command: test From 3ad9c0b558c490d6bec00b071823ec7d574e2355 Mon Sep 17 00:00:00 2001 From: Piotr PAWLICKI Date: Sun, 13 Jun 2021 02:08:21 +0200 Subject: [PATCH 2/2] fix(rustdoc): improve `ModalCloser` examples to work with `cargo test` Current examples for `ModalCloser` fail `cargo test` as they require some not provided yet required boilerplate code, plus do include a minor mistake following previous changes in YBC. This fixes `ModalCloser` examples to pass `cargo test`, while preserving the existing code/snippets presentation choices. --- src/components/modal.rs | 117 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/src/components/modal.rs b/src/components/modal.rs index 8c12be9..3499948 100644 --- a/src/components/modal.rs +++ b/src/components/modal.rs @@ -235,32 +235,143 @@ pub struct ModalCloseMsg(pub String); /// use yew::agent::Dispatcher; /// use yew::prelude::*; /// // .. snip .. +/// # use ybc::{Button, ModalCloser, ModalCloseMsg, ModalCard}; +/// # +/// # #[derive(Properties, Clone, PartialEq)] +/// # struct MyComponentProps {} +/// # +/// # struct MyComponent { +/// # link: ComponentLink, +/// # props: MyComponentProps, +/// # bridge: Dispatcher, +/// # } +/// # +/// # impl Component for MyComponent { +/// # type Properties = MyComponentProps; +/// # type Message = ModalCloseMsg; +/// # /// fn create(props: Self::Properties, link: ComponentLink) -> Self { /// let bridge = ModalCloser::dispatcher(); -/// Self{link, props, bridge} +/// Self { link, props, bridge } /// } +/// # +/// # fn update(&mut self, msg: Self::Message) -> ShouldRender { +/// # self.bridge.send(msg); +/// # true +/// # } +/// # +/// # fn change(&mut self, props: Self::Properties) -> ShouldRender { false } +/// # +/// # fn view(&self) -> Html { +/// # let closer = self.link.callback(|_| ModalCloseMsg("modal-0".into())); +/// # html! { +/// # { "Close" } +/// # } +/// # /> +/// # } +/// # } +/// # } /// ``` /// /// Next, in your component's `view` method, setup a callback to handle your component's close event. /// ```rust +/// # use yew::agent::Dispatcher; +/// # use yew::prelude::*; +/// # use ybc::{Button, ModalCloser, ModalCloseMsg, ModalCard}; +/// # +/// # #[derive(Properties, Clone, PartialEq)] +/// # struct MyComponentProps {} +/// # +/// # struct MyComponent { +/// # link: ComponentLink, +/// # props: MyComponentProps, +/// # bridge: Dispatcher, +/// # } +/// # +/// # impl Component for MyComponent { +/// # type Properties = MyComponentProps; +/// # type Message = ModalCloseMsg; +/// # +/// # fn create(props: Self::Properties, link: ComponentLink) -> Self { +/// # let bridge = ModalCloser::dispatcher(); +/// # Self { link, props, bridge } +/// # } +/// # +/// # fn update(&mut self, msg: Self::Message) -> ShouldRender { +/// # self.bridge.send(msg); +/// # true +/// # } +/// # +/// # fn change(&mut self, props: Self::Properties) -> ShouldRender { false } +/// # +/// # fn view(&self) -> Html { /// let closer = self.link.callback(|_| ModalCloseMsg("modal-0".into())); /// // ... snip ... +/// # html! { /// {"Close"} +/// footer=html! { +/// /// } /// /> +/// # } +/// # } +/// # } /// ``` /// /// Finally, in your component's `update` method, send the `ModalCloseMsg` over to the agent which /// will forward the message to the modal to cause it to close. /// ```rust +/// # use yew::agent::Dispatcher; +/// # use yew::prelude::*; +/// # use ybc::{Button, ModalCloser, ModalCloseMsg, ModalCard}; +/// # +/// # #[derive(Properties, Clone, PartialEq)] +/// # struct MyComponentProps {} +/// # +/// # struct MyComponent { +/// # link: ComponentLink, +/// # props: MyComponentProps, +/// # bridge: Dispatcher, +/// # } +/// # +/// # impl Component for MyComponent { +/// # type Properties = MyComponentProps; +/// # type Message = ModalCloseMsg; +/// # +/// # fn create(props: Self::Properties, link: ComponentLink) -> Self { +/// # let bridge = ModalCloser::dispatcher(); +/// # Self { link, props, bridge } +/// # } +/// # /// fn update(&mut self, msg: Self::Message) -> ShouldRender { /// self.bridge.send(msg); /// true /// } +/// # +/// # fn change(&mut self, props: Self::Properties) -> ShouldRender { false } +/// # +/// # fn view(&self) -> Html { +/// # let closer = self.link.callback(|_| ModalCloseMsg("modal-0".into())); +/// # html! { +/// # { "Close" } +/// # } +/// # /> +/// # } +/// # } +/// # } /// ``` /// /// This pattern allows you to communicate with a modal by its given ID, allowing