Skip to content

Instantly share code, notes, and snippets.

@tflori
Last active August 29, 2015 14:24
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 tflori/6644b59e0798580ab248 to your computer and use it in GitHub Desktop.
Save tflori/6644b59e0798580ab248 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<input id="example" type=text value="Example" />
// ----
// libsass (v3.2.5)
// ----
@function hsb_saturation($color){
$hsl-l: lightness($color);
$hsl-s: saturation($color);
$t:
$hsl-s *
if(
$hsl-l < 50,
$hsl-l,
100 - $hsl-l
) / 100%; // Temp value
@return if(
$t > 0%,
round( 200 * $t / $hsl-l + $t),
0
);
}
@function hsb_brightness($color){
$hsl-l: lightness($color);
$hsl-s: saturation($color);
$t:
$hsl-s *
if(
$hsl-l < 50,
$hsl-l,
100 - $hsl-l
) / 100%; // Temp value
@return round($t + $hsl-l);
}
@function hsb($h-hsb, $s-hsb, $b-hsb, $a: 1) {
@if $b-hsb == 0 {
@return hsla(0, 0, 0, $a)
} @else {
$l-hsl: ($b-hsb/2) * (2 - ($s-hsb/100));
$s-hsl: ($b-hsb * $s-hsb) / if($l-hsl < 50, $l-hsl * 2, 200 - $l-hsl * 2);
@return hsla($h-hsb, $s-hsl, $l-hsl, $a);
}
}
//$CIPrimary: hsb(18deg, 44%, 100%);
$CIPrimary: #F06522;
/** RULES **/
$Primary: if(hsb_saturation($CIPrimary) < 30, #F06522, $CIPrimary);
$OnPrimary: if(lightness($Primary) > 54, rgba(black, 0.8), rgba(white, 0.8));
/** TESTS **/
body:before {
//content: '#{lightness($Primary)}';
}
/** USAGE **/
input#example {
border: none;
color: $OnPrimary;
background: $Primary;
padding: 10px;
font-family: "Open Sans";
font-weight: 400;
font-size: 10px;
}
/** RULES **/
/** TESTS **/
/** USAGE **/
input#example {
border: none;
color: rgba(255, 255, 255, 0.8);
background: #F06522;
padding: 10px;
font-family: "Open Sans";
font-weight: 400;
font-size: 10px;
}
<input id="example" type=text value="Example" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment