KNACSS/sass/components/buttons.scss

159 lines
2.9 KiB
SCSS
Raw Normal View History

2017-07-31 13:24:04 +02:00
/* ----------------------------- */
/* ==Buttons */
/* ----------------------------- */
/* preferably use <button> for buttons !*/
/* use .btn-- or .button-- classes for variants */
%btn {
display: inline-block;
padding: $tiny-value $small-value;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
2017-07-31 15:49:38 +02:00
transition: 0.25s;
2017-07-31 13:24:04 +02:00
transition-property: box-shadow, background-color, color, border;
2017-07-31 15:49:38 +02:00
text-align: center;
vertical-align: middle;
white-space: nowrap;
text-decoration: none;
color: $color-base;
border: none;
border-radius: $border-radius;
background-color: $color-muted;
font-family: inherit;
font-size: inherit;
line-height: 1;
2017-07-31 13:24:04 +02:00
}
.btn,
.button,
[type="button"],
button {
@extend %btn;
&:focus {
-webkit-tap-highlight-color: transparent;
}
}
2017-07-31 14:00:06 +02:00
2017-07-31 13:24:04 +02:00
.btn,
.button {
2017-07-31 15:49:38 +02:00
@each $name, $background-color, $color, $border in $variants-list {
2017-07-31 14:00:06 +02:00
&--#{$name} {
2017-07-31 13:24:04 +02:00
@extend %btn;
2017-07-31 14:00:06 +02:00
background-color: $background-color;
color: $color;
box-shadow: $border;
2017-07-31 13:24:04 +02:00
&:active,
&:focus,
&:hover {
2017-07-31 14:00:06 +02:00
background-color: darken( $background-color, 10% );
2017-07-31 13:24:04 +02:00
}
}
}
}
2017-07-31 14:00:06 +02:00
2017-07-31 13:24:04 +02:00
// button state variants
.btn,
.button {
&--small {
font-size: $base-font-size - 0.4rem;
}
&--big {
font-size: $base-font-size + 0.4rem;
}
&--block {
width: 100% !important;
display: block;
}
&.disabled,
2017-07-31 15:49:38 +02:00
&--disabled {
2017-07-31 13:24:04 +02:00
opacity: 0.5;
cursor: not-allowed;
}
2017-07-31 15:49:38 +02:00
&--unstyled {
2017-07-31 13:24:04 +02:00
padding: 0;
border: none;
text-align: left;
background: none;
border-radius: 0;
box-shadow: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
&:focus {
box-shadow: none;
outline: none;
}
}
}
2017-07-31 21:31:56 +02:00
// burger button
.button-burger {
position: relative;
height: 2.4rem;
width: 2.8rem;
background-color: transparent;
2017-07-31 21:42:15 +02:00
background-image: linear-gradient($color-burger, $color-burger);
2017-07-31 21:31:56 +02:00
background-position: center;
background-repeat: no-repeat;
background-size: 100% 5px;
padding: 0;
outline: 0;
border: 0;
color: #333;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: .25s cubic-bezier(.17,.67,.89,1.4);
transition-property: transform;
will-change: transform;
2017-07-31 21:42:15 +02:00
& > * {
@extend .visually-hidden;
}
2017-07-31 21:31:56 +02:00
&::before,
&::after {
content: "";
position: absolute;
left: 0; right: 0;
display: block;
height: 5px;
2017-07-31 21:42:15 +02:00
background: $color-burger;
2017-07-31 21:31:56 +02:00
transition: .25s;
transition-property: transform, top;
will-change: transform, top;
}
&::before {
top: 0;
}
&:after {
top: calc(100% - 4px);
}
&:focus,
&.is-active,
&.js-active {
background-image: none;
&::before,
&::after {
top: 50%;
}
&::before {
transform: translate3d(0,-50%,0) rotate3d(0,0,1,45deg);
}
&::after {
transform: translate3d(0,-50%,0) rotate3d(0,0,1,-45deg);
}
}
}