@ws-serenity/sass-styling 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +1,58 @@
1
- // https://github.com/KittyGiraudel/SassyJSON/tree/master/stylesheets/decode/helpers/color
2
-
3
- @function hex-to-dec($string) {
4
- $hex: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'a' 'b' 'c' 'd' 'e' 'f';
5
- $string: to-lower-case($string);
6
- $length: str-length($string);
7
- $dec: 0;
8
-
9
- @for $i from 1 through $length {
10
- $factor: 1 + (15 * ($length - $i));
11
- $index: index($hex, str-slice($string, $i, $i));
12
- $dec: $dec + $factor * ($index - 1);
13
- }
14
-
15
- @return $dec;
16
- }
17
-
18
- @function regenerateColor($string) {
19
- @if type-of($string) == 'color' {
20
- @return $string;
21
- }
22
-
23
- $string-lower: to-lower-case($string);
24
- $r: '';
25
- $g: '';
26
- $b: '';
27
- $hex: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'a' 'b' 'c' 'd' 'e' 'f';
28
- $length: str-length($string);
29
- $max: if($length == 4, 1, 2);
30
-
31
- @if $length != 4 and $length != 7 {
32
- @return $string;
33
- }
34
-
35
- @for $i from 2 through $length {
36
- $c: str-slice($string-lower, $i, $i);
37
-
38
- @if index($hex, $c) == null {
39
- @return $string;
40
- }
41
-
42
- @if str-length($r) < $max {
43
- $r: $r + $c;
44
- } @else if str-length($g) < $max {
45
- $g: $g + $c;
46
- } @else if str-length($b) < $max {
47
- $b: $b + $c;
48
- }
49
- }
50
-
51
- @if $length == 4 {
52
- $r: $r + $r;
53
- $g: $g + $g;
54
- $b: $b + $b;
55
- }
56
-
57
- @return rgb(hex-to-dec($r), hex-to-dec($g), hex-to-dec($b));
58
- }
1
+ // https://github.com/KittyGiraudel/SassyJSON/tree/master/stylesheets/decode/helpers/color
2
+
3
+ @function hex-to-dec($string) {
4
+ $hex: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'a' 'b' 'c' 'd' 'e' 'f';
5
+ $string: to-lower-case($string);
6
+ $length: str-length($string);
7
+ $dec: 0;
8
+
9
+ @for $i from 1 through $length {
10
+ $factor: 1 + (15 * ($length - $i));
11
+ $index: index($hex, str-slice($string, $i, $i));
12
+ $dec: $dec + $factor * ($index - 1);
13
+ }
14
+
15
+ @return $dec;
16
+ }
17
+
18
+ @function regenerateColor($string) {
19
+ @if type-of($string) == 'color' {
20
+ @return $string;
21
+ }
22
+
23
+ $string-lower: to-lower-case($string);
24
+ $r: '';
25
+ $g: '';
26
+ $b: '';
27
+ $hex: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'a' 'b' 'c' 'd' 'e' 'f';
28
+ $length: str-length($string);
29
+ $max: if($length == 4, 1, 2);
30
+
31
+ @if $length != 4 and $length != 7 {
32
+ @return $string;
33
+ }
34
+
35
+ @for $i from 2 through $length {
36
+ $c: str-slice($string-lower, $i, $i);
37
+
38
+ @if index($hex, $c) == null {
39
+ @return $string;
40
+ }
41
+
42
+ @if str-length($r) < $max {
43
+ $r: $r + $c;
44
+ } @else if str-length($g) < $max {
45
+ $g: $g + $c;
46
+ } @else if str-length($b) < $max {
47
+ $b: $b + $c;
48
+ }
49
+ }
50
+
51
+ @if $length == 4 {
52
+ $r: $r + $r;
53
+ $g: $g + $g;
54
+ $b: $b + $b;
55
+ }
56
+
57
+ @return rgb(hex-to-dec($r), hex-to-dec($g), hex-to-dec($b));
58
+ }
@@ -1,9 +1,9 @@
1
- @function str-replace($string, $search, $replace: '') {
2
- $index: str-index($string, $search);
3
-
4
- @if $index {
5
- @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
6
- }
7
-
8
- @return $string;
9
- }
1
+ @function str-replace($string, $search, $replace: '') {
2
+ $index: str-index($string, $search);
3
+
4
+ @if $index {
5
+ @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
6
+ }
7
+
8
+ @return $string;
9
+ }
@@ -1,101 +1,101 @@
1
- @use 'sass:list';
2
- @use 'sass:string';
3
- @import './functions/strReplace';
4
- @import './functions/regenerateColor';
5
-
6
- @function get-color($color-name, $theme, $theme-colors, $group-name) {
7
- @if string.index($color-name, '%') == 1 {
8
- $group: map-get($theme, $group-name);
9
- @return map-get($group, str-replace($color-name, '%'));
10
- }
11
- @return map-get($theme-colors, str-replace($color-name, '@', $group-name));
12
- }
13
-
14
- @function generate-theme-colors($theme, $theme-config) {
15
- $theme-colors: ();
16
-
17
- // Main
18
- @each $group-name, $group in $theme-config {
19
- $group-type: map-get($group, 'type');
20
- $group-colors: map-get($group, 'colors');
21
- @if $group-type == 'single' {
22
- @each $shade-name, $shade-layers in $group-colors {
23
- $color-rest: black;
24
- $color-hover: black;
25
- $color-active: black;
26
- @for $i from 1 through list.length($shade-layers) {
27
- $layer-config: list.nth($shade-layers, -$i);
28
- $layer-color-name: list.nth($layer-config, 1);
29
- $layer-color: get-color($layer-color-name, $theme, $theme-colors, $group-name);
30
- $layer-color-state-modifiers: list.nth($layer-config, 2);
31
- $rest-modifier: list.nth($layer-color-state-modifiers, 1);
32
- $hover-modifier: $rest-modifier;
33
- @if list.length($layer-color-state-modifiers) >= 2 {
34
- $hover-modifier: list.nth($layer-color-state-modifiers, 2);
35
- }
36
- $active-modifier: $hover-modifier;
37
- @if list.length($layer-color-state-modifiers) >= 3 {
38
- $active-modifier: list.nth($layer-color-state-modifiers, 3);
39
- }
40
- $color-rest: mix($layer-color, $color-rest, $rest-modifier);
41
- $color-hover: mix($layer-color, $color-hover, $hover-modifier);
42
- $color-active: mix($layer-color, $color-active, $active-modifier);
43
- }
44
- $theme-colors: map-merge($theme-colors, (
45
- '#{$group-name}-#{$shade-name}': $color-rest,
46
- '#{$group-name}-#{$shade-name}-hover': $color-hover,
47
- '#{$group-name}-#{$shade-name}-active': $color-active
48
- ));
49
- }
50
- }
51
- @if $group-type == 'foreach' {
52
- @each $color-name, $_ in map-get($theme, $group-name) {
53
- @each $shade-name, $shade-layers in $group-colors {
54
- $color-rest: black;
55
- $color-hover: black;
56
- $color-active: black;
57
- @for $i from 1 through list.length($shade-layers) {
58
- $layer-config: list.nth($shade-layers, -$i);
59
- $layer-color-name: list.nth($layer-config, 1);
60
- $layer-color: get-color(
61
- str-replace(
62
- str-replace($layer-color-name, '%', '%#{$color-name}'),
63
- '@',
64
- '@#{$color-name}'
65
- ),
66
- $theme,
67
- $theme-colors,
68
- $group-name
69
- );
70
- $layer-color-state-modifiers: list.nth($layer-config, 2);
71
- $rest-modifier: list.nth($layer-color-state-modifiers, 1);
72
- $hover-modifier: $rest-modifier;
73
- @if list.length($layer-color-state-modifiers) >= 2 {
74
- $hover-modifier: list.nth($layer-color-state-modifiers, 2);
75
- }
76
- $active-modifier: $hover-modifier;
77
- @if list.length($layer-color-state-modifiers) >= 3 {
78
- $active-modifier: list.nth($layer-color-state-modifiers, 3);
79
- }
80
- $color-rest: mix($layer-color, $color-rest, $rest-modifier);
81
- $color-hover: mix($layer-color, $color-hover, $hover-modifier);
82
- $color-active: mix($layer-color, $color-active, $active-modifier);
83
- }
84
- $theme-colors: map-merge($theme-colors, (
85
- '#{$group-name}#{$color-name}-#{$shade-name}': $color-rest,
86
- '#{$group-name}#{$color-name}-#{$shade-name}-hover': $color-hover,
87
- '#{$group-name}#{$color-name}-#{$shade-name}-active': $color-active
88
- ));
89
- }
90
- }
91
- }
92
- }
93
-
94
- // Overrides
95
- $overrides: map-get($theme, 'overrides');
96
- @each $color-name, $color-value in $overrides {
97
- $theme-colors: map-merge($theme-colors, ($color-name: $color-value));
98
- }
99
-
100
- @return $theme-colors;
101
- }
1
+ @use 'sass:list';
2
+ @use 'sass:string';
3
+ @import './functions/strReplace';
4
+ @import './functions/regenerateColor';
5
+
6
+ @function get-color($color-name, $theme, $theme-colors, $group-name) {
7
+ @if string.index($color-name, '%') == 1 {
8
+ $group: map-get($theme, $group-name);
9
+ @return map-get($group, str-replace($color-name, '%'));
10
+ }
11
+ @return map-get($theme-colors, str-replace($color-name, '@', $group-name));
12
+ }
13
+
14
+ @function generate-theme-colors($theme, $theme-config) {
15
+ $theme-colors: ();
16
+
17
+ // Main
18
+ @each $group-name, $group in $theme-config {
19
+ $group-type: map-get($group, 'type');
20
+ $group-colors: map-get($group, 'colors');
21
+ @if $group-type == 'single' {
22
+ @each $shade-name, $shade-layers in $group-colors {
23
+ $color-rest: black;
24
+ $color-hover: black;
25
+ $color-active: black;
26
+ @for $i from 1 through list.length($shade-layers) {
27
+ $layer-config: list.nth($shade-layers, -$i);
28
+ $layer-color-name: list.nth($layer-config, 1);
29
+ $layer-color: get-color($layer-color-name, $theme, $theme-colors, $group-name);
30
+ $layer-color-state-modifiers: list.nth($layer-config, 2);
31
+ $rest-modifier: list.nth($layer-color-state-modifiers, 1);
32
+ $hover-modifier: $rest-modifier;
33
+ @if list.length($layer-color-state-modifiers) >= 2 {
34
+ $hover-modifier: list.nth($layer-color-state-modifiers, 2);
35
+ }
36
+ $active-modifier: $hover-modifier;
37
+ @if list.length($layer-color-state-modifiers) >= 3 {
38
+ $active-modifier: list.nth($layer-color-state-modifiers, 3);
39
+ }
40
+ $color-rest: mix($layer-color, $color-rest, $rest-modifier);
41
+ $color-hover: mix($layer-color, $color-hover, $hover-modifier);
42
+ $color-active: mix($layer-color, $color-active, $active-modifier);
43
+ }
44
+ $theme-colors: map-merge($theme-colors, (
45
+ '#{$group-name}-#{$shade-name}': $color-rest,
46
+ '#{$group-name}-#{$shade-name}-hover': $color-hover,
47
+ '#{$group-name}-#{$shade-name}-active': $color-active
48
+ ));
49
+ }
50
+ }
51
+ @if $group-type == 'foreach' {
52
+ @each $color-name, $_ in map-get($theme, $group-name) {
53
+ @each $shade-name, $shade-layers in $group-colors {
54
+ $color-rest: black;
55
+ $color-hover: black;
56
+ $color-active: black;
57
+ @for $i from 1 through list.length($shade-layers) {
58
+ $layer-config: list.nth($shade-layers, -$i);
59
+ $layer-color-name: list.nth($layer-config, 1);
60
+ $layer-color: get-color(
61
+ str-replace(
62
+ str-replace($layer-color-name, '%', '%#{$color-name}'),
63
+ '@',
64
+ '@#{$color-name}'
65
+ ),
66
+ $theme,
67
+ $theme-colors,
68
+ $group-name
69
+ );
70
+ $layer-color-state-modifiers: list.nth($layer-config, 2);
71
+ $rest-modifier: list.nth($layer-color-state-modifiers, 1);
72
+ $hover-modifier: $rest-modifier;
73
+ @if list.length($layer-color-state-modifiers) >= 2 {
74
+ $hover-modifier: list.nth($layer-color-state-modifiers, 2);
75
+ }
76
+ $active-modifier: $hover-modifier;
77
+ @if list.length($layer-color-state-modifiers) >= 3 {
78
+ $active-modifier: list.nth($layer-color-state-modifiers, 3);
79
+ }
80
+ $color-rest: mix($layer-color, $color-rest, $rest-modifier);
81
+ $color-hover: mix($layer-color, $color-hover, $hover-modifier);
82
+ $color-active: mix($layer-color, $color-active, $active-modifier);
83
+ }
84
+ $theme-colors: map-merge($theme-colors, (
85
+ '#{$group-name}#{$color-name}-#{$shade-name}': $color-rest,
86
+ '#{$group-name}#{$color-name}-#{$shade-name}-hover': $color-hover,
87
+ '#{$group-name}#{$color-name}-#{$shade-name}-active': $color-active
88
+ ));
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ // Overrides
95
+ $overrides: map-get($theme, 'overrides');
96
+ @each $color-name, $color-value in $overrides {
97
+ $theme-colors: map-merge($theme-colors, ($color-name: $color-value));
98
+ }
99
+
100
+ @return $theme-colors;
101
+ }
@@ -1,12 +1,12 @@
1
- // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
2
- $weight-name-to-value-map: (
3
- thin: 100,
4
- extra-light: 200,
5
- light: 300,
6
- regular: 400,
7
- medium: 500,
8
- semi-bold: 600,
9
- bold: 700,
10
- extra-bold: 800,
11
- heavy: 900,
12
- );
1
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#common_weight_name_mapping
2
+ $weight-name-to-value-map: (
3
+ thin: 100,
4
+ extra-light: 200,
5
+ light: 300,
6
+ regular: 400,
7
+ medium: 500,
8
+ semi-bold: 600,
9
+ bold: 700,
10
+ extra-bold: 800,
11
+ heavy: 900,
12
+ );
@@ -1,60 +1,60 @@
1
- @use 'sass:list';
2
- @use 'sass:map';
3
-
4
- @mixin use-css-vars-conveyor(
5
- $key-vars-tuples,
6
- $conveyor,
7
- $defaults: (),
8
- $aliases: (),
9
- $default-markers: [ d, def, null ]
10
- ) {
11
- // Если в конвейере есть ключ, существующий в дефолтсах
12
- // То помечаем ключ, как override-friendly
13
- $override-friendly-props: [];
14
- @each $key in $conveyor {
15
- @if map.get($defaults, $key) != null {
16
- $override-friendly-props: append($override-friendly-props, $key);
17
- }
18
- }
19
-
20
- // Если в дефолтсах есть ключ, не существующий в конвейере
21
- // То помещаем его в конец конвейера
22
- @each $key, $_ in $defaults {
23
- @if index($conveyor, $key) == null {
24
- $conveyor: append($conveyor, $key);
25
- }
26
- }
27
-
28
- @each $key, $vars in $key-vars-tuples {
29
- @for $i from 1 through length($conveyor) {
30
- $prop: nth($conveyor, $i);
31
- $var: null;
32
-
33
- // Находим raw значение
34
- @if map.get($defaults, $prop) != null {
35
- @if $i <= length($vars) and index($override-friendly-props, $prop) != null {
36
- $var: nth($vars, $i);
37
-
38
- @if index($default-markers, $var) != null {
39
- $var: map.get($defaults, $prop);
40
- }
41
- } @else {
42
- $var: map.get($defaults, $prop);
43
- }
44
- } @else {
45
- $var: nth($vars, $i);
46
- }
47
-
48
- // Находим и применяем алиасы
49
- $prop-aliases: map.get($aliases, $prop);
50
- @if $prop-aliases != null {
51
- $var-aliased-value: map.get($prop-aliases, $var);
52
- @if $var-aliased-value != null {
53
- $var: $var-aliased-value;
54
- }
55
- }
56
-
57
- --#{$key}-#{$prop}: #{$var};
58
- }
59
- }
60
- }
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+
4
+ @mixin use-css-vars-conveyor(
5
+ $key-vars-tuples,
6
+ $conveyor,
7
+ $defaults: (),
8
+ $aliases: (),
9
+ $default-markers: [ d, def, null ]
10
+ ) {
11
+ // Если в конвейере есть ключ, существующий в дефолтсах
12
+ // То помечаем ключ, как override-friendly
13
+ $override-friendly-props: [];
14
+ @each $key in $conveyor {
15
+ @if map.get($defaults, $key) != null {
16
+ $override-friendly-props: append($override-friendly-props, $key);
17
+ }
18
+ }
19
+
20
+ // Если в дефолтсах есть ключ, не существующий в конвейере
21
+ // То помещаем его в конец конвейера
22
+ @each $key, $_ in $defaults {
23
+ @if index($conveyor, $key) == null {
24
+ $conveyor: append($conveyor, $key);
25
+ }
26
+ }
27
+
28
+ @each $key, $vars in $key-vars-tuples {
29
+ @for $i from 1 through length($conveyor) {
30
+ $prop: nth($conveyor, $i);
31
+ $var: null;
32
+
33
+ // Находим raw значение
34
+ @if map.get($defaults, $prop) != null {
35
+ @if $i <= length($vars) and index($override-friendly-props, $prop) != null {
36
+ $var: nth($vars, $i);
37
+
38
+ @if index($default-markers, $var) != null {
39
+ $var: map.get($defaults, $prop);
40
+ }
41
+ } @else {
42
+ $var: map.get($defaults, $prop);
43
+ }
44
+ } @else {
45
+ $var: nth($vars, $i);
46
+ }
47
+
48
+ // Находим и применяем алиасы
49
+ $prop-aliases: map.get($aliases, $prop);
50
+ @if $prop-aliases != null {
51
+ $var-aliased-value: map.get($prop-aliases, $var);
52
+ @if $var-aliased-value != null {
53
+ $var: $var-aliased-value;
54
+ }
55
+ }
56
+
57
+ --#{$key}-#{$prop}: #{$var};
58
+ }
59
+ }
60
+ }
@@ -1,35 +1,35 @@
1
- @import './commonWeights';
2
-
3
- $default-line-height-multiplier: 1.25;
4
-
5
- // todo: cssVarsConveyor can be reused
6
- @mixin set-font-css-vars(
7
- $name,
8
- $size,
9
- $weight: regular,
10
- $line-height: $size * $default-line-height-multiplier,
11
- $letter-spacing: 0
12
- ) {
13
- --#{$name}-font-size: #{$size}px;
14
- --#{$name}-line-height: #{$line-height};
15
- --#{$name}-letter-spacing: #{$letter-spacing};
16
-
17
- @if type-of($weight) == string {
18
- --#{$name}-font-weight: #{map-get($weight-name-to-value-map, $weight)};
19
- } @else {
20
- --#{$name}-font-weight: #{$weight};
21
- }
22
- }
23
-
24
- @mixin set-fonts-css-vars-by-map($map) {
25
- @each $name, $size, $weight, $line-height, $letter-spacing in $map {
26
- @include set-font-css-vars($name, $size, $weight, $line-height, $letter-spacing);
27
- }
28
- }
29
-
30
- @mixin use-css-vars-based-font($name) {
31
- font-size: var(--#{$name}-font-size);
32
- line-height: var(--#{$name}-line-height);
33
- letter-spacing: var(--#{$name}-letter-spacing);
34
- font-weight: var(--#{$name}-font-weight);
35
- }
1
+ @import './commonWeights';
2
+
3
+ $default-line-height-multiplier: 1.25;
4
+
5
+ // todo: cssVarsConveyor can be reused
6
+ @mixin set-font-css-vars(
7
+ $name,
8
+ $size,
9
+ $weight: regular,
10
+ $line-height: $size * $default-line-height-multiplier,
11
+ $letter-spacing: 0
12
+ ) {
13
+ --#{$name}-font-size: #{$size}px;
14
+ --#{$name}-line-height: #{$line-height};
15
+ --#{$name}-letter-spacing: #{$letter-spacing};
16
+
17
+ @if type-of($weight) == string {
18
+ --#{$name}-font-weight: #{map-get($weight-name-to-value-map, $weight)};
19
+ } @else {
20
+ --#{$name}-font-weight: #{$weight};
21
+ }
22
+ }
23
+
24
+ @mixin set-fonts-css-vars-by-map($map) {
25
+ @each $name, $size, $weight, $line-height, $letter-spacing in $map {
26
+ @include set-font-css-vars($name, $size, $weight, $line-height, $letter-spacing);
27
+ }
28
+ }
29
+
30
+ @mixin use-css-vars-based-font($name) {
31
+ font-size: var(--#{$name}-font-size);
32
+ line-height: var(--#{$name}-line-height);
33
+ letter-spacing: var(--#{$name}-letter-spacing);
34
+ font-weight: var(--#{$name}-font-weight);
35
+ }
@@ -1,11 +1,11 @@
1
- @mixin max-width($resolution) {
2
- @media (max-width: #{$resolution}px) {
3
- @content;
4
- }
5
- }
6
-
7
- @mixin min-width($resolution) {
8
- @media (min-width: #{$resolution}px) {
9
- @content;
10
- }
11
- }
1
+ @mixin max-width($resolution) {
2
+ @media (max-width: #{$resolution}px) {
3
+ @content;
4
+ }
5
+ }
6
+
7
+ @mixin min-width($resolution) {
8
+ @media (min-width: #{$resolution}px) {
9
+ @content;
10
+ }
11
+ }