compilation du nouveau css
This commit is contained in:
parent
063f84f1ad
commit
75a822112f
20 changed files with 2804 additions and 0 deletions
52
src/scss/function/_calc-font-size.scss
Normal file
52
src/scss/function/_calc-font-size.scss
Normal file
|
@ -0,0 +1,52 @@
|
|||
@charset "utf-8";
|
||||
|
||||
// Built-In Modules
|
||||
@use 'sass:math';
|
||||
|
||||
// Included Modules
|
||||
@use 'strip-unit';
|
||||
|
||||
// ===================================================================
|
||||
// px to em
|
||||
// ===================================================================
|
||||
|
||||
@function px2em($px, $base: 16) {
|
||||
@return math.div(strip-unit.strip-unit($px), strip-unit.strip-unit($base)) * 1em;
|
||||
}
|
||||
|
||||
@function px2rem($px, $base: 16) {
|
||||
@return math.div(strip-unit.strip-unit($px), strip-unit.strip-unit($base)) * 1rem;
|
||||
}
|
||||
// ===================================================================
|
||||
// percent to px
|
||||
// ========================================================n===========
|
||||
|
||||
@function percent2px($percent, $base: 16) {
|
||||
@return strip-unit.strip-unit($base) * math.div(strip-unit.strip-unit($percent), 100) * 1px;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// percent to em
|
||||
// ===================================================================
|
||||
|
||||
@function percent2em($percent, $base: 16) {
|
||||
$ratio: math.div((strip-unit.strip-unit($percent), 100));
|
||||
@return math.div(strip-unit.strip-unit($base) * $ratio, strip-unit.strip-unit($base)) * 1em;
|
||||
}
|
||||
|
||||
@function percent2rem($percent, $base: 16) {
|
||||
$ratio: math.div((strip-unit.strip-unit($percent), 100));
|
||||
@return math.div((strip-unit.strip-unit($base) * $ratio), strip-unit.strip-unit($base)) * 1rem;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// em to px
|
||||
// ===================================================================
|
||||
|
||||
@function em2px($em, $base: 16) {
|
||||
@return strip-unit.strip-unit($em) * strip-unit.strip-unit($base) * 1px;
|
||||
}
|
||||
|
||||
@function rem2px($rem, $base: 16) {
|
||||
@return strip-unit.strip-unit($rem) * strip-unit.strip-unit($base) * 1px;
|
||||
}
|
40
src/scss/function/_calc-stack.scss
Normal file
40
src/scss/function/_calc-stack.scss
Normal file
|
@ -0,0 +1,40 @@
|
|||
@charset "utf-8";
|
||||
|
||||
// Built-In Modules
|
||||
@use 'sass:math';
|
||||
|
||||
// Included Modules
|
||||
@use 'calc-font-size';
|
||||
@use 'strip-unit';
|
||||
|
||||
@function stack($line-height: 1, $font-size: 16px, $base-size: 16px) {
|
||||
@if math.unit($font-size) == '%' {
|
||||
$font-size: calc-font-size.percent2px($font-size, $base-size);
|
||||
} @else if math.unit($font-size) == 'em' {
|
||||
$font-size: calc-font-size.em2px($font-size, $base-size);
|
||||
} @else if math.unit($font-size) == 'rem' {
|
||||
$font-size: calc-font-size.rem2px($font-size, $base-size);
|
||||
}
|
||||
|
||||
$line-height-px-unit: strip-unit.strip-unit($line-height) * strip-unit.strip-unit($font-size);
|
||||
|
||||
$stack: calc-font-size.px2rem($line-height-px-unit, $base-size);
|
||||
|
||||
@return $stack;
|
||||
}
|
||||
|
||||
@function line-height($line-space: 4px, $font-size: 16px, $base-size: 16px) {
|
||||
@if math.unit($font-size) == '%' {
|
||||
$font-size: calc-font-size.percent2px($font-size, $base-size);
|
||||
} @else if math.unit($font-size) == 'em' {
|
||||
$font-size: calc-font-size.em2px($font-size, $base-size);
|
||||
} @else if math.unit($font-size) == 'rem' {
|
||||
$font-size: calc-font-size.rem2px($font-size, $base-size);
|
||||
}
|
||||
|
||||
$font-size: strip-unit.strip-unit($font-size);
|
||||
$line-space: strip-unit.strip-unit($line-space);
|
||||
$line-height: math.div(($line-space * 2) + $font-size, $font-size);
|
||||
|
||||
@return $line-height;
|
||||
}
|
26
src/scss/function/_contrast-color.scss
Normal file
26
src/scss/function/_contrast-color.scss
Normal file
|
@ -0,0 +1,26 @@
|
|||
@charset "utf-8";
|
||||
|
||||
// Built-In Modules
|
||||
@use 'sass:math';
|
||||
@use 'sass:color';
|
||||
|
||||
// ===================================================================
|
||||
// contrast color
|
||||
// ===================================================================
|
||||
|
||||
@function contrast-color($color: null, $dark: #000, $light: #fff) {
|
||||
@if $color == null {
|
||||
@return null;
|
||||
}
|
||||
@else {
|
||||
$color-brightness: brightness($color);
|
||||
$light-color-brightness: brightness($light);
|
||||
$dark-color-brightness: brightness($dark);
|
||||
|
||||
@return if(math.abs($color-brightness - $light-color-brightness) > math.abs($color-brightness - $dark-color-brightness), $light, $dark);
|
||||
}
|
||||
}
|
||||
|
||||
@function brightness($color: null) {
|
||||
@return math.div((color.red($color) * 299) + (color.green($color) * 587) + (color.blue($color) * 114), 1000);
|
||||
}
|
17
src/scss/function/_strip-unit.scss
Normal file
17
src/scss/function/_strip-unit.scss
Normal file
|
@ -0,0 +1,17 @@
|
|||
@charset "utf-8";
|
||||
|
||||
// Built-In Modules
|
||||
@use 'sass:meta';
|
||||
@use 'sass:math';
|
||||
|
||||
@function strip-unit($value) {
|
||||
@if meta.type-of($value) == 'number' and math.is-unitless($value) == false {
|
||||
@return math.div($value, $value * 0 + 1);
|
||||
} @else if meta.type-of($value) == 'number' {
|
||||
@return $value;
|
||||
} @else {
|
||||
@warn $value;
|
||||
@warn meta.type-of($value);
|
||||
@error "error strip unit"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue