bss icon indicating copy to clipboard operation
bss copied to clipboard

`b.var()` to generate CSS variable references

Open barneycarroll opened this issue 6 years ago • 3 comments

…the same way BSS currently does for class names. That way we can avoid accidental cascades!

barneycarroll avatar Aug 13 '18 12:08 barneycarroll

More like $.keyframes perhaps? Could you make some pseudo code of how you imagined usage?

porsager avatar Aug 13 '18 12:08 porsager

Yes, much the same. Remember we were talking about the problem of accidental downstream collisions?

Straw man:

export const color = b.var('buttonColour')

export const Button = b`
  border-radius: 3px;
  color        : var(${ color });
`

//

import { Button, color } from './Button'

export const Modal = {
  view: ({attrs, children}) => 
    m(Etc, 
      children,
      
      m('button' + Button, {
        [color] : 'green',
        onclick : attrs.update(true),
      }),
      
      m('button' + Button, {
        [color] : 'red',
        onclick : attrs.update(false),
      }),
    ),
}

barneycarroll avatar Aug 13 '18 18:08 barneycarroll

Yeah exactly. That's a really good way to solve it!

In your example the [color] would need to be under style right?

porsager avatar Aug 15 '18 06:08 porsager