davesnx / styled-ppx

Type-safe styled components for ReScript, Melange and native with type-safe CSS
https://styled-ppx.vercel.app
BSD 2-Clause "Simplified" License
399 stars 32 forks source link

Implement `switch%cx` #434

Open davesnx opened 5 months ago

davesnx commented 5 months ago

Similar on how switch%style_label works, but with cx

let boxBackground = bg =>
  switch%style_label (bg) {
  | Transparent => []
  | Sheet => [backgroundColor(Color.Background.box), boxShadows(BoxShadow.elevation1)]
  | SheetWithShadowElevation3 => [backgroundColor(Color.Background.box), boxShadows(BoxShadow.elevation3)]
  | SidebarItemSelected => [backgroundColor(Color.Background.sidebarItemSelected)]
  | AccentMuted => [backgroundColor(Color.Background.accentMuted)]
  | NavBarWithShadow => [
      backgroundColor(ColorAlt.Background.box),
      boxShadow(Shadow.box(~inset=true, ~y=`px(-1), Color.Border.lineAlpha)),
    ]
  | NavBar => [backgroundColor(ColorAlt.Background.box)]
  | Code => [backgroundColor(Color.Background.codeAlpha)]
  | Dark => [backgroundColor(Color.Background.boxDark)]
  };