Last active
October 3, 2017 06:26
-
-
Save johnathankent/3a14e7b18792f70e9ba58d74e89fdcc6 to your computer and use it in GitHub Desktop.
Reactive Style Specificity using custom attributes (hack)
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
<!-- picard.vue --> | |
<template> | |
<wesley :class="$style.shutupwesley" data-says-because-picard-said-make-it-so><!-- <<== Added custom data-attr here --> | |
</wesley> | |
</template> | |
<script> | |
import wesley from './wesley.vue' | |
export default { | |
name: 'picard', | |
components: { wesley } | |
} | |
</script> | |
<style module> | |
.shutupwesley[data-says-because-picard-said-make-it-so] { color: crimson; background-color: crimson; } | |
</style> |
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
<div id="starship-enterprise"> | |
<a class="picard_shutupwesley_cptJL_0 wesley_wesley_cru5hr_0" data-says-because-picard-said-make-it-so href="https://codepen.io/johnathankent/pen/QqqdWW/"> | |
Is it cool if my dance crew uses the holodeck to practice our new sick moves?</a> | |
</div> | |
<style> | |
/* It really doesn't matter what order they render - this will override: */ | |
.picard_shutupwesley_cptJL_0[data-says-because-picard-said-make-it-so] { | |
color: crimson; | |
background-color: crimson; | |
} | |
/* over-ridden */ | |
.wesley_wesley_cru5hr_0 { | |
color: blue; | |
background-color: grey; | |
} | |
</style> |
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
<!-- wesley.vue --> | |
<template> | |
<a :class="$style.wesley" :href="url">Is it cool if my dance crew uses the holodeck to practice our new sick moves?</a> | |
</template> | |
<script> | |
export default { | |
name: 'wesley', | |
data () { return { url: 'https://codepen.io/johnathankent/pen/QqqdWW/' } } | |
} | |
</script> | |
<style module> | |
.wesley { color: blue; background-color: grey; } | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment