From d67133916942883ab32a9d7c21c28e3d0f81798a Mon Sep 17 00:00:00 2001 From: Bram Smulders Date: Wed, 10 Nov 2021 15:35:30 +0100 Subject: [PATCH 1/3] convert `px` values for breakpoints to `em` values --- tools/_internal/_functions.scss | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/_internal/_functions.scss b/tools/_internal/_functions.scss index 970b38b..96600cc 100644 --- a/tools/_internal/_functions.scss +++ b/tools/_internal/_functions.scss @@ -109,17 +109,17 @@ $parsed-value: validate-query($value); @if $parsed-value { - @if math.unit($parsed-value) == 'em' { - $min-w: $parsed-value; - } @else { + $resolved-value: $parsed-value; + + @if math.unit($parsed-value) != 'em' { @if $key == max-width or $key == max-height { $parsed-value: $parsed-value - 1px; } - $min-w: value-to-em($parsed-value); + $resolved-value: value-to-em($parsed-value); } - $return: map.merge($return, ($key: $parsed-value)); + $return: map.merge($return, ($key: $resolved-value)); } @return $return; From bebbfb0090fd80018994706367aba93b7cf687cb Mon Sep 17 00:00:00 2001 From: Bram Smulders Date: Wed, 10 Nov 2021 15:50:28 +0100 Subject: [PATCH 2/3] check for correct breakpoint unit usage in defaults --- settings/defaults/_index.scss | 15 ++++++++++++++- tools/_internal/_functions.scss | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/settings/defaults/_index.scss b/settings/defaults/_index.scss index 468129f..ef3c32e 100644 --- a/settings/defaults/_index.scss +++ b/settings/defaults/_index.scss @@ -115,7 +115,20 @@ $should-be-pixel-values: ( @each $key, $value in $should-be-pixel-values { @if type-of($value) == number { @if math.unit($value) != 'px' { - @error '`#{$key}: #{$value}` needs to be a pixel value.'; + @error '`#{$key}: #{$value}` needs to be a pixel unit.'; + } + } @else { + @error '`#{$key}: #{$value}` needs to be a number.'; + } +} + +/** + * check that breakpoints are defined in px or em + */ +@each $key, $value in $breakpoints { + @if type-of($value) == number { + @if math.unit($value) != 'px' and math.unit($value) != 'em' { + @error 'Breakpoint `#{$key}: #{$value}` needs to be a pixel or em unit.'; } } @else { @error '`#{$key}: #{$value}` needs to be a number.'; diff --git a/tools/_internal/_functions.scss b/tools/_internal/_functions.scss index 96600cc..9d9f05f 100644 --- a/tools/_internal/_functions.scss +++ b/tools/_internal/_functions.scss @@ -111,7 +111,7 @@ @if $parsed-value { $resolved-value: $parsed-value; - @if math.unit($parsed-value) != 'em' { + @if math.unit($parsed-value) == 'px' { @if $key == max-width or $key == max-height { $parsed-value: $parsed-value - 1px; } From 2685b19fda35189c76e6871bfc6c23a8115d3013 Mon Sep 17 00:00:00 2001 From: Bram Smulders Date: Wed, 10 Nov 2021 16:20:18 +0100 Subject: [PATCH 3/3] bump version --- CHANGELOG.md | 4 ++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1452529..3f027cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 5.3.0 - 10-november-2021 + +- Fixed a bug where `px` based media queries were not converted to `em` + ## 5.2.0 - 03-november-2021 - Upgraded stylelint-config-supple to version 4 diff --git a/package-lock.json b/package-lock.json index 524b5e7..d35a5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@supple-kit/supple-css", - "version": "5.2.0", + "version": "5.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c8a4081..24cac0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@supple-kit/supple-css", - "version": "5.2.0", + "version": "5.3.0", "description": "Reliable and testable Sass framework. Fluid, Variable, supple if you will", "main": "index.scss", "repository": "https://github.com/supple-kit/supple-css.git",