Skip to content
Snippets Groups Projects
_functions.scss 1.15 KiB
Newer Older
  • Learn to ignore specific revisions
  • // Strip the unit from the given value and return the value
    @function strip-unit($value) {
        @return $value / ($value * 0 + 1);
    }
    
    // Return an em unit based on the pixel value and context
    @function rem($px, $context: $base-font-size) {
        @return #{strip-unit($px / strip-unit($context))}rem;
    }
    
    
    // Returns the opposite direction of each direction in a list
    // @param {List} $directions - List of initial directions
    // @return {List} - List of opposite directions
    @function opposite-direction($directions) {
        $opposite-directions: ();
        $direction-map: (
            'top':    'bottom',
            'right':  'left',
            'bottom': 'top',
            'left':   'right',
            'center': 'center',
            'ltr':    'rtl',
            'rtl':    'ltr'
        );
    
        @each $direction in $directions {
            $direction: to-lower-case($direction);
    
            @if map-has-key($direction-map, $direction) {
                $opposite-directions: append($opposite-directions, unquote(map-get($direction-map, $direction)));
    
                @warn 'No opposite direction can be found for `#{$direction}`. Direction omitted.';
            }
        }
        @return $opposite-directions;
    }