Created
February 13, 2015 14:08
-
-
Save abe33/6a3528763b2b6b2a97c8 to your computer and use it in GitHub Desktop.
Styleguide Example
This file contains hidden or 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
class StyleguideItemElement extends HTMLElement | |
createdCallback: -> | |
console.log 'here' | |
@shadowRoot = @createShadowRoot() | |
@contentContainer = document.createElement('div') | |
content = document.createElement('content') | |
content.setAttribute('select', '*') | |
@contentContainer.appendChild(content) | |
@shadowRoot.appendChild(@contentContainer) | |
pre = document.createElement('pre') | |
@codeContainer = document.createElement('code') | |
pre.appendChild(@codeContainer) | |
@shadowRoot.appendChild(pre) | |
contentTargets = @querySelectorAll('*') | |
sources = Array::map.call contentTargets, (el) -> el.outerHTML | |
@codeContainer.textContent = sources.join('\n') | |
StyleguideItemElement = | |
document.registerElement 'styleguide-item', prototype: StyleguideItemElement.prototype |
This file contains hidden or 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
styleguide-item | |
for color in ['default', 'primary', 'info', 'success', 'warning', 'danger'] | |
button.btn(class="btn-#{color}")= color.replace(/^\w/, function(m){ return m.toUpperCase() }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment