Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b.var() to generate CSS variable references #25

Open
barneycarroll opened this issue Aug 13, 2018 · 3 comments
Open

b.var() to generate CSS variable references #25

barneycarroll opened this issue Aug 13, 2018 · 3 comments

Comments

@barneycarroll
Copy link
Contributor

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

@porsager
Copy link
Owner

porsager commented Aug 13, 2018

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

@barneycarroll
Copy link
Contributor Author

barneycarroll commented Aug 13, 2018

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),
      }),
    ),
}

@porsager
Copy link
Owner

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants