1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 13:41:54 +02:00
blog/src/styles/_mixins.scss

231 lines
4.8 KiB
SCSS

@import 'variables';
// Centering Blocks
/////////////////////////////////////
@mixin aligncenter() {
display: block;
margin-left: auto;
margin-right: auto;
}
// Toggling content
/////////////////////////////////////
// Hide from both screenreaders and browsers: h5bp.com/u
@mixin hide() {
display: none !important;
visibility: hidden;
}
@mixin show() {
display: block;
visibility: visible;
}
// Hide only visually, but have it available for screenreaders: h5bp.com/v
@mixin visuallyhidden() {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
// Extends the .visuallyhidden class to allow the
// element to be focusable when navigated to via the keyboard: h5bp.com/p
&.focusable:active,
&.focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
}
// Hide visually and from screenreaders, but maintain layout
@mixin invisible() {
visibility: hidden;
}
// CSS image replacement
/////////////////////////////////////
@mixin hide-text() {
font: 0/0 a; // stylelint-disable font-family-no-missing-generic-family-keyword
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
// Text overflow
/////////////////////////////////////
@mixin ellipsis() {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
// Default transition
/////////////////////////////////////
@mixin transition() {
transition: all ease-in-out .15s;
}
// Dashed Dividers
/////////////////////////////////////
@mixin divider() {
position: relative;
border-bottom: 1px dashed lighten($brand-grey-light, 20%);
margin-top: $spacer * $line-height;
margin-bottom: $spacer * $line-height;
&::before {
content: '';
position: absolute;
left: 0;
height: 1px;
bottom: -2px;
width: 100%;
border-bottom: 1px dashed #fff;
}
}
@mixin divider-top() {
position: relative;
border-top: 1px dashed lighten($brand-grey-light, 20%);
margin-top: $spacer * $line-height;
margin-bottom: $spacer * $line-height;
&::after {
content: '';
position: absolute;
left: 0;
height: 1px;
top: 0;
width: 100%;
border-bottom: 1px dashed #fff;
}
}
// Heading band
/////////////////////////////////////
@mixin heading-band() {
display: inline-block;
background: rgba(255, 255, 255, .5);
padding: ($spacer/2) $spacer ($spacer/2) 100%;
margin-left: -100%;
}
// Layout breakout
/////////////////////////////////////
@mixin breakoutviewport() {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
@media (min-width: $screen-md) {
@include breakoutviewport--base();
}
}
@mixin breakoutviewport--base() {
margin-left: -($spacer * 4);
margin-right: -($spacer * 4);
}
@mixin breakoutviewport--full() {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
}
// Button sizing
/////////////////////////////////////
@mixin button-size(
$padding-vertical,
$padding-horizontal,
$font-size,
$line-height,
$border-radius
) {
padding: $padding-vertical $padding-horizontal;
font-size: $font-size;
line-height: $line-height;
border-radius: $border-radius;
}
// Form control sizing
/////////////////////////////////////
@mixin input-size(
$padding-vertical,
$padding-horizontal,
$font-size,
$line-height,
$border-radius
) {
padding: $padding-vertical $padding-horizontal;
font-size: $font-size;
line-height: $line-height;
border-radius: $border-radius;
&input[type='search'] {
background-size: $font-size;
background-position: $padding-vertical center;
padding-left: ($padding-vertical * 4);
}
&select {
line-height: $input-height;
}
&textarea,
&select[multiple] {
height: auto;
}
}
// Placeholder text
/////////////////////////////////////
@mixin placeholder($color: $input-color-placeholder) {
&::-moz-placeholder {
color: $color;
opacity: 1; // Override Firefox's unusual default opacity; See https//github.com/twbs/bootstrap/pull/11526
}
&::-webkit-input-placeholder {
color: $color;
}
&:-ms-input-placeholder {
color: $color;
}
}
// Image frame style
/////////////////////////////////////
@mixin media-frame() {
@include transition();
border-top: 2px solid transparent;
border-bottom: 2px solid transparent;
border-radius: $border-radius;
box-shadow: 0 1px 3px rgba($brand-grey, .2);
@media (min-width: $screen-sm) {
border: 2px solid transparent;
}
}