grumply / pure-grid

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Parameterize CSS #1

Open grumply opened 5 years ago

grumply commented 5 years ago

Instead of having baked-in divider color, padding, etc, make the CSS generator a function of some configuration record. The generator function can't exist inside a splice like the current implementation, but a SomeGridT existential could be added to the Grid record to allow for pre-parameterized and pre-compiled grid themes based on the generator.

data GridConfiguration = GridConfiguration
  { padding :: ...
  , relaxedPadding :: ...
  , ...
  }

instance Default GridConfiguration where
  def = GridConfiguration {..}
    where
      ...

gridCSS :: GridConfiguration -> CSS ()
gridCSS GridConfiguration {..} = ...

data SomeGridT = SomeGridT (CSS ())
instance Default SomeGridT where
  def = SomeGridT $(mkRawCSS $ gridCSS def)

instance Themeable SomeGridT where
  theme _ (SomeGridT gt) = gt

data Grid = Grid
  { ...
  , theme :: SomeGridT
  }

instance Pure Grid where
  view Grid {..} =
    let cs = ...
    in as (features & Classes cs & Theme theme) children

Or something like this.

grumply commented 5 years ago

As a side benefit, we could generate an arbitrary number of columns for the theme, programatically.