ui_storybook/stories/
recording_status.rs1use leptos::prelude::*;
4
5use crate::components::recorder::{CompactRecordingState, RecordingStatusButton};
6
7use super::{Story, StoryViewport, render};
8
9const W: u16 = 380;
10const H: u16 = 64;
11
12#[must_use]
14pub fn stories() -> Vec<Story> {
15 vec![
16 story(
17 "recording-status-countdown-3",
18 "Compact status — countdown 3s",
19 render_countdown_3,
20 ),
21 story(
22 "recording-status-countdown-1",
23 "Compact status — countdown 1s",
24 render_countdown_1,
25 ),
26 story(
27 "recording-status-recording",
28 "Compact status — recording",
29 render_recording,
30 ),
31 story(
32 "recording-status-paused",
33 "Compact status — paused",
34 render_paused,
35 ),
36 story(
37 "recording-status-stopping",
38 "Compact status — stopping",
39 render_stopping,
40 ),
41 story(
42 "recording-status-error",
43 "Compact status — error",
44 render_error,
45 ),
46 ]
47}
48
49fn story(id: &'static str, title: &'static str, render: fn() -> String) -> Story {
50 Story {
51 id,
52 category: "Recorder",
53 title,
54 viewport: StoryViewport::Fixed {
55 width: W,
56 height: H,
57 },
58 render,
59 }
60}
61
62fn render_countdown_3() -> String {
63 render(view! {
64 <RecordingStatusButton state=CompactRecordingState::Countdown { seconds_remaining: 3 } />
65 })
66}
67
68fn render_countdown_1() -> String {
69 render(view! {
70 <RecordingStatusButton state=CompactRecordingState::Countdown { seconds_remaining: 1 } />
71 })
72}
73
74fn render_recording() -> String {
75 render(view! {
76 <RecordingStatusButton
77 state=CompactRecordingState::Recording { elapsed_label: "00:42".to_owned() }
78 shortcuts=vec!["⌘".to_owned(), "⇧".to_owned(), "2".to_owned()]
79 />
80 })
81}
82
83fn render_paused() -> String {
84 render(view! {
85 <RecordingStatusButton
86 state=CompactRecordingState::Paused { elapsed_label: "01:18".to_owned() }
87 />
88 })
89}
90
91fn render_stopping() -> String {
92 render(view! {
93 <RecordingStatusButton state=CompactRecordingState::Stopping />
94 })
95}
96
97fn render_error() -> String {
98 render(view! {
99 <RecordingStatusButton
100 state=CompactRecordingState::Error { message: "Disk full — recording stopped".to_owned() }
101 />
102 })
103}