Skip to content

Instantly share code, notes, and snippets.

@tgriesser
Created February 1, 2012 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tgriesser/1718640 to your computer and use it in GitHub Desktop.
Save tgriesser/1718640 to your computer and use it in GitHub Desktop.
A Less Implementation of the Bootstrap Buttons Generator
.customButton(@cHue: 201, @cSaturation: 1, @cLightness: .4, @cDelta: .1, @cMultiplier: 1.5) {
.cTextColor(@a, @b) when (@a < .5) { color: #fff; .cAlphaShadow(0, -1, 1, 0, (@b * 3.3)); }
.cTextColor(@a, @b) when (@a > .5) { color: #333; .cAlphaShadow(0, 1, 1, 255, (@b * 3.3)); }
.cTextColor(@a) { -webkit-font-smoothing: antialiased; }
.cAlphaShadow(@a, @b, @c, @d, @e) when (@e > 1) { text-shadow: (0px + @a) (0px + @b) (0px + @c) rgba(@d, @d, @d, 1); }
.cAlphaShadow(@a, @b, @c, @d, @e) when (@e < 1) { text-shadow: (0px + @a) (0px + @b) (0px + @c) rgba(@d, @d, @d, @e); }
@cHighlight: percentage(@cLightness + @cDelta);
@cLowlight: percentage(@cLightness - @cDelta);
@cSuperLowLight: percentage(@cLightness - @cDelta * @cMultiplier);
@cColor: hsl(percentage(@cHue), percentage(@cSaturation), @cHighlight);
@cEndColor: hsl(percentage(@cHue), percentage(@cSaturation), @cLowlight);
@cBorderColor: hsl(percentage(@cHue), percentage(@cSaturation), @cSuperLowLight);
background-color: @cColor;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(@cColor), to(@cEndColor));
background-image: -moz-linear-gradient(top, @cColor, @cEndColor);
background-image: -ms-linear-gradient(top, @cColor, @cEndColor);
background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@cColor), to(@cEndColor));
background-image: -webkit-linear-gradient(top, @cColor, @cEndColor);
background-image: -o-linear-gradient(top, @cColor, @cEndColor);
background-image: linear-gradient(top, @cColor, @cSuperLowLight);
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@cColor,@cEndColor));
border-color: @cEndColor @cEndColor @cBorderColor;
.cTextColor(@cLightness, @cDelta);
}
.btn {
&.custom {
.customButton;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment