Skip to content

Instantly share code, notes, and snippets.

@rtablada
Created September 19, 2018 19:32
Show Gist options
  • Save rtablada/1c083d5b6c3cd0b5e19ba3ffd0b6c02f to your computer and use it in GitHub Desktop.
Save rtablada/1c083d5b6c3cd0b5e19ba3ffd0b6c02f to your computer and use it in GitHub Desktop.
import makeStyle from 'ember-something-js-style-thing';
import Component from '@glimmer/component';
export default class MyComponent extends Component {
styles = makeStyle({
title: {
margin: '1rem',
color: (component) => {
return component.isActive ? 'red' : 'black';
}
},
name: {
padding: '2rem'
}
});
}
<div>
<h2 {{styled "title"}}>{{@titleMessage}}</h2>
<p>Hello my name is <span {{styled "name"}}>{{@name}}</span></p>
</div>
{{!-- This is roughly what the component and template above would be equal to --}}
<div>
<h2 class="some-bound-unique-class-for-title" style="{{if isActive "red" "black"}}">{{@titleMessage}}</h2>
<p>Hello my name is <span class="some-bound-unique-class-for-name">{{@name}}</span></p>
</div>
.some-bound-unique-class-for-title {
margin: 1rem;
}
some-bound-unique-class-for-name {
padding: 2rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment