1+ //! CSS properties related to box alignment.
2+
13use super :: flex:: { BoxAlign , BoxPack , FlexAlign , FlexItemAlign , FlexLinePack , FlexPack } ;
24use super :: { Property , PropertyId } ;
35use crate :: compat;
@@ -13,10 +15,13 @@ use crate::values::length::LengthPercentage;
1315use crate :: vendor_prefix:: VendorPrefix ;
1416use cssparser:: * ;
1517
16- /// https://www.w3.org/TR/2020/WD-css-align-3-20200421/#typedef-baseline-position
18+ /// A [`<baseline-position>`](https://www.w3.org/TR/css-align-3/#typedef-baseline-position) value,
19+ /// as used in the alignment properties.
1720#[ derive( Debug , Clone , PartialEq ) ]
1821pub enum BaselinePosition {
22+ /// The first baseline.
1923 First ,
24+ /// The last baseline.
2025 Last ,
2126}
2227
@@ -54,40 +59,57 @@ impl ToCss for BaselinePosition {
5459}
5560
5661enum_property ! {
57- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#typedef-content-distribution
62+ /// A [`<content-distribution>`]( https://www.w3.org/TR/css-align-3/#typedef-content-distribution) value.
5863 pub enum ContentDistribution {
64+ /// Items are spaced evenly, with the first and last items against the edge of the container.
5965 "space-between" : SpaceBetween ,
66+ /// Items are spaced evenly, with half-size spaces at the start and end.
6067 "space-around" : SpaceAround ,
68+ /// Items are spaced evenly, with full-size spaces at the start and end.
6169 "space-evenly" : SpaceEvenly ,
70+ /// Items are stretched evenly to fill free space.
6271 "stretch" : Stretch ,
6372 }
6473}
6574
6675enum_property ! {
67- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#typedef-overflow-position
76+ /// An [`<overflow-position>`]( https://www.w3.org/TR/css-align-3/#typedef-overflow-position) value.
6877 pub enum OverflowPosition {
78+ /// If the size of the alignment subject overflows the alignment container,
79+ /// the alignment subject is instead aligned as if the alignment mode were start.
6980 Safe ,
81+ /// Regardless of the relative sizes of the alignment subject and alignment
82+ /// container, the given alignment value is honored.
7083 Unsafe ,
7184 }
7285}
7386
7487enum_property ! {
75- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#typedef-content-position
88+ /// A [`<content-position>`]( https://www.w3.org/TR/css-align-3/#typedef-content-position) value.
7689 pub enum ContentPosition {
90+ /// Content is centered within the container.
7791 "center" : Center ,
92+ /// Content is aligned to the start of the container.
7893 "start" : Start ,
94+ /// Content is aligned to the end of the container.
7995 "end" : End ,
96+ /// Same as `start` when within a flexbox container.
8097 "flex-start" : FlexStart ,
98+ /// Same as `end` when within a flexbox container.
8199 "flex-end" : FlexEnd ,
82100 }
83101}
84102
85- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#propdef-align-content
103+ /// A value for the [align-content]( https://www.w3.org/TR/css-align-3/#propdef-align-content) property.
86104#[ derive( Debug , Clone , PartialEq ) ]
87105pub enum AlignContent {
106+ /// Default alignment.
88107 Normal ,
108+ /// A baseline position.
89109 BaselinePosition ( BaselinePosition ) ,
110+ /// A content distribution keyword.
90111 ContentDistribution ( ContentDistribution ) ,
112+ /// A content position keyword, with optional overflow position.
91113 ContentPosition ( Option < OverflowPosition > , ContentPosition ) ,
92114}
93115
@@ -132,13 +154,18 @@ impl ToCss for AlignContent {
132154 }
133155}
134156
135- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#propdef-justify-content
157+ /// A value for the [justify-content]( https://www.w3.org/TR/css-align-3/#propdef-justify-content) property.
136158#[ derive( Debug , Clone , PartialEq ) ]
137159pub enum JustifyContent {
160+ /// Default justification.
138161 Normal ,
162+ /// A content distribution keyword.
139163 ContentDistribution ( ContentDistribution ) ,
164+ /// A content position keyword, with optional overflow position.
140165 ContentPosition ( Option < OverflowPosition > , ContentPosition ) ,
166+ /// Justify to the left, with an optional overflow position.
141167 Left ( Option < OverflowPosition > ) ,
168+ /// Justify to the right, with an optional overflow position.
142169 Right ( Option < OverflowPosition > ) ,
143170}
144171
@@ -205,10 +232,12 @@ impl ToCss for JustifyContent {
205232 }
206233}
207234
208- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#place-content
235+ /// A value for the [place-content]( https://www.w3.org/TR/css-align-3/#place-content) shorthand property.
209236#[ derive( Debug , Clone , PartialEq ) ]
210237pub struct PlaceContent {
238+ /// The content alignment.
211239 pub align : AlignContent ,
240+ /// The content justification.
212241 pub justify : JustifyContent ,
213242}
214243
@@ -261,25 +290,37 @@ impl ToCss for PlaceContent {
261290}
262291
263292enum_property ! {
264- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#typedef-self-position
293+ /// A [`<self-position>`]( https://www.w3.org/TR/css-align-3/#typedef-self-position) value.
265294 pub enum SelfPosition {
295+ /// Item is centered within the container.
266296 "center" : Center ,
297+ /// Item is aligned to the start of the container.
267298 "start" : Start ,
299+ /// Item is aligned to the end of the container.
268300 "end" : End ,
301+ /// Item is aligned to the edge of the container corresponding to the start side of the item.
269302 "self-start" : SelfStart ,
303+ /// Item is aligned to the edge of the container corresponding to the end side of the item.
270304 "self-end" : SelfEnd ,
305+ /// Item is aligned to the start of the container, within flexbox layouts.
271306 "flex-start" : FlexStart ,
307+ /// Item is aligned to the end of the container, within flexbox layouts.
272308 "flex-end" : FlexEnd ,
273309 }
274310}
275311
276- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421/#propdef- align-self
312+ /// A value for the [align-self]( https://www.w3.org/TR/css-align-3/# align-self-property) property.
277313#[ derive( Debug , Clone , PartialEq ) ]
278314pub enum AlignSelf {
315+ /// Automatic alignment.
279316 Auto ,
317+ /// Default alignment.
280318 Normal ,
319+ /// Item is stretched.
281320 Stretch ,
321+ /// A baseline position keyword.
282322 BaselinePosition ( BaselinePosition ) ,
323+ /// A self position keyword, with optional overflow position.
283324 SelfPosition ( Option < OverflowPosition > , SelfPosition ) ,
284325}
285326
@@ -329,15 +370,22 @@ impl ToCss for AlignSelf {
329370 }
330371}
331372
332- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421/#propdef- justify-self
373+ /// A value for the [justify-self]( https://www.w3.org/TR/css-align-3/# justify-self-property) property.
333374#[ derive( Debug , Clone , PartialEq ) ]
334375pub enum JustifySelf {
376+ /// Automatic justification.
335377 Auto ,
378+ /// Default justification.
336379 Normal ,
380+ /// Item is stretched.
337381 Stretch ,
382+ /// A baseline position keyword.
338383 BaselinePosition ( BaselinePosition ) ,
384+ /// A self position keyword, with optional overflow position.
339385 SelfPosition ( Option < OverflowPosition > , SelfPosition ) ,
386+ /// Item is justified to the left, with an optional overflow position.
340387 Left ( Option < OverflowPosition > ) ,
388+ /// Item is justified to the right, with an optional overflow position.
341389 Right ( Option < OverflowPosition > ) ,
342390}
343391
@@ -414,10 +462,12 @@ impl ToCss for JustifySelf {
414462 }
415463}
416464
417- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#place-self-property
465+ /// A value for the [place-self]( https://www.w3.org/TR/css-align-3/#place-self-property) shorthand property.
418466#[ derive( Debug , Clone , PartialEq ) ]
419467pub struct PlaceSelf {
468+ /// The item alignment.
420469 pub align : AlignSelf ,
470+ /// The item justification.
421471 pub justify : JustifySelf ,
422472}
423473
@@ -470,12 +520,16 @@ impl ToCss for PlaceSelf {
470520 }
471521}
472522
473- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#align-items-property
523+ /// A value for the [align-items]( https://www.w3.org/TR/css-align-3/#align-items-property) property.
474524#[ derive( Debug , Clone , PartialEq ) ]
475525pub enum AlignItems {
526+ /// Default alignment.
476527 Normal ,
528+ /// Items are stretched.
477529 Stretch ,
530+ /// A baseline position keyword.
478531 BaselinePosition ( BaselinePosition ) ,
532+ /// A self position keyword, with an optional overflow position.
479533 SelfPosition ( Option < OverflowPosition > , SelfPosition ) ,
480534}
481535
@@ -520,10 +574,14 @@ impl ToCss for AlignItems {
520574 }
521575}
522576
577+ /// A legacy justification keyword, as used in the `justify-items` property.
523578#[ derive( Debug , Clone , PartialEq ) ]
524579pub enum LegacyJustify {
580+ /// Left justify.
525581 Left ,
582+ /// Right justify.
526583 Right ,
584+ /// Centered.
527585 Center ,
528586}
529587
@@ -577,15 +635,22 @@ impl ToCss for LegacyJustify {
577635 }
578636}
579637
580- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#justify-items-property
638+ /// A value for the [justify-items]( https://www.w3.org/TR/css-align-3/#justify-items-property) property.
581639#[ derive( Debug , Clone , PartialEq ) ]
582640pub enum JustifyItems {
641+ /// Default justification.
583642 Normal ,
643+ /// Items are stretched.
584644 Stretch ,
645+ /// A baseline position keyword.
585646 BaselinePosition ( BaselinePosition ) ,
647+ /// A self position keyword, with optional overflow position.
586648 SelfPosition ( Option < OverflowPosition > , SelfPosition ) ,
649+ /// Items are justified to the left, with an optional overflow position.
587650 Left ( Option < OverflowPosition > ) ,
651+ /// Items are justified to the right, with an optional overflow position.
588652 Right ( Option < OverflowPosition > ) ,
653+ /// A legacy justification keyword.
589654 Legacy ( LegacyJustify ) ,
590655}
591656
@@ -662,10 +727,12 @@ impl ToCss for JustifyItems {
662727 }
663728}
664729
665- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#place-items-property
730+ /// A value for the [place-items]( https://www.w3.org/TR/css-align-3/#place-items-property) shorthand property.
666731#[ derive( Debug , Clone , PartialEq ) ]
667732pub struct PlaceItems {
733+ /// The item alignment.
668734 pub align : AlignItems ,
735+ /// The item justification.
669736 pub justify : JustifyItems ,
670737}
671738
@@ -716,10 +783,13 @@ impl ToCss for PlaceItems {
716783 }
717784}
718785
719- /// https://www.w3.org/TR/2020/WD-css-align-3-20200421/#column-row-gap
786+ /// A [gap](https://www.w3.org/TR/css-align-3/#column-row-gap) value, as used in the
787+ /// `column-gap` and `row-gap` properties.
720788#[ derive( Debug , Clone , PartialEq ) ]
721789pub enum GapValue {
790+ /// Equal to `1em` for multi-column containers, and zero otherwise.
722791 Normal ,
792+ /// An explicit length.
723793 LengthPercentage ( LengthPercentage ) ,
724794}
725795
@@ -746,10 +816,12 @@ impl ToCss for GapValue {
746816 }
747817}
748818
749- /// https://www.w3.org/TR/2020/WD- css-align-3-20200421 /#gap-shorthand
819+ /// A value for the [gap]( https://www.w3.org/TR/css-align-3/#gap-shorthand) shorthand property.
750820#[ derive( Debug , Clone , PartialEq ) ]
751821pub struct Gap {
822+ /// The row gap.
752823 pub row : GapValue ,
824+ /// The column gap.
753825 pub column : GapValue ,
754826}
755827
0 commit comments