Skip to content

Instantly share code, notes, and snippets.

@MichaelArestad
Created July 19, 2014 01:42
Show Gist options
  • Select an option

  • Save MichaelArestad/4b5041a0f6acaabdfeeb to your computer and use it in GitHub Desktop.

Select an option

Save MichaelArestad/4b5041a0f6acaabdfeeb to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// ----
$buttons:(
primary:(
background: blue,
border-color: shade(blue, 15%),
border-top-color: shade(blue, 10%),
border-bottom-color: shade(blue, 20%),
color: white,
focus:(
border-color: #0e3950, // MT / check this color
box-shadow:(
inset 0 1px 0 rgba(120, 200, 230, .6),
1px 1px 2px rgba(0, 0, 0, .4)
)
),
disabled:(
background: #298cba !important,
border-color: #1b607f !important,
color: #94cde7 !important,
text-shadow: 0 -1px 0 rgba(0, 0, 0, .1) !important
)
),
secondary:(
color: orange,
),
tertiary:(
background: blue,
border-color: kitten
)
);
@mixin button(
$border-color: default,
$border-top-color: default,
$border-bottom-color: default,
$background: default,
$color: default
){
@extend %button;
@if $border-color == default {
$border-color: MIXIN-DEFAULT BORDER-COLOR;
}
@if $border-top-color == default {
$border-top-color: MIXIN-DEFAULT BORDER-TOP-COLOR;
}
@if $border-bottom-color == default {
$border-bottom-color: MIXIN-DEFAULT BORDER-BOTTOM-COLOR;
}
@if $background == default {
$background: MIXIN-DEFAULT BACKGROUND;
}
@if $color == default {
$color: MIXIN-DEFAULT COLOR;
}
border-color: $border-color;
border-top-color: $border-top-color;
border-bottom-color: $border-bottom-color;
background: $background;
color: $color;
}
// Base button styles
%button {
display: inline-block;
box-sizing: border-box;
margin: 0;
border-radius: 3px;
border-style: solid;
border-width: 1px 1px 2px;
padding: .4em .9em;
font-size: 13px;
text-overflow: ellipsis;
text-decoration: none;
vertical-align: top;
white-space: nowrap;
appearance: none;
outline: 0;
overflow: hidden;
cursor: pointer;
&:active {
border-width: 2px 1px 1px
}
&.hidden {
display: none
}
// MT / Take a look at these
&[disabled],
&:disabled {
color: #aaa !important;
border-color: #ddd !important;
text-shadow: 0 1px 0 #fff !important;
cursor: default;
box-shadow: none;
}
}
@each $type in map-keys($buttons) {
.button-#{$type} {
$border-color: default;
$border-top-color: default;
$border-bottom-color: default;
$background: default;
$color: default;
// Define border-color
@if map-has-key(map-get($buttons, $type), border-color) {
$border-color: map-get(map-get($buttons, $type), border-color);
}
// Define border-top-color
@if map-has-key(map-get($buttons, $type), border-top-color) {
$border-top-color: map-get(map-get($buttons, $type), border-top-color);
}
// Define border-bottom-color
@if map-has-key(map-get($buttons, $type), border-bottom-color) {
$border-bottom-color: map-get(map-get($buttons, $type), border-bottom-color);
}
// Define background
@if map-has-key(map-get($buttons, $type), background) {
$background: map-get(map-get($buttons, $type), background);
}
// Define color
@if map-has-key(map-get($buttons, $type), color) {
$color: map-get(map-get($buttons, $type), color);
}
@include button(
$border-color: $border-color,
$border-top-color: $border-top-color,
$border-bottom-color: $border-bottom-color,
$background: $background,
$color: $color
);
.test-2 {
color: map-get(map-get($buttons, $type), background);
}
}
}
.test {
color: map-has-key(map-get($buttons, primary), background);
@if map-has-key(map-get($buttons, primary), background) {
button: true;
}
}
.button-primary, .button-secondary, .button-tertiary {
display: inline-block;
box-sizing: border-box;
margin: 0;
border-radius: 3px;
border-style: solid;
border-width: 1px 1px 2px;
padding: .4em .9em;
font-size: 13px;
text-overflow: ellipsis;
text-decoration: none;
vertical-align: top;
white-space: nowrap;
appearance: none;
outline: 0;
overflow: hidden;
cursor: pointer;
}
.button-primary:active, .button-secondary:active, .button-tertiary:active {
border-width: 2px 1px 1px;
}
.hidden.button-primary, .hidden.button-secondary, .hidden.button-tertiary {
display: none;
}
[disabled].button-primary, [disabled].button-secondary, [disabled].button-tertiary, .button-primary:disabled, .button-secondary:disabled, .button-tertiary:disabled {
color: #aaa !important;
border-color: #ddd !important;
text-shadow: 0 1px 0 #fff !important;
cursor: default;
box-shadow: none;
}
.button-primary {
border-color: #0000d8;
border-top-color: #0000e5;
border-bottom-color: #0000cc;
background: blue;
color: white;
}
.button-primary .test-2 {
color: blue;
}
.button-secondary {
border-color: MIXIN-DEFAULT BORDER-COLOR;
border-top-color: MIXIN-DEFAULT BORDER-TOP-COLOR;
border-bottom-color: MIXIN-DEFAULT BORDER-BOTTOM-COLOR;
background: MIXIN-DEFAULT BACKGROUND;
color: orange;
}
.button-tertiary {
border-color: kitten;
border-top-color: MIXIN-DEFAULT BORDER-TOP-COLOR;
border-bottom-color: MIXIN-DEFAULT BORDER-BOTTOM-COLOR;
background: blue;
color: MIXIN-DEFAULT COLOR;
}
.button-tertiary .test-2 {
color: blue;
}
.test {
color: true;
button: true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment