elvis_core/style/
grid.rs

1//! Grid Style
2use crate::{
3    style::Style,
4    value::{
5        layouts::{GridAuto, GridFlow, GridTemplate},
6        Unit,
7    },
8};
9use elvis_core_support::Setter;
10
11/// `Grid` Style
12#[derive(Default, Clone, Setter)]
13pub struct GridStyle {
14    /// Grid column
15    pub col: Option<GridAuto>,
16    /// Grid column gap
17    pub col_gap: Option<Unit>,
18    /// Grid flow
19    pub flow: Option<GridFlow>,
20    /// Grid row
21    pub row: Option<GridAuto>,
22    /// Grid row gap
23    pub row_gap: Option<Unit>,
24    /// Grid template_column
25    pub template_col: Option<GridTemplate>,
26    /// Grid template_row
27    pub template_row: Option<GridTemplate>,
28}
29
30impl Into<Vec<Style>> for GridStyle {
31    fn into(self) -> Vec<Style> {
32        let mut styles: Vec<Style> = vec![];
33        option_to_style! {
34            styles, [
35                (GridAutoColumns, self.col),
36                (GridAutoRows, self.row),
37                (GridAutoFlow, self.flow),
38                (GridColumnGap, self.col_gap),
39                (GridRowGap, self.row_gap),
40                (GridTemplateColumns, self.template_col),
41                (GridTemplateRows, self.template_row),
42            ],
43        }
44        styles
45    }
46}