Ghost theme (MIT license)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.3 KiB

10 years ago
// Foundation by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source
// This is the default html and body font-size for the base rem value.
$rem-base: 16px !default;
// IMPORT ONCE
10 years ago
// We use this to prevent styles from being loaded multiple times for components that rely on other components.
10 years ago
$modules: () !default;
@mixin exports($name) {
10 years ago
// Import from global scope
$modules: $modules !global;
// Check if a module is already on the list
$module_index: index($modules, $name);
@if (($module_index == null) or ($module_index == false)) {
10 years ago
$modules: append($modules, $name) !global;
10 years ago
@content;
}
}
//
// @functions
//
// RANGES
10 years ago
// We use these functions to define ranges for various things, like media queries.
10 years ago
@function lower-bound($range){
@if length($range) <= 0 {
@return 0;
}
@return nth($range,1);
}
@function upper-bound($range) {
@if length($range) < 2 {
@return 999999999999;
}
@return nth($range, 2);
}
// STRIP UNIT
// It strips the unit of measure and returns it
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
10 years ago
// TEXT INPUT TYPES
@function text-inputs( $types: all, $selector: input ) {
$return: ();
$all-text-input-types:
text
password
date
datetime
datetime-local
month
week
email
number
search
tel
time
url
color
textarea;
@if $types == all { $types: $all-text-input-types; }
@each $type in $types {
@if $type == textarea {
@if $selector == input {
$return: append($return, unquote('#{$type}'), comma)
} @else {
$return: append($return, unquote('#{$type}#{$selector}'), comma)
}
} @else {
$return: append($return, unquote('#{$selector}[type="#{$type}"]'), comma)
}
}
@return $return;
}
10 years ago
// CONVERT TO REM
@function convert-to-rem($value, $base-value: $rem-base) {
$value: strip-unit($value) / strip-unit($base-value) * 1rem;
@if ($value == 0rem) { $value: 0; } // Turn 0rem into 0
@return $value;
}
@function data($attr) {
@if $namespace {
@return '[data-' + $namespace + '-' + $attr + ']';
}
@return '[data-' + $attr + ']';
}
10 years ago
// REM CALC
10 years ago
// New Syntax, allows to optionally calculate on a different base value to counter compounding effect of rem's.
// Call with 1, 2, 3 or 4 parameters, 'px' is not required but supported:
10 years ago
//
10 years ago
// rem-calc(10 20 30px 40);
10 years ago
//
10 years ago
// Space delimited, if you want to delimit using comma's, wrap it in another pair of brackets
10 years ago
//
10 years ago
// rem-calc((10, 20, 30, 40px));
10 years ago
//
10 years ago
// Optionally call with a different base (eg: 8px) to calculate rem.
10 years ago
//
10 years ago
// rem-calc(16px 32px 48px, 8px);
10 years ago
//
10 years ago
// If you require to comma separate your list
10 years ago
//
10 years ago
// rem-calc((16px, 32px, 48), 8px);
@function rem-calc($values, $base-value: $rem-base) {
$max: length($values);
@if $max == 1 { @return convert-to-rem(nth($values, 1), $base-value); }
$remValues: ();
@for $i from 1 through $max {
$remValues: append($remValues, convert-to-rem(nth($values, $i), $base-value));
}
@return $remValues;
}
// OLD EM CALC
// Deprecated: We'll drop support for this in 5.1.0, use rem-calc()
@function emCalc($values){
@return rem-calc($values);
}
// OLD EM CALC
// Deprecated: We'll drop support for this in 5.1.0, use rem-calc()
@function em-calc($values){
@return rem-calc($values);
}