// /** // * Copyright (C) 2013 Crossing Hippos - Babs Gösgens. All rights reserved. // * Licensed under GNU General Public License version 2 or later; see LICENSE.txt // */ @if $trace-imports { @debug 'imported'; } // ========================================================================== // Function px-to-relative-font-size // -------------------------------------------------------------------------- // Placeholder function for font-sizes. // Inserts correct font unit as set in the Vertical-Rhythm module settings. // -------------------------------------------------------------------------- // @param (string) $target-px (value in px) // @param (string) $context (value in px) // @param (string) $unit (unit of output) // @return (string) value in alternate unit // ========================================================================== @function px-to-relative-font-size($target-px, $context: $base-font-size, $unit: $font-unit) { @return px-to-relative-size($target-px, $context, $unit); } // ========================================================================== // Function px-to-relative-line-height // -------------------------------------------------------------------------- // Placeholder function for line-heights. // inserts correct line-height unit as set in the Vertical-Rhythm module settings. // -------------------------------------------------------------------------- // @param (string) $target-px (value in px) // @param (string) $context (value in px) // @param (string) $unit (unit of output) // @return (string) value in alternate unit // ========================================================================== @function px-to-relative-line-height($target-px, $context: $base-font-size, $unit: $leading-unit) { @return px-to-relative-size($target-px, $context, $unit); } // ========================================================================== // Function extract-type-style // -------------------------------------------------------------------------- // Extract the style property from a type array // -------------------------------------------------------------------------- // @param (array) $type (a valid type array: $style, $variant, $weight, $family) // @return (string) font-style // ========================================================================== @function extract-type-style($type) { @return nth($type, 1); } // ========================================================================== // Function extract-type-variant // -------------------------------------------------------------------------- // Extract the variant property from a type array // -------------------------------------------------------------------------- // @param (array) $type (a valid type array: $style, $variant, $weight, $family) // @return (string) font-variant // ========================================================================== @function extract-type-variant($type) { @return nth($type, 2); } // ========================================================================== // Function extract-type-weight // -------------------------------------------------------------------------- // Extract the weight property from a type array // -------------------------------------------------------------------------- // @param (array) $type (a valid type array: $style, $variant, $weight, $family) // @return (string) font-weight // ========================================================================== @function extract-type-weight($type) // ========================================================================== { @return nth($type, 3); } // ========================================================================== // Function extract-type-family // -------------------------------------------------------------------------- // Extract the family property from a type array // -------------------------------------------------------------------------- // @param (array) $type (a valid type array: $style, $variant, $weight, $family) // @return (string) font-family // ========================================================================== @function extract-type-family($type) { @return nth($type, 4); } // ========================================================================== // Function weight-number-to-string // -------------------------------------------------------------------------- // Converts a weight number to a string and returns it // -------------------------------------------------------------------------- // @param (integer) $weight a valid weight number: 100 through 900) // @return (string) weight // ========================================================================== @function weight-number-to-string($weight) { @if $weight == 100 { @return "ultra-light"; } @if $weight == 200 { @return "light"; } @if $weight == 300 { @return "book"; } @if $weight == 400 { @return "regular"; } @if $weight == 500 { @return "medium"; } @if $weight == 600 { @return "semi-bold"; } @if $weight == 700 { @return "bold"; } @if $weight == 800 { @return "extra-bold"; } @if $weight == 900 { @return "heavy"; } @else { @warn "Not a valid weight"; @return false; } } //* To Do: (everything below needs to be looked over as settings in the Type modules have changed) // //* Calculate the optimal line-height */ // @function leading-in-px($base-font-size, $balance-over: false) { // $dividend: $base-font-size / $base-line-height; // $leading: $base-line-height; // // For smaller font-sizes, for instance balance a font-size of 8px over two baselines of 24px in three (balance) lines resulting in 48/3=16px; // @if $balance-over { // $leading: 2 * $base-line-height / $balance-over; // @return $leading; // } // @if $dividend<0.5 { // $leading: 0.5 * $base-line-height; // @return $leading; // } // @if $dividend>1 { // $leading: ceil($dividend) * $base-line-height; // @if ($leading - $base-font-size) < (2 * $min-line-padding) { // $leading: $leading + $base-line-height; // } // @return $leading; // } // @else { // @return $leading; // } // } // @function px-to-rhythm($value) { // @return $value/$base-line-height; // } // @function base-line-rhythm($base-lines: 1) { // // @debug $base-lines; // // @debug $base-line-height; // @return ($base-lines * $base-line-height); // }