Created
October 24, 2016 20:50
-
-
Save geddski/57aeceafbecc1f7c6c9103e0c62098af to your computer and use it in GitHub Desktop.
workaround for angular 1.x component styling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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