// @category styleguide // helper function to get the height of a button // @function _styleguideGetButtonHeight // @private // @param $size {String} the size of the button to calculate // @return {Number} the height of the button @function _styleguideGetButtonHeight($size: medium) { @if type-of($size) != list { $sizes: ( (small, $CONFIG_FONT_BUTTON_SMALL), (medium, $CONFIG_FONT_BUTTON_MEDIUM), (large, $CONFIG_FONT_BUTTON_LARGE) ); $size: associative($sizes, $size); } // font size + top/bottom padding @return nth($size, 1) + (2 * nth($size, 2)); } // helper function to get the padding of a button // @function _styleguideGetButtonPadding // @private // @param $size {String} the size of the button to calculate // @param $narrow {Boolean} is the button narrow or not // @return {Number} the padding on the button @function _styleguideGetButtonPadding($size: medium, $narrow: false) { @if type-of($size) != list { $sizes: ( (small, $CONFIG_FONT_BUTTON_SMALL), (medium, $CONFIG_FONT_BUTTON_MEDIUM), (large, $CONFIG_FONT_BUTTON_LARGE) ); $size: nth(associative($sizes, $size), 3); } $size: floor(if($narrow, $size * 0.75, $size)); @return (0 $size); } // helper function to get the size of the caret // @function _styleguideCaretSize // @private // @param $size {String} the size of the caret to calculate // @param $direction {String} the direction the caret is facing [up|down] // @return {List} the border widths needed to generate the caret @function _styleguideCaretSize($size: medium, $direction: south) { @if type-of($size) != number { $size: associative(( (small $CONFIG_FONT_CARET_SMALL), (medium $CONFIG_FONT_CARET_MEDIUM), (large $CONFIG_FONT_CARET_LARGE), (tooltip $CONFIG_DIM_TOOLTIP_TIP) ), $size); } @return associative(( (default ($size $size 0)), (north (0 $size $size)), (east ($size 0 $size $size)), (west ($size $size $size 0)) ), $direction); } // helper function to get the alert icon offset // @function _styleguideGetAlertGlyphOffset // @private // @param $type {List} the glyph data // @return {List} the top and left offsets for the glyph @function _styleguideGetAlertGlyphOffset($type: $CONFIG_GLYPH_ALERT_NOTIFY) { $top: (nth-cyclic($CONFIG_DIM_ALERTS_SPACING, 1) + nth-cyclic($CONFIG_DIM_ALERTS_SPACING, 3) + nth-cyclic($CONFIG_FONT_NOTICE, 2) - nth($type, 4)) / 2; $left: ((nth-cyclic($CONFIG_DIM_ALERTS_SPACING, 4) - nth($type, 4))/2); @return ($top $left); } // helper function to extract the glyph styles for an alert icon // @function _styleguideGetAlertGlyph // @private // @param $type {List} the glyph data // @return {List} the parameters needed for glyph-icon() @function _styleguideGetAlertGlyph($type: $CONFIG_GLYPH_ALERT_NOTIFY) { @return (nth($type, 1), nth($type, 2), nth($type, 3), before, ''); } // helper function to return the list of shadows for the alert // alerts have two shadows, one thats shared and ones that unique // @function _styleguideGetAlertShadow // @private // @param $type {String} the type of alert [success|notice|yield|error] // @return {List} the shadows on the alert @function _styleguideGetAlertShadow($type: notice) { $color: $type; @if type-of($type) == string { $color: associative(( (notice $CONFIG_COLOR_BORDER_ALERT_NOTIFY), (success $CONFIG_COLOR_BORDER_ALERT_SUCCESS), (error $CONFIG_COLOR_BORDER_ALERT_ERROR), (yield $CONFIG_COLOR_BORDER_ALERT_YIELD) ), $type); } @if not is-null($color) and not is-null($CONFIG_DIM_GENERIC_BORDER) { @return ((0 0 0 $CONFIG_DIM_GENERIC_BORDER $color), $CONFIG_SHADOW_ALERT); } @else { @return $CONFIG_SHADOW_ALERT; } } // helper function to get the color of a context // @function _styleguideGetContextColor // @private // @param $texture {List|String} a list or string for a background texture // @return {Color} the color in the list @function _styleguideGetContextColor($texture: $CONFIG_TEXTURE_CONTAINER) { $texture: -archetype-list(first-value-of($texture)); // cast a string into a list @return first-value-of($texture); // pull off the first value in the string/list } // helper function to get background position for the tooltip sprite // @function _styleguideGetTooltipTipBG // @private // @param $direction {String} the direction the tip is pointing [north|south|east|west] // @param $type {String} the type of the tip [hovercard] // @return {List} the background position offsets @function _styleguideGetTooltipTipBG($direction: south, $type: hovercard) { $dim: $type; @if type-of($type) == string { $dim: map-get(( hovercard: $CONFIG_DIM_HOVERCARD_TIP ), $type); } $a: nth($dim, 1); $b: nth-cyclic($dim, 2); @return map-get(( north: (-$b 0), south: ((-$b) (-($a+$b))), east: ((-($a+$b)) (-$b)), west: (0 (-$b)) ), $direction); } // helper function to get the position of the loading spinner // @function _styleguideGetLoaderPosition // @private // @param $size {String} the size of the loading spinner e.g. [small|medium|large] // @param $type {String} the type of the loading spinner e.g. [static|dynamic] // @param $context {Number} the index for the context type // @return {List} background position of the image or null @function _styleguideGetLoaderPosition($size: medium, $type: static, $context: 1) { $img: nth-cyclic(map-get(map-get($CONFIG_LOADERS, $size), $type), $context); @return -archetype-sprite-position($CONFIG_SPRITE_LOADERS, $img); } // helper function to get the dimensions of the loading spinner // @function _styleguideGetLoaderDimension // @private // @param $size {String} the size of the loading spinner e.g. [small|medium|large] // @param $type {String} the type of the loading spinner e.g. [static|dynamic] // @param $dim {String} the dimension to return [width|height] // @param $context {Number} the index for the context type // @param $divisor {Number} an optional value to divide the dimension by // @return {Number} the width/height of the loading spinner @function _styleguideGetLoaderDimension($size: medium, $type: static, $dim: width, $context: 1, $divisor: 1) { $context: if(is-null($context), 1, $context); $img: nth-cyclic(map-get(map-get($CONFIG_LOADERS, $size), $type), $context); $sprite-file: -archetype-sprite-file($CONFIG_SPRITE_LOADERS, $img); $dim: if($dim == width, -archetype-image-width($sprite-file), -archetype-image-height($sprite-file)); @return if(is-null($dim), $dim, $dim / ($divisor * units($dim))); } // helper function to get the animation routine of the loading spinner // @function _styleguideGetLoaderAnimation // @private // @param $size {String} the size of the loading spinner e.g. [small|medium|large] // @param $context {Number} the index for the context type // @return {String} the animation value @function _styleguideGetLoaderAnimation($size: medium, $context: 1) { $values: map-get($CONFIG_LOADERS, $size); $anim: (archetype-namespace($CONFIG_KEYFRAME_LOADERS)); $duration: nth-cyclic(map-get($values, duration), $context); $delay: nth-cyclic(map-get($values, delay), $context); $steps: nth-cyclic(map-get($values, steps), $context); $iterations: nth-cyclic(map-get($values, iterations), $context); @if not is-null($duration) { $anim: append($anim, $duration); } @if not is-null($delay) { $anim: append($anim, $delay); } @if not is-null($steps) { $anim: append($anim, steps($steps, end)); } @if not is-null($iterations) { $anim: append($anim, $iterations); } $position-keyframe-name: #{archetype-namespace($CONFIG_KEYFRAME_LOADERS)}-position-#{$size}-#{$context}; $anim: unquote("#{$anim}, #{$position-keyframe-name} 0.1ms step-end infinite"); @return $anim; } // helper function to get the CSS expression of the loading spinner (for IE6/7 support) // @function _styleguideGetLoaderExpression // @private // @param $size {String} the size of the loading spinner e.g. [small|medium|large] // @param $context {Number} the index for the context type // @return {String} the CSS expression styles @function _styleguideGetLoaderExpression($size: medium, $context: 1) { $img: nth-cyclic(map-get(map-get($CONFIG_LOADERS, $size), static), $context); $bg: -archetype-sprite($CONFIG_SPRITE_LOADERS, $img); @if is-null($bg) { $bg: $bg no-repeat; $width: _styleguideGetLoaderDimension($size, static, width, $context) or 0; $height: _styleguideGetLoaderDimension($size, static, height, $context) or 0; $margin-top: $height or / -2; $margin-left: $width / -2; @return ("position:absolute;top:50%;left:50%;background:#{$bg};width:#{$width};height:#{$height};margin-left:#{$margin-left};margin-top:#{$margin-top};", false, loader); } @return ""; }