diff --git a/crates/frontend/src/components/achievement.rs b/crates/frontend/src/components/achievement.rs index 39ca894..16602c4 100644 --- a/crates/frontend/src/components/achievement.rs +++ b/crates/frontend/src/components/achievement.rs @@ -14,6 +14,7 @@ use yew::Properties; #[derive(Properties, PartialEq)] pub struct Props { pub achievement: Achievement, + pub number: usize, } #[function_component] @@ -58,6 +59,9 @@ pub fn AchievementComponent(props: &Props) -> Html { html! {
+
+

{format!("{}.", props.number)}

+
@@ -65,7 +69,7 @@ pub fn AchievementComponent(props: &Props) -> Html {

{goal}

- +
} diff --git a/crates/frontend/src/components/create_milestone.rs b/crates/frontend/src/components/create_milestone.rs index c9a4c94..a11dad3 100644 --- a/crates/frontend/src/components/create_milestone.rs +++ b/crates/frontend/src/components/create_milestone.rs @@ -49,7 +49,7 @@ impl Component for CreateMilestoneComponent { fn update(&mut self, ctx: &yew::Context, msg: Self::Message) -> bool { match msg { Msg::Submit => { - log::info!("Creating achievement"); + log::info!("Creating milestone"); let Ok(goal) = self.input_value.parse::() else { return false; }; let goal = goal as usize; diff --git a/crates/frontend/src/components/error/error_component.rs b/crates/frontend/src/components/error/error_component.rs index 41ffd6b..c617b7a 100644 --- a/crates/frontend/src/components/error/error_component.rs +++ b/crates/frontend/src/components/error/error_component.rs @@ -29,6 +29,7 @@ impl Component for ErrorComponent { fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { match msg { Msg::ErrorContextUpdated(error_context) => { + log::info!("error context updated"); self.error = error_context.value.clone(); true } diff --git a/crates/frontend/src/components/error/error_provider.rs b/crates/frontend/src/components/error/error_provider.rs index 91e5657..6b7d990 100644 --- a/crates/frontend/src/components/error/error_provider.rs +++ b/crates/frontend/src/components/error/error_provider.rs @@ -3,6 +3,11 @@ use yew::prelude::*; #[derive(Default, Debug, PartialEq, Eq, Clone)] pub struct Error { + // The counter field is a trick so each emission by the reducer is unique. + // Yew will by default try to minimize the number of re-renders by diffing the new virtual DOM against the previous version. + // So this makes sure that downstream subscribers to this context are notified. + _counter: usize, + pub value: Option, } @@ -10,7 +15,11 @@ impl Reducible for Error { type Action = String; fn reduce(self: Rc, action: Self::Action) -> Rc { - Error { value: Some(action) }.into() + Error { + _counter: self._counter + 1, + value: Some(action), + } + .into() } } diff --git a/crates/frontend/src/components/milestone.rs b/crates/frontend/src/components/milestone.rs index 07c9fbb..587d7d3 100644 --- a/crates/frontend/src/components/milestone.rs +++ b/crates/frontend/src/components/milestone.rs @@ -74,7 +74,7 @@ pub fn milestone_component(props: &Props) -> Html { {unfilled_stars}

- +
} diff --git a/crates/frontend/src/components/root.rs b/crates/frontend/src/components/root.rs index 9e8acb4..92480e1 100644 --- a/crates/frontend/src/components/root.rs +++ b/crates/frontend/src/components/root.rs @@ -25,9 +25,11 @@ pub fn Root() -> Html { .achievements .iter() .cloned() - .map(|a| { + .enumerate() + .map(|(idx, a)| (idx + 1, a)) + .map(|(n, a)| { html! { - + } }) .collect::(); diff --git a/crates/frontend/static/css/styles.css b/crates/frontend/static/css/styles.css index 0443eaa..9ee1ea2 100644 --- a/crates/frontend/static/css/styles.css +++ b/crates/frontend/static/css/styles.css @@ -6,6 +6,11 @@ --danger-color: #e74c3c; } +.button.narrow { + padding-left: 15px; + padding-right: 15px; +} + .button.color-primary { color: var(--primary-color) !important; border-color: var(--primary-color) !important;