Skip to content

Instantly share code, notes, and snippets.

View seven-phases-max's full-sized avatar

Max Mikhailov seven-phases-max

View GitHub Profile
.filter:extend(.btn-group all) {}
button:extend(.btn-default, .btn all) {}
.filter > button:extend(.btn-group > .btn all) {}
// also don't miss that there're a lot of classes like
// .btn-group-xs .btn-xs etc. etc.
// and none of those are considered by above code
// (so you also have to code them explicitly when needed)
.font-face(@family, @filename: @family) {
// font-family and font file name don't have to be the same but let's keep it simple
font-family: "@{family}";
@font-face {
font-family: "@{family}";
@file: "../fonts/@{filename}";
src: url("@{file}.eot");
#np-namespace {
@color: red;
.mixin() {
color: @color;
}
}
#namespace() {
@color: blue;
.np-mixin {
// Dynamically generated classes as mixins:
.generate-1(@name) {
.@{name} {
color: red;
}
}
.generate-2(@name) {
@{name} {
.usage {
.absolute(top 123px, left 321px);
.relative(top, left 123px, right 456px);
.fixed(bottom, left);
// or whatever else CSS [property value(s)] pairs (empty value expanded as 0):
.expand-style(padding);
.expand-style(color red, background-color blue, border 1px solid green);
// etc.
.button-link {
&, &:hover {
color: black;
background: white;
}
}
.button-link {
.imlazyandherearemycolors(white, black);
}
.not-button-link {
.imlazyandherearemycolors(red, blue);
}
.imlazyandherearemycolors(@fore, @back: (#fff - @fore), @state: ~':hover') {
color: @fore;
@foobar: #69c;
.z {
@pre: foo;
@post: bar;
@a: "@{pre}@{post}";
@b: ~"@{@{pre}@{post}}";
.-() {@c: ~"@{@{pre}@{post}}"} .-;
.generate-something(4);
.generate-something(@i) when (@i > 0) {
// just invoke next iteration *before* styles
// so the styles output when the loop is unwinded
// and the whole thing works in reverse:
.generate-something((@i - 1));
.something-@{i} {
left: (@i * 1%);
}
@font-awesome-icons:
glass "\f000",
music "\f001",
search "\f002",
envelope-o "\f003",
heart "\f004",
star "\f005",
star-o "\f006",
user "\f007",