1.0.4 • Published 12 months ago

vw-calc v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

License: MIT

vw-calc()

vw-calc() is a Sass function that scales pixel-based value(s) proportionally and accessible.

Getting Started

Follow these steps to setup your project.

Installation

  1. Install the package

    npm install --save-dev vw-calc

Parameters

  vw-calc(
    $values,
    $wide-width,
    $narrow-width,
    $narrow,
    $clamp,
    $dynamic,
    $base-font-size
  )
NameTypeDefaultDescription
$valuesnumber - ($min-value, $max-value, $limit-value)One parameter required. Up to 3 (three) parameters allowed
$wide-widthnumber1440Unitless pixel-based value for wide screens
$narrow-widthnumber375Unitless pixel-based value for narrow screens
$narrowbooleanfalseIf enabled $values MUST have 1 (one) parameter, which will be treated as the $max-value, then it will set $min-value to 0. This helpful when the scaling will happen on narrow screens.
$clampbooleanfalseEnable to avoid the returned value to scale beyond $wide-width
$dynamicbooleanfalseIf enabled $values MUST have 1 (one) parameter, which will be treated as the $max-value, then it will apply a mathematical rule of three to calculate $min-value
$base-font-sizenumber16Default base font size for most browsers

Usage

  1. Import the function with Sass @use rule

    @use 'vw-calc';

    OR with an alias:

    @use 'vw-calc' as vw;
  2. Change the default values as needed prepending $default- to the parameter name, e.g:

     @use 'vw-calc' as vw with (
       $default-wide-width: 1200,
       $default-narrow-width: 425
     );

    OR

  3. Passing the values directly in the Sass function, e.g:

     vw-calc(16 32, wide-width: 1200, narrow-width: 425);
1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago