polyhorn_ui/styles/
flex.rs

1use strum_macros::EnumString;
2
3/// Controls the direction in which items are layed out.
4#[derive(Copy, Clone, Debug, Eq, PartialEq, EnumString)]
5pub enum FlexDirection {
6    /// Items are layed out vertically from top to bottom.
7    #[strum(serialize = "column")]
8    Column,
9
10    /// Items are layed out vertically from bottom to top.
11    #[strum(serialize = "column-reverse")]
12    ColumnReverse,
13
14    /// Items are layed out horizontally in the layout direction (either left to
15    /// right or right to left).
16    #[strum(serialize = "row")]
17    Row,
18
19    /// Items are layed out horizontally in the reverse layout direction (either
20    /// right to left or left to right).
21    #[strum(serialize = "row-reverse")]
22    RowReverse,
23}
24
25/// Controls how items are aligned along the main axis of a flexbox.
26#[derive(Copy, Clone, Debug, Eq, PartialEq, EnumString)]
27pub enum Align {
28    /// Items are aligned at the start of the cross axis.
29    #[strum(serialize = "flex-start")]
30    FlexStart,
31
32    /// Items are aligned at the center along the main axis.
33    #[strum(serialize = "center")]
34    Center,
35
36    /// Items are aligned at the end of the cross axis.
37    #[strum(serialize = "flex-end")]
38    FlexEnd,
39
40    /// Items are stretched between the start and end of the cross axis.
41    #[strum(serialize = "stretch")]
42    Stretch,
43
44    /// Items are spaced evenly between, the first item starts at the start of
45    /// the cross axis and the last item ends at the end of the cross axis.
46    #[strum(serialize = "space-between")]
47    SpaceBetween,
48
49    /// Items are spaced evenly around, the first item starts after the start of
50    /// the cross axis and the last item ends before the end of the cross axis.
51    #[strum(serialize = "space-around")]
52    SpaceAround,
53}
54
55/// Controls how content is justified along the cross axis of a flexbox.
56#[derive(Copy, Clone, Debug, Eq, PartialEq, EnumString)]
57pub enum Justify {
58    /// Content is justified at the start of the main axis.
59    #[strum(serialize = "flex-start")]
60    FlexStart,
61
62    /// Content is justified at the center along the cross axis.
63    #[strum(serialize = "center")]
64    Center,
65
66    /// Content is justified at the end of the main axis.
67    #[strum(serialize = "flex-end")]
68    FlexEnd,
69
70    /// Content is spaced evenly between, the first content starts at the start
71    /// of the main axis and the last content ends at the end of the main axis.
72    #[strum(serialize = "space-between")]
73    SpaceBetween,
74
75    /// Items are spaced evenly around, the first content starts after the start
76    /// of the main axis and the last content ends before the end of the main
77    /// axis.
78    #[strum(serialize = "space-around")]
79    SpaceAround,
80
81    /// Items are evenly spaced: the space between items is equal to the space
82    /// between the first and last item and both ends of the main axis
83    /// respectively.
84    #[strum(serialize = "space-evenly")]
85    SpaceEvenly,
86}