Skip to content

Commit

Permalink
refactor(sass): version migration (#1011)
Browse files Browse the repository at this point in the history
* refactor: using internal color functions

* refactor: using internal string function

* refactor: using internal map.merge function

* refactor: using internal map.get function

* refactor: using internal string.unquote function

* refactor: use the internal map.get function

* refactor: running prettier
  • Loading branch information
mfranzke authored Nov 18, 2024
1 parent 89ea629 commit bc5c4b9
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
11 changes: 7 additions & 4 deletions source/_patterns/00-base/_helpers.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:color";
@mixin rgba2hex(
$cssProperty,
$hexValue,
Expand All @@ -6,10 +7,12 @@
$rgbBackground: #fdfdfd
) {
#{$cssProperty}: rgb(
(1 - $alphaValue) * red($rgbBackground) + $alphaValue * red($hexValue),
(1 - $alphaValue) * green($rgbBackground) + $alphaValue *
green($hexValue),
(1 - $alphaValue) * blue($rgbBackground) + $alphaValue * blue($hexValue)
(1 - $alphaValue) * color.red($rgbBackground) + $alphaValue *
color.red($hexValue),
(1 - $alphaValue) * color.green($rgbBackground) + $alphaValue *
color.green($hexValue),
(1 - $alphaValue) * color.blue($rgbBackground) + $alphaValue *
color.blue($hexValue)
);
}

Expand Down
3 changes: 2 additions & 1 deletion source/_patterns/00-base/_init.global.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:color";
// *! this is an opionionated (especially based on "enhancing" normalize.css) version of minireset.css v0.0.4 | MIT License | github.com/jgthms/minireset.css
html,
body {
Expand Down Expand Up @@ -61,7 +62,7 @@ a {

code {
background-color: #f5f5f5;
color: darken($db-color-red, 2%);
color: color.adjust($db-color-red, $lightness: -2%);
font-size: 0.875em;
font-weight: normal;
padding: 0.25em 0.5em;
Expand Down
3 changes: 2 additions & 1 deletion source/_patterns/00-base/icons/_icons.font-faces.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:string";
@import "../../../css/db-ui-core.variables";

@import "icons.variables";
Expand Down Expand Up @@ -32,7 +33,7 @@
url("#{$icons-path}functional/fonts/#{$icon-font-family+ "-" + $icon-category}.woff?4r2098")
format("woff");

unicode-range: unquote($icon-font-unicodes);
unicode-range: string.unquote($icon-font-unicodes);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion source/_patterns/00-base/icons/_icons.helpers.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:map";
// Icon SCSS mixin
@mixin icon(
$glyph: "",
Expand Down Expand Up @@ -99,7 +100,7 @@

// Icon glyph mixin
@function glyph($glyph) {
@return map-get($icon-glyphs, $glyph);
@return map.get($icon-glyphs, $glyph);
}

// Icon meta data mixin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:map";
@import "../../../../css/helpers/functions";
@import "../icons.variables";

Expand Down Expand Up @@ -81,4 +82,4 @@ $icon-glyphs-enterprise: (
// "upload-cloud": "\e923",
// "watch": "\1f552"
);
$icon-glyphs: map-merge($icon-glyphs-enterprise, $icon-glyphs-personenverkehr);
$icon-glyphs: map.merge($icon-glyphs-enterprise, $icon-glyphs-personenverkehr);
13 changes: 7 additions & 6 deletions source/_patterns/00-base/type/_fonts.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
@use "sass:map";
@import "../../../css/db-ui-core.variables";
@import "fonts.variables";

@each $font-name, $font-meta in $font-families {
$font-family: map-get($font-meta, "font-family");
$font-filename: map-get($font-meta, "font-filename");
$font-weight: map-get($font-meta, "font-weight");
$font-style: map-get($font-meta, "font-style");
$font-local-name: map-get($font-meta, "font-local-name");
$font-local-name-short: map-get($font-meta, "font-local-name-short");
$font-family: map.get($font-meta, "font-family");
$font-filename: map.get($font-meta, "font-filename");
$font-weight: map.get($font-meta, "font-weight");
$font-style: map.get($font-meta, "font-style");
$font-local-name: map.get($font-meta, "font-local-name");
$font-local-name-short: map.get($font-meta, "font-local-name-short");

@font-face {
font-family: $font-family;
Expand Down
19 changes: 11 additions & 8 deletions source/_patterns/01-elements/buttons/button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@charset "utf-8";

@use "sass:string";
@import "button.variables";

.elm-button {
Expand Down Expand Up @@ -46,7 +47,7 @@
background-color: $button-brand-primary--backgroundColor;

&:disabled {
background-color: unquote(
background-color: string.unquote(
$button-brand-primary--backgroundColor + "40"
);
}
Expand All @@ -67,7 +68,9 @@
background-color: $button-primary--backgroundColor;

&:disabled {
background-color: unquote($button-primary--backgroundColor + "40");
background-color: string.unquote(
$button-primary--backgroundColor + "40"
);
}

&:not(:disabled) {
Expand All @@ -90,8 +93,8 @@
color: $db-color-cool-gray-700;

&:disabled {
color: unquote($db-color-cool-gray-700 + "80");
border-color: unquote($db-color-cool-gray-700 + "40");
color: string.unquote($db-color-cool-gray-700 + "80");
border-color: string.unquote($db-color-cool-gray-700 + "40");
}

&:not(:disabled) {
Expand All @@ -111,8 +114,8 @@
color: $db-color-cool-gray-700;

&:disabled {
color: unquote($db-color-cool-gray-700 + "80");
background-color: unquote(
color: string.unquote($db-color-cool-gray-700 + "80");
background-color: string.unquote(
$button-secondarySolid--backgroundColor + "40"
);
}
Expand All @@ -135,7 +138,7 @@
color: $db-color-cool-gray-700;

&:disabled {
color: unquote($db-color-cool-gray-700 + "80");
color: string.unquote($db-color-cool-gray-700 + "80");
}

&:not(:disabled) {
Expand Down Expand Up @@ -214,7 +217,7 @@
}

&:disabled {
color: unquote($button---color + "80");
color: string.unquote($button---color + "80");
}

// width
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@charset "utf-8";
@use "sass:map";
@use "sass:math";

@import "loading-indicator.variables";
Expand All @@ -17,12 +18,12 @@
&%size-#{$size} {
--loadingindicator--stroke-width: #{math.div(
44px,
map-get($db-spinner-sizes, $size)
map.get($db-spinner-sizes, $size)
) *
$stroke-width};
--loadingindicator--r: 19px;
height: map-get($db-spinner-sizes, $size);
width: map-get($db-spinner-sizes, $size);
height: map.get($db-spinner-sizes, $size);
width: map.get($db-spinner-sizes, $size);
}
}
}
Expand Down

0 comments on commit bc5c4b9

Please sign in to comment.