podcast.netzbegruenung.de/themes/zen/zen_tmp/assets/lib/typey/stylesheets/typey/functions/_outputters.scss
Marian Steinbach eda64f71d8 Initial version
2020-01-18 00:32:07 +01:00

84 lines
2.7 KiB
SCSS

// Take a px value and output converted value.
//
// @param number $number
// A px value to convert.
// @param number|string $context
// (optional) Only used if em is the $base-unit. The value of the elements/parents
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
// value in px.
//
// @return number
// The number converted to the base unit.
@function output-from-px($number, $context: $base-font-size) {
@if $base-unit == rem {
@return typey-output-in-base-unit(($number / $base-font-size));
}
@if $base-unit == px {
@return typey-output-in-base-unit(typey-strip-unit($number));
}
@if $base-unit == em {
@return calculate-em-px($number, $context);
}
}
// Take a key from the $font-size map and output converted value.
//
// @param string $size
// A size from the $font-size map.
// @param number|string $context
// (optional) Only used if em is the $base-unit. The value of the parent
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
// value in px.
//
// @return number
// The selected font-size in $base-unit.
@function output-from-font-size-map($size, $context: $base-font-size) {
$map-size: map-get($font-size, $size);
@if $base-unit == rem {
@return typey-output-in-base-unit(($map-size / $base-font-size));
}
@if $base-unit == px {
@return typey-output-in-base-unit(typey-strip-unit($map-size));
}
@if $base-unit == em {
@return calculate-em-px($map-size, $context);
}
}
// Take a line-height multipler and output converted value.
//
// @param number $number
// Multiple of line height to be used.
// @param number|string $context
// (optional) Only used if em is the $base-unit. The value of the elements/parents
// font-size if it differs from $base-font-size. Specified as a t-shirt size or
// value in px.
//
// @return number
// The value of the line-height multiple converted to the base unit.
@function output-from-multiplier($x, $context: $base-font-size) {
@if $base-unit == rem {
@return typey-output-in-base-unit(($x * $base-line-height) / $base-font-size);
}
@if $base-unit == px {
@return typey-output-in-base-unit(typey-strip-unit($x * $base-line-height));
}
@if $base-unit == em {
@return calculate-em-multiplier($x, $context);
}
}
// Take a line-height ratio and output as em.
//
// @param number $ratio
// Multiple of the $font-size to be used.
// @param number|string $context
// (optional) used to ensure function outputs the ratio regardless of whether
// it is the same as the $base-line-height-ratio.
//
// @return number
// The ratio in em.
@function output-from-ratio($ratio: $base-line-height-ratio) {
@return $ratio;
}