gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 500HTML 254C 19JavaScript 81398 Definiciones

⎇ 2519aebad238d55fb767c2087344ccc99c21d1c6 src/style/alignment.rs Rust · 98 líneas · 4.0 KB Historia Quién tocó qué crudo

add block layout & inherited fixtures, remove unused `flip` function 2519aebad · Kane Wang ·

1//! Style types for controlling alignment
2
3/// Used to control how child nodes are aligned.
4/// For Flexbox it controls alignment in the cross axis
5/// For Grid it controls alignment in the block axis
6///
7/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items)
8#[derive(Copy, Clone, PartialEq, Eq, Debug)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub enum AlignItems {
11    /// Items are packed toward the start of the axis
12    Start,
13    /// Items are packed toward the end of the axis
14    End,
15    /// Items are packed towards the flex-relative start of the axis.
16    ///
17    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
18    /// to End. In all other cases it is equivalent to Start.
19    FlexStart,
20    /// Items are packed towards the flex-relative end of the axis.
21    ///
22    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
23    /// to Start. In all other cases it is equivalent to End.
24    FlexEnd,
25    /// Items are packed along the center of the cross axis
26    Center,
27    /// Items are aligned such as their baselines align
28    Baseline,
29    /// Stretch to fill the container
30    Stretch,
31}
32
33/// Used to control how child nodes are aligned.
34/// Does not apply to Flexbox, and will be ignored if specified on a flex container
35/// For Grid it controls alignment in the inline axis
36///
37/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items)
38pub type JustifyItems = AlignItems;
39/// Controls alignment of an individual node
40///
41/// Overrides the parent Node's `AlignItems` property.
42/// For Flexbox it controls alignment in the cross axis
43/// For Grid it controls alignment in the block axis
44///
45/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self)
46pub type AlignSelf = AlignItems;
47/// Controls alignment of an individual node
48///
49/// Overrides the parent Node's `JustifyItems` property.
50/// Does not apply to Flexbox, and will be ignored if specified on a flex child
51/// For Grid it controls alignment in the inline axis
52///
53/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self)
54pub type JustifySelf = AlignItems;
55
56/// Sets the distribution of space between and around content items
57/// For Flexbox it controls alignment in the cross axis
58/// For Grid it controls alignment in the block axis
59///
60/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content)
61#[derive(Copy, Clone, PartialEq, Eq, Debug)]
62#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
63pub enum AlignContent {
64    /// Items are packed toward the start of the axis
65    Start,
66    /// Items are packed toward the end of the axis
67    End,
68    /// Items are packed towards the flex-relative start of the axis.
69    ///
70    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
71    /// to End. In all other cases it is equivalent to Start.
72    FlexStart,
73    /// Items are packed towards the flex-relative end of the axis.
74    ///
75    /// For flex containers with flex_direction RowReverse or ColumnReverse this is equivalent
76    /// to Start. In all other cases it is equivalent to End.
77    FlexEnd,
78    /// Items are centered around the middle of the axis
79    Center,
80    /// Items are stretched to fill the container
81    Stretch,
82    /// The first and last items are aligned flush with the edges of the container (no gap)
83    /// The gap between items is distributed evenly.
84    SpaceBetween,
85    /// The gap between the first and last items is exactly THE SAME as the gap between items.
86    /// The gaps are distributed evenly
87    SpaceEvenly,
88    /// The gap between the first and last items is exactly HALF the gap between items.
89    /// The gaps are distributed evenly in proportion to these ratios.
90    SpaceAround,
91}
92
93/// Sets the distribution of space between and around content items
94/// For Flexbox it controls alignment in the main axis
95/// For Grid it controls alignment in the inline axis
96///
97/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
98pub type JustifyContent = AlignContent;