Skip to content

Instantly share code, notes, and snippets.

@trumball
Created April 19, 2016 14:49
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 trumball/527a751ed569964d504a5ebcb688673e to your computer and use it in GitHub Desktop.
Save trumball/527a751ed569964d504a5ebcb688673e to your computer and use it in GitHub Desktop.
Swatches Template
<script id="swatch-template" type="text/template">
{{#swatches}}
<div class="col-lg-2">
<div class="swatch color-{{.}}">
<div class="chip"></div>
<div class="info">
<span>{{.}}</span>
<small></small>
</div>
</div>
</div>
{{/swatches}}
</script>
(function() {
var swatch = {
swatches: ['primary', "secondary", "tertiary"],
shadesofgray: ['gray-darker', "gray-dark", "gray", "gray-light", "gray-lighter"],
statuscolors: ['success', "info", "warning", "danger"],
init: function() {
this.casheDOM();
this.render();
this.renderGray();
this.renderStatus();
},
casheDOM: function() {
this.$colorScheme = $('#color-scheme');
this.$grayScheme = $('#gray-scheme');
this.$statusScheme = $('#status-scheme');
this.template = $('#swatch-template').html();
},
render: function() {
var data = {
swatches: this.swatches,
};
this.$colorScheme.html(Mustache.render(this.template, data))
},
renderGray: function() {
var data = {
swatches: this.shadesofgray,
};
this.$grayScheme.html(Mustache.render(this.template, data))
},
renderStatus: function() {
var data = {
swatches: this.statuscolors,
};
this.$statusScheme.html(Mustache.render(this.template, data))
},
};
swatch.init();
})();
.swatch {
.rounded;
background-color: #fff;
width: 100%;
border:1px solid @gray-light;
margin:10px;
.chip {
width: 100%;
height: 100px;
.border-top-radius(@border-radius-base);
}
.info {
padding: .5rem 1.0rem;
background-color: @gray-light;
span {
margin-bottom: 3px;
display: block;
}
small {
}
}
}
.build-swatch(@color) {
.chip {
background-color: @color;
}
.info small:after {
content: "@{color}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment