use yew::prelude::*;

use crate::*;
use crate::container::Container;
pub struct Grid{
    link: ComponentLink<Self>,
    props: GridProperties,
}
#[derive(Properties, Clone, Debug)]
pub struct GridProperties{
  #[prop_or_default]
  pub children: Children,
  #[prop_or_default]
  pub justify_content: String,
  #[prop_or_default]
  pub align_items: String,
  #[prop_or_default]
  pub grid_template_columns: MultiValue<Unit>,
  #[prop_or_default]
  pub grid_gap: Unit,
}
impl Component for Grid {
    type Message = ();
    type Properties = GridProperties;
    fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
        Self{link, props}
    }
    fn update(&mut self, _msg: Self::Message)->ShouldRender {
        true
   }
    fn change(&mut self, _: Self::Properties)-> ShouldRender {
        false
    }
    fn view(&self) -> Html {
      html!{
        <Container is={Elem::Div}, 
          display={"grid"},
          justify_content=self.props.justify_content.clone(),
          align_items= self.props.align_items.clone(),
        >
          {self.props.children.clone()}
        </Container>
      }  
    }
}
