From 9a7c6d2cf60744ae71f8114302b72c38c1e9465b Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:36:42 +0200 Subject: [PATCH 1/9] feat: select-style & target-anchor-offset able to set own content select-style no longer has default values --- mixins/_basic.scss | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mixins/_basic.scss b/mixins/_basic.scss index fe64b21..c484c02 100644 --- a/mixins/_basic.scss +++ b/mixins/_basic.scss @@ -2,13 +2,13 @@ @use '../functions/numbers' as numb; /// Styles for selected elements -/// @param {Color} $bg-color [$black] Background-color -/// @param {Color} $color [$white] Text-color +/// @param {Color} $bg-color Background-color +/// @param {Color} $color Text-color /// @param {String} $selector [*] Selector /// @group Basic /// @author Felix Scholze /// @since v1.0.0 -@mixin select-style($bg-color: #000, $color: #fff, $selector: '*') { +@mixin select-style($bg-color, $color, $selector: '*') { @if meta.type-of($bg-color) != color { @error '❌ ===> #{$bg-color} is not a color'; } @@ -19,6 +19,7 @@ &::selection { background: $bg-color; color: $color; + @content; } } } @@ -35,6 +36,7 @@ display: block; height: $offset; margin-top: number-invert($offset); + @content; } } } From d9b924b424c3f7e7753c70805f6c7c86759295b3 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:37:19 +0200 Subject: [PATCH 2/9] build: stylelint ignores .css files in test folder --- .stylelintignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .stylelintignore diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 0000000..f096ddb --- /dev/null +++ b/.stylelintignore @@ -0,0 +1 @@ +tests/**/*.css \ No newline at end of file From f28922d321a07fb9f8e477777598cf7d50ec1d75 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:38:06 +0200 Subject: [PATCH 3/9] style: typo in function name --- tests/px-to-rem.spec.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/px-to-rem.spec.scss b/tests/px-to-rem.spec.scss index ee7c8c0..51180f3 100644 --- a/tests/px-to-rem.spec.scss +++ b/tests/px-to-rem.spec.scss @@ -1,7 +1,7 @@ @use 'true'; @use '../functions' as fn; -@include true.describe('px-to-ren()') { +@include true.describe('px-to-rem()') { @include true.it('should return the value in rem') { @include true.assert-equal( fn.px-to-rem(16), 1rem From f487f843fd5c9c6a5bda366a832681e64801aaae Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:38:40 +0200 Subject: [PATCH 4/9] test(breakpoint): add test in px --- tests/breakpoint.spec.scss | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/breakpoint.spec.scss b/tests/breakpoint.spec.scss index f0edb83..c118753 100644 --- a/tests/breakpoint.spec.scss +++ b/tests/breakpoint.spec.scss @@ -1,6 +1,18 @@ @use 'true'; @use '../mixins' as mx; +// Breakpoint Map +$breakpoints-px: ( + 'xxs': 375px, + 'xs': 568px, + 'sm': 768px, + 'md': 1024px, + 'lg': 1260px, + 'xlg': 1440px, + 'fhd': 1920px, + 'uhd': 2560px, +) !default; + @include true.describe('breakpoint()') { @include true.it('should return a css media query in min-width') { @include true.assert { @@ -20,6 +32,7 @@ } } } + @include true.it('should return a css media query in max-width') { @include true.assert { @include true.output { @@ -38,4 +51,23 @@ } } } + + @include true.it('should return a css media query in max-width using own breakpoint map in px') { + @include true.assert { + @include true.output { + @include mx.breakpoint('md', 'max', $breakpoints-px) { + .test { + padding: 12px; + } + } + } + @include true.expect { + @media (max-width: 1023px) { + .test { + padding: 12px; + } + } + } + } + } } From 5d5234cf9bd0ebb2e10be4316c5a8be0fcc5142a Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:42:26 +0200 Subject: [PATCH 5/9] test(select-style): add test --- tests/select-style.spec.scss | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/select-style.spec.scss diff --git a/tests/select-style.spec.scss b/tests/select-style.spec.scss new file mode 100644 index 0000000..ca1fa4a --- /dev/null +++ b/tests/select-style.spec.scss @@ -0,0 +1,18 @@ +@use 'true'; +@use '../mixins' as mx; + +@include true.describe('select-style()') { + @include true.it('should return a select style for specified selector') { + @include true.assert { + @include true.output { + @include mx.select-style(red, blue); + } + @include true.expect { + *::selection { + background: red; + color: blue; + } + } + } + } +} From 66f2da080b922bcfeaaf925234db4f3a25920490 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 13:55:11 +0200 Subject: [PATCH 6/9] ci: run release workflow only when unit tests successed --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f2f36a..a60de76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,11 @@ name: Release on: - push: + workflow_run: + workflows: [Unit tests] + types: [completed] branches: - master + jobs: release: name: Release From c9c30868e93cf70efd260103ab32db7819f1ad28 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 14:19:06 +0200 Subject: [PATCH 7/9] fix: target-anchor-offset no namespace for invert func --- mixins/_basic.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixins/_basic.scss b/mixins/_basic.scss index c484c02..afad0d2 100644 --- a/mixins/_basic.scss +++ b/mixins/_basic.scss @@ -35,7 +35,7 @@ content: ''; display: block; height: $offset; - margin-top: number-invert($offset); + margin-top: numb.number-invert($offset); @content; } } From 7002e1ef90998eab357e46d6426d9fa84e8e4967 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 14:19:55 +0200 Subject: [PATCH 8/9] ci(target-anchor-offset): add test --- tests/target-anchor-offset.spec.scss | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/target-anchor-offset.spec.scss diff --git a/tests/target-anchor-offset.spec.scss b/tests/target-anchor-offset.spec.scss new file mode 100644 index 0000000..4f83670 --- /dev/null +++ b/tests/target-anchor-offset.spec.scss @@ -0,0 +1,22 @@ +@use 'true'; +@use '../mixins' as mx; + +@include true.describe('target-anchor-offset()') { + @include true.it('should return a offset for target anchor') { + @include true.assert { + @include true.output { + @include mx.target-anchor-offset(150px); + } + @include true.expect { + :target { + &::before { + content: ''; + display: block; + height: 150px; + margin-top: -150px; + } + } + } + } + } +} From d3d5321d915a3ada678b1e0d2e27ba8303a6e433 Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Sun, 7 Aug 2022 17:15:49 +0200 Subject: [PATCH 9/9] test(strip-unit): add test --- tests/strip-unit.spec.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/strip-unit.spec.scss diff --git a/tests/strip-unit.spec.scss b/tests/strip-unit.spec.scss new file mode 100644 index 0000000..2748dae --- /dev/null +++ b/tests/strip-unit.spec.scss @@ -0,0 +1,10 @@ +@use 'true'; +@use '../functions' as fn; + +@include true.describe('strip-unit()') { + @include true.it('should return the value without unit') { + @include true.assert-equal( + fn.strip-unit(33rem), 33, + ); + } +}