Ghost/ghost/admin/assets/sass/modules/mixins.scss

102 lines
2.9 KiB
SCSS
Raw Normal View History

// ------------------------------------------------------------
2014-10-26 20:07:35 +03:00
// Mixins
//
// Mixins defined here are very general and used in mul
//
// * baseline()
// * clearfix()
// * tab-focus()
// * triangle()
// * set-triangle-color()
// ------------------------------------------------------------
2014-10-26 20:07:35 +03:00
//
2014-10-26 20:07:35 +03:00
// Baseline margin
// --------------------------------------------------
@mixin baseline {
margin: 1.6em 0;
}
2014-10-26 20:07:35 +03:00
//
2014-10-26 20:07:35 +03:00
// Fix for clearing float-based overflows
// --------------------------------------------------
@mixin clearfix {
2014-10-26 20:07:35 +03:00
&:after {
content: "";
display: table;
clear: both;
}
}
//
// WebKit-style focus
2014-10-26 20:07:35 +03:00
// From Bootstrap
// --------------------------------------------------
@mixin tab-focus() {
2014-10-26 20:07:35 +03:00
// Default
outline: thin dotted;
// WebKit
outline: 0px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
2014-08-05 18:12:27 +04:00
//
2014-10-26 20:07:35 +03:00
// Simple SCSS mixin to create CSS triangles
// Example: @include css-triangle (10px, #fff, "up");
// --------------------------------------------------
2014-10-26 20:07:35 +03:00
@mixin triangle($size: 20px, $color: #000, $direction: "down", $type: "normal") {
2014-09-29 15:17:27 +04:00
$verticalSize: $size;
width: 0;
height: 0;
2014-09-29 15:17:27 +04:00
@if $type == "shallow" {
$verticalSize: floor($size * $popover_triangle_shallow_multiplier);
}
@if $direction == "down" {
border-left: $size solid #{set-triangle-color($direction, "left", $color)};
border-right: $size solid #{set-triangle-color($direction, "right", $color)};
border-top: $verticalSize solid #{set-triangle-color($direction, "top", $color)};
}
@if $direction == "up" {
border-left: $size solid #{set-triangle-color($direction, "left", $color)};
border-right: $size solid #{set-triangle-color($direction, "right", $color)};
border-bottom: $verticalSize solid #{set-triangle-color($direction, "bottom", $color)};
}
@if $direction == "left" {
border-right: $verticalSize solid #{set-triangle-color($direction, "right", $color)};
border-top: $size solid #{set-triangle-color($direction, "top", $color)};
border-bottom: $size solid #{set-triangle-color($direction, "bottom", $color)};
}
@if $direction == "right" {
border-left: $verticalSize solid #{set-triangle-color($direction, "left", $color)};
border-bottom: $size solid #{set-triangle-color($direction, "bottom", $color)};
border-top: $size solid #{set-triangle-color($direction, "top", $color)};
}
}
//
2014-10-26 20:07:35 +03:00
// Utility function to return the relevant colour depending on what type of arrow it is
// --------------------------------------------------
@function set-triangle-color($direction, $side, $color) {
@if $direction == "left" and $side == "right"
or $direction == "right" and $side == "left"
or $direction == "down" and $side == "top"
or $direction == "up" and $side == "bottom" {
@return $color
} @else {
@return "transparent";
}
}