freya-components 0.4.0-alpha.8

Components for Freya apps
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
use freya_core::prelude::*;
use torin::{
    gaps::Gaps,
    size::Size,
};

#[cfg(feature = "calendar")]
use crate::theming::component_themes::CalendarThemePreference;
#[cfg(feature = "router")]
use crate::theming::component_themes::LinkThemePreference;
use crate::theming::{
    component_themes::{
        AccordionThemePreference,
        ButtonColorsThemePreference,
        ButtonLayoutThemePreference,
        ButtonSegmentThemePreference,
        CheckboxThemePreference,
        ChipThemePreference,
        CircularLoaderThemePreference,
        ColorsSheet,
        FloatingTabThemePreference,
        InputThemePreference,
        MenuContainerThemePreference,
        MenuItemThemePreference,
        PopupThemePreference,
        ProgressBarThemePreference,
        RadioItemThemePreference,
        ResizableHandleThemePreference,
        ScrollBarThemePreference,
        SegmentedButtonThemePreference,
        SelectThemePreference,
        SideBarItemThemePreference,
        SideBarThemePreference,
        SliderThemePreference,
        SwitchThemePreference,
        TableThemePreference,
        Theme,
        TooltipThemePreference,
    },
    macros::Preference,
};

pub(crate) const BASE_THEME: Theme = Theme {
    name: "base",
    colors: ColorsSheet {
        // Brand & Accent
        primary: Color::TRANSPARENT,
        secondary: Color::TRANSPARENT,
        tertiary: Color::TRANSPARENT,

        // Status
        success: Color::TRANSPARENT,
        warning: Color::TRANSPARENT,
        error: Color::TRANSPARENT,
        info: Color::TRANSPARENT,

        // Surfaces
        background: Color::TRANSPARENT,
        surface_primary: Color::TRANSPARENT,
        surface_secondary: Color::TRANSPARENT,
        surface_tertiary: Color::TRANSPARENT,
        surface_inverse: Color::TRANSPARENT,
        surface_inverse_secondary: Color::TRANSPARENT,
        surface_inverse_tertiary: Color::TRANSPARENT,

        // Borders
        border: Color::TRANSPARENT,
        border_focus: Color::TRANSPARENT,
        border_disabled: Color::TRANSPARENT,

        // Text
        text_primary: Color::TRANSPARENT,
        text_secondary: Color::TRANSPARENT,
        text_placeholder: Color::TRANSPARENT,
        text_inverse: Color::TRANSPARENT,
        text_highlight: Color::TRANSPARENT,

        // States
        hover: Color::TRANSPARENT,
        focus: Color::TRANSPARENT,
        active: Color::TRANSPARENT,
        disabled: Color::TRANSPARENT,

        // Utility
        overlay: Color::TRANSPARENT,
        shadow: Color::TRANSPARENT,
    },
    button_layout: ButtonLayoutThemePreference {
        padding: Preference::Specific(Gaps::new(6., 12., 6., 12.)),
        margin: Preference::Specific(Gaps::new_all(0.)),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
    },
    compact_button_layout: ButtonLayoutThemePreference {
        padding: Preference::Specific(Gaps::new(3., 6., 3., 6.)),
        margin: Preference::Specific(Gaps::new_all(0.)),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
    },
    expanded_button_layout: ButtonLayoutThemePreference {
        padding: Preference::Specific(Gaps::new(10., 16., 10., 16.)),
        margin: Preference::Specific(Gaps::new_all(0.)),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
    },
    button: ButtonColorsThemePreference {
        background: Preference::Reference("surface_tertiary"),
        hover_background: Preference::Reference("hover"),
        border_fill: Preference::Reference("border"),
        focus_border_fill: Preference::Reference("border_focus"),
        color: Preference::Reference("text_primary"),
    },
    filled_button: ButtonColorsThemePreference {
        background: Preference::Reference("primary"),
        hover_background: Preference::Reference("tertiary"),
        border_fill: Preference::Specific(Color::TRANSPARENT),
        focus_border_fill: Preference::Reference("secondary"),
        color: Preference::Reference("text_inverse"),
    },
    outline_button: ButtonColorsThemePreference {
        background: Preference::Reference("surface_tertiary"),
        hover_background: Preference::Reference("hover"),
        border_fill: Preference::Reference("border"),
        focus_border_fill: Preference::Reference("secondary"),
        color: Preference::Reference("primary"),
    },
    flat_button: ButtonColorsThemePreference {
        background: Preference::Specific(Color::TRANSPARENT),
        hover_background: Preference::Reference("surface_tertiary"),
        border_fill: Preference::Specific(Color::TRANSPARENT),
        focus_border_fill: Preference::Reference("border"),
        color: Preference::Reference("text_primary"),
    },
    accordion: AccordionThemePreference {
        color: Preference::Reference("text_primary"),
        background: Preference::Reference("surface_tertiary"),
        border_fill: Preference::Reference("border"),
    },
    switch: SwitchThemePreference {
        margin: Preference::Specific(Gaps::new_all(0.)),
        background: Preference::Reference("surface_secondary"),
        thumb_background: Preference::Reference("surface_inverse"),
        toggled_background: Preference::Reference("secondary"),
        toggled_thumb_background: Preference::Reference("primary"),
        focus_border_fill: Preference::Reference("border_focus"),
    },
    scrollbar: ScrollBarThemePreference {
        background: Preference::Reference("surface_primary"),
        thumb_background: Preference::Reference("surface_inverse"),
        hover_thumb_background: Preference::Reference("surface_inverse_secondary"),
        active_thumb_background: Preference::Reference("surface_inverse_tertiary"),
        size: Preference::Specific(15.),
    },
    progressbar: ProgressBarThemePreference {
        color: Preference::Reference("text_inverse"),
        background: Preference::Reference("surface_primary"),
        progress_background: Preference::Reference("primary"),
        height: Preference::Specific(20.),
    },
    sidebar: SideBarThemePreference {
        color: Preference::Reference("text_primary"),
        background: Preference::Reference("surface_tertiary"),
        padding: Preference::Specific(Gaps::new_all(8.)),
        spacing: Preference::Specific(4.),
    },
    sidebar_item: SideBarItemThemePreference {
        color: Preference::Reference("text_primary"),
        background: Preference::Reference("surface_tertiary"),
        active_background: Preference::Reference("surface_secondary"),
        hover_background: Preference::Reference("hover"),
        corner_radius: Preference::Specific(CornerRadius::new_all(99.)),
        margin: Preference::Specific(Gaps::new_all(0.)),
        padding: Preference::Specific(Gaps::new(8., 12., 8., 12.)),
    },
    #[cfg(feature = "router")]
    link: LinkThemePreference {
        color: Preference::Reference("text_highlight"),
    },
    tooltip: TooltipThemePreference {
        background: Preference::Reference("surface_tertiary"),
        color: Preference::Reference("text_primary"),
        border_fill: Preference::Reference("surface_primary"),
    },
    circular_loader: CircularLoaderThemePreference {
        primary_color: Preference::Reference("surface_primary"),
        inversed_color: Preference::Reference("surface_inverse"),
    },
    input: InputThemePreference {
        background: Preference::Reference("surface_tertiary"),
        hover_background: Preference::Reference("background"),
        color: Preference::Reference("text_primary"),
        placeholder_color: Preference::Reference("text_secondary"),
        border_fill: Preference::Reference("border"),
        focus_border_fill: Preference::Reference("border_focus"),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        inner_margin: Preference::Specific(Gaps::new(8., 8., 8., 8.)),
    },
    radio: RadioItemThemePreference {
        unselected_fill: Preference::Reference("surface_inverse_tertiary"),
        selected_fill: Preference::Reference("primary"),
        border_fill: Preference::Reference("surface_primary"),
    },
    checkbox: CheckboxThemePreference {
        unselected_fill: Preference::Reference("surface_inverse_tertiary"),
        selected_fill: Preference::Reference("primary"),
        selected_icon_fill: Preference::Reference("secondary"),
        border_fill: Preference::Reference("surface_primary"),
    },
    resizable_handle: ResizableHandleThemePreference {
        background: Preference::Reference("surface_secondary"),
        hover_background: Preference::Reference("surface_primary"),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
    },
    floating_tab: FloatingTabThemePreference {
        background: Preference::Specific(Color::TRANSPARENT),
        hover_background: Preference::Reference("surface_secondary"),
        color: Preference::Reference("text_primary"),
        padding: Preference::Specific(Gaps::new(6., 12., 6., 12.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
    },
    slider: SliderThemePreference {
        background: Preference::Reference("surface_primary"),
        thumb_background: Preference::Reference("secondary"),
        thumb_inner_background: Preference::Reference("primary"),
        border_fill: Preference::Reference("surface_primary"),
    },
    select: SelectThemePreference {
        width: Preference::Specific(Size::Inner),
        margin: Preference::Specific(Gaps::new_all(0.)),
        select_background: Preference::Reference("background"),
        background_button: Preference::Reference("surface_tertiary"),
        hover_background: Preference::Reference("hover"),
        color: Preference::Reference("text_primary"),
        border_fill: Preference::Reference("border"),
        focus_border_fill: Preference::Reference("border_focus"),
        arrow_fill: Preference::Reference("text_primary"),
    },
    popup: PopupThemePreference {
        background: Preference::Reference("background"),
        color: Preference::Reference("text_primary"),
    },
    table: TableThemePreference {
        background: Preference::Reference("background"),
        arrow_fill: Preference::Reference("text_primary"),
        row_background: Preference::Specific(Color::TRANSPARENT),
        hover_row_background: Preference::Reference("surface_secondary"),
        divider_fill: Preference::Reference("surface_primary"),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        color: Preference::Reference("text_primary"),
    },
    chip: ChipThemePreference {
        background: Preference::Reference("background"),
        hover_background: Preference::Reference("tertiary"),
        selected_background: Preference::Reference("primary"),
        border_fill: Preference::Reference("border"),
        hover_border_fill: Preference::Reference("tertiary"),
        selected_border_fill: Preference::Reference("primary"),
        focus_border_fill: Preference::Reference("secondary"),
        padding: Preference::Specific(Gaps::new(8., 14., 8., 14.)),
        margin: Preference::Specific(0.),
        corner_radius: Preference::Specific(CornerRadius::new_all(99.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
        color: Preference::Reference("text_primary"),
        hover_color: Preference::Reference("text_inverse"),
        selected_color: Preference::Reference("text_inverse"),
        selected_icon_fill: Preference::Reference("secondary"),
        hover_icon_fill: Preference::Reference("secondary"),
    },
    menu_item: MenuItemThemePreference {
        background: Preference::Reference("background"),
        hover_background: Preference::Reference("surface_secondary"),
        select_background: Preference::Reference("surface_secondary"),
        border_fill: Preference::Specific(Color::TRANSPARENT),
        select_border_fill: Preference::Reference("border_focus"),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        color: Preference::Reference("text_primary"),
    },
    menu_container: MenuContainerThemePreference {
        background: Preference::Reference("background"),
        padding: Preference::Specific(Gaps::new_all(4.)),
        shadow: Preference::Reference("shadow"),
        border_fill: Preference::Reference("surface_primary"),
        corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
    },
    button_segment: ButtonSegmentThemePreference {
        background: Preference::Reference("surface_tertiary"),
        hover_background: Preference::Reference("hover"),
        disabled_background: Preference::Reference("disabled"),
        selected_background: Preference::Reference("hover"),
        focus_background: Preference::Reference("surface_secondary"),
        padding: Preference::Specific(Gaps::new(8., 16., 8., 16.)),
        selected_padding: Preference::Specific(Gaps::new(8., 12., 8., 12.)),
        width: Preference::Specific(Size::Inner),
        height: Preference::Specific(Size::Inner),
        color: Preference::Reference("text_primary"),
        selected_icon_fill: Preference::Reference("primary"),
    },
    segmented_button: SegmentedButtonThemePreference {
        background: Preference::Reference("surface_tertiary"),
        border_fill: Preference::Reference("border"),
        corner_radius: Preference::Specific(CornerRadius::new_all(99.)),
    },
    #[cfg(feature = "calendar")]
    calendar: CalendarThemePreference {
        background: Preference::Reference("surface_tertiary"),
        day_background: Preference::Specific(Color::TRANSPARENT),
        day_hover_background: Preference::Reference("hover"),
        day_selected_background: Preference::Reference("surface_primary"),
        color: Preference::Reference("text_primary"),
        day_other_month_color: Preference::Reference("text_placeholder"),
        header_color: Preference::Reference("text_primary"),
        corner_radius: Preference::Specific(CornerRadius::new_all(8.)),
        padding: Preference::Specific(Gaps::new_all(12.)),
        day_corner_radius: Preference::Specific(CornerRadius::new_all(6.)),
        nav_button_hover_background: Preference::Reference("hover"),
    },
};

pub const LIGHT_THEME: Theme = Theme {
    name: "light",
    colors: ColorsSheet {
        // Brand & Accent
        primary: Color::from_rgb(103, 80, 164),
        secondary: Color::from_rgb(202, 193, 227),
        tertiary: Color::from_rgb(79, 61, 130),

        // Status
        success: Color::from_rgb(76, 175, 80),
        warning: Color::from_rgb(255, 193, 7),
        error: Color::from_rgb(244, 67, 54),
        info: Color::from_rgb(33, 150, 243),

        // Surfaces
        background: Color::from_rgb(250, 250, 250),
        surface_primary: Color::from_rgb(210, 210, 210),
        surface_secondary: Color::from_rgb(225, 225, 225),
        surface_tertiary: Color::from_rgb(245, 245, 245),
        surface_inverse: Color::from_rgb(125, 125, 125),
        surface_inverse_secondary: Color::from_rgb(110, 110, 110),
        surface_inverse_tertiary: Color::from_rgb(90, 90, 90),

        // Borders
        border: Color::from_rgb(210, 210, 210),
        border_focus: Color::from_rgb(180, 180, 180),
        border_disabled: Color::from_rgb(210, 210, 210),

        // Text
        text_primary: Color::from_rgb(10, 10, 10),
        text_secondary: Color::from_rgb(100, 100, 100),
        text_placeholder: Color::from_rgb(150, 150, 150),
        text_inverse: Color::WHITE,
        text_highlight: Color::from_rgb(38, 89, 170),

        // States
        hover: Color::from_rgb(235, 235, 235),
        focus: Color::from_rgb(225, 225, 255),
        active: Color::from_rgb(200, 200, 200),
        disabled: Color::from_rgb(210, 210, 210),

        // Utility
        overlay: Color::from_af32rgb(0.5, 0, 0, 0),
        shadow: Color::from_af32rgb(0.2, 0, 0, 0),
    },
    ..BASE_THEME
};

pub const DARK_THEME: Theme = Theme {
    name: "dark",
    colors: ColorsSheet {
        // Brand & Accent
        primary: Color::from_rgb(103, 80, 164),
        secondary: Color::from_rgb(202, 193, 227),
        tertiary: Color::from_rgb(79, 61, 130),

        // Status
        success: Color::from_rgb(129, 199, 132),
        warning: Color::from_rgb(255, 213, 79),
        error: Color::from_rgb(229, 115, 115),
        info: Color::from_rgb(100, 181, 246),

        // Surfaces
        background: Color::from_rgb(20, 20, 20),
        surface_primary: Color::from_rgb(60, 60, 60),
        surface_secondary: Color::from_rgb(45, 45, 45),
        surface_tertiary: Color::from_rgb(25, 25, 25),
        surface_inverse: Color::from_rgb(135, 135, 135),
        surface_inverse_secondary: Color::from_rgb(150, 150, 150),
        surface_inverse_tertiary: Color::from_rgb(170, 170, 170),

        // Borders
        border: Color::from_rgb(60, 60, 60),
        border_focus: Color::from_rgb(110, 110, 110),
        border_disabled: Color::from_rgb(80, 80, 80),

        // Text
        text_primary: Color::from_rgb(250, 250, 250),
        text_secondary: Color::from_rgb(210, 210, 210),
        text_placeholder: Color::from_rgb(150, 150, 150),
        text_inverse: Color::BLACK,
        text_highlight: Color::from_rgb(96, 145, 224),

        // States
        hover: Color::from_rgb(80, 80, 80),
        focus: Color::from_rgb(100, 100, 120),
        active: Color::from_rgb(70, 70, 70),
        disabled: Color::from_rgb(50, 50, 50),

        // Utility
        overlay: Color::from_af32rgb(0.2, 255, 255, 255),
        shadow: Color::from_af32rgb(0.6, 0, 0, 0),
    },
    ..BASE_THEME
};