Skip to content

Instantly share code, notes, and snippets.

@geddski
Created October 24, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geddski/57aeceafbecc1f7c6c9103e0c62098af to your computer and use it in GitHub Desktop.
Save geddski/57aeceafbecc1f7c6c9103e0c62098af to your computer and use it in GitHub Desktop.
workaround for angular 1.x component styling
// Angular 1.x components don't let you do a "replace:true", so they're always nested in another HTML tag.
// This nesting makes it so you can't use some really useful css pseudo-classes like ":last-of-type".
// This workaround puts a CSS class on the actual root, so you can take adavantage of these CSS goodies.
export default class Task {
constructor($element){
// add class to component root element for easier css styling
// using aphrodite
$element.addClass(css(styles.container))
// using plain CSS
$element.addClass('task')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment