Skip to content

Commit

Permalink
version 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tedw committed Jun 16, 2023
1 parent 4f50867 commit 9bb80f2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
57 changes: 56 additions & 1 deletion dist/_frontline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// _______ ____ _ __________ _____ ______
// / __/ _ \/ __ \/ |/ /_ __/ / / _/ |/ / __/
// / _// , _/ /_/ / / / / / /___/ // / _/
// /_/ /_/|_|\____/_/|_/ /_/ /____/___/_/|_/___/ v4.0.0
// /_/ /_/|_|\____/_/|_/ /_/ /____/___/_/|_/___/ v4.1.0
//
// This project is licensed under the terms of the MIT license


@use "sass:map";
@use 'sass:math';

//------------------------------------------------------------------------//
Expand Down Expand Up @@ -495,6 +496,60 @@ $fs-zindex: (
}
}

/// Generate clamp() to smoothly scale a value between two breakpoints
/// @group Main
/// @param {Map} $map - Map of breakpoints and values
/// @param {String} $units [vw] - Optionally specify container query units
/// @return {String} - Custom `clamp()` formula
/// @require {function} fs-rem
/// @link https://chrisburnell.com/clamp-calculator/
///
/// @example scss
/// p {
/// font-size: scale-clamp((375px: 16px, 960px: 20px));
/// }
///
@function fs-scale-clamp($map, $units: vw) {
// Formulas from link above:
//
// Change = (sizeMax - sizeMin) / (viewportMax - viewportMin);
// A = sizeMax - viewportMax * Change;
// B = 100vw * Change;
// Result = clamp(sizeMin, A + B, sizeMax);
//
$breakpoints: map.keys($map);
$values: map.values($map);
$min-width: nth($breakpoints, 1);
$max-width: nth($breakpoints, 2);
$start: nth($values, 1);
$end: nth($values, 2);
$change: math.div($end - $start, $max-width - $min-width);
$a: $end - ($max-width * $change);

// Add support for container query units
// https://caniuse.com/css-container-query-units
$width: 100vw;
@if $units == 'cqw' {
$width: 100cqw;
} @else if $units == 'cqh' {
$width: 100cqh;
} @else if $units == 'cqi' {
$width: 100cqi;
} @else if $units == 'cqb' {
$width: 100cqb;
}

$b: $width * $change;

// Round to 3 decimal places
// Note: Additional decimal places won’t have any effect on the computed
// value and makes it harder to read in the dev tools.
$a: math.div(math.round($a * 1000), 1000);
$b: math.div(math.round($b * 1000), 1000);

@return clamp(#{fs-rem($start)}, #{fs-rem($a)} + #{$b}, #{fs-rem($end)});
}

/// Slices `$list` between `$start` and `$end`.
/// @group Sass Utils
/// @author Hugo Giraudel
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "frontline-sass",
"name": "frontline-sass",
"version": "4.0.0",
"version": "4.1.0",
"description": "Threespot's base Sass framework",
"repository": {
"type": "git",
Expand Down

0 comments on commit 9bb80f2

Please sign in to comment.