bevy_bsml 0.14.10

A UI library to compose UI elements using simple markup language, inspired by svelte and tailwindcss
Documentation
//! Defines the number of columns a grid has and the sizes of those columns. If grid items are given explicit placements then more columns may
//! be implicitly generated by items that are placed out of bounds. The sizes of those columns are controlled by `grid_auto_columns` property.
//!
//! <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns>

use crate::class::ApplyClass;
use bevy_ui::{RepeatedGridTrack, Style};
use derive_more::From;

#[derive(Debug, Clone, From, PartialEq)]
pub struct GridTemplateColumns(pub RepeatedGridTrack);

pub fn grid_cols(repeat: u16) -> GridTemplateColumns {
    GridTemplateColumns(RepeatedGridTrack::flex(repeat, 1.))
}

impl ApplyClass<GridTemplateColumns> for Style {
    #[inline]
    fn apply_class(&mut self, class: &GridTemplateColumns) {
        if !self.grid_template_columns.is_empty() {
            self.grid_template_columns.clear();
        }
        self.grid_template_columns.push(class.0.clone());
    }
}