@helsenorge/designsystem-react 13.0.0-workspaces-beta.1 → 13.0.0-workspaces-beta.3

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.
Files changed (58) hide show
  1. package/lib/CHANGELOG.md +4 -0
  2. package/lib/FormFieldTag.js.map +1 -1
  3. package/lib/Table.js +3 -3
  4. package/lib/Table.js.map +1 -1
  5. package/lib/TableBody.js +2 -2
  6. package/lib/TableBody.js.map +1 -1
  7. package/lib/TableCell.js +2 -2
  8. package/lib/TableCell.js.map +1 -1
  9. package/lib/TableExpandedRow.js +4 -4
  10. package/lib/TableExpandedRow.js.map +1 -1
  11. package/lib/TableExpanderCell.js +2 -2
  12. package/lib/TableExpanderCell.js.map +1 -1
  13. package/lib/TableHead.js +6 -6
  14. package/lib/TableHead.js.map +1 -1
  15. package/lib/TableHeadCell.js +5 -5
  16. package/lib/TableHeadCell.js.map +1 -1
  17. package/lib/TableRow.js +5 -5
  18. package/lib/TableRow.js.map +1 -1
  19. package/lib/components/FormFieldTag/FormFieldTag.d.ts +1 -1
  20. package/lib/components/Toast/styles.module.scss.d.ts +15 -0
  21. package/package.json +27 -9
  22. package/scss/_body.scss +11 -0
  23. package/scss/_breakpoints.scss +29 -0
  24. package/scss/_figma-tokens.scss +68 -0
  25. package/scss/_font-mixins.scss +262 -0
  26. package/scss/_font-settings.scss +8 -0
  27. package/scss/_fonts.scss +155 -0
  28. package/scss/_grid.scss +6 -0
  29. package/scss/_icon.scss +8 -0
  30. package/scss/_input.scss +139 -0
  31. package/scss/_palette.scss +146 -0
  32. package/scss/_print.scss +219 -0
  33. package/scss/_reset.scss +13 -0
  34. package/scss/_screen-reader.scss +63 -0
  35. package/scss/_spacers.scss +42 -0
  36. package/scss/bootstrap/LICENSE +22 -0
  37. package/scss/bootstrap/scss/_functions.scss +210 -0
  38. package/scss/bootstrap/scss/_grid.scss +73 -0
  39. package/scss/bootstrap/scss/_variables.scss +990 -0
  40. package/scss/bootstrap/scss/bootstrap-grid.scss +30 -0
  41. package/scss/bootstrap/scss/mixins/_breakpoints.scss +131 -0
  42. package/scss/bootstrap/scss/mixins/_deprecate.scss +11 -0
  43. package/scss/bootstrap/scss/mixins/_grid-framework.scss +89 -0
  44. package/scss/bootstrap/scss/mixins/_grid.scss +76 -0
  45. package/scss/bootstrap/scss/utilities/_display.scss +30 -0
  46. package/scss/bootstrap/scss/utilities/_flex.scss +120 -0
  47. package/scss/bootstrap/scss/utilities/_spacing.scss +80 -0
  48. package/scss/bootstrap/scss/vendor/_rfs.scss +233 -0
  49. package/scss/helsenorge.scss +10 -0
  50. package/scss/layout.module.scss +14 -0
  51. package/scss/layout.module.scss.d.ts +9 -0
  52. package/scss/supernova/index.css +4 -0
  53. package/scss/supernova/styles/colors.css +258 -0
  54. package/scss/supernova/styles/spacers.css +24 -0
  55. package/scss/supernova/styles/typography.css +110 -0
  56. package/scss/typography.module.scss +182 -0
  57. package/scss/typography.module.scss.d.ts +38 -0
  58. package/scss/typography.stories.tsx +203 -0
@@ -0,0 +1,146 @@
1
+ $black: #000;
2
+ $white: #fff;
3
+ $banana50: #fdf8df;
4
+ $banana100: #fcf2bf;
5
+ $banana200: #f9ea9f;
6
+ $banana300: #f5e080;
7
+ $banana400: #ebc840;
8
+ $banana500: #ddab06;
9
+ $banana600: #c59302;
10
+ $banana700: #ab7c00;
11
+ $banana800: #916500;
12
+ $banana900: #764f00;
13
+ $blueberry50: #e4f7f9;
14
+ $blueberry100: #cae7ed;
15
+ $blueberry200: #afdae3;
16
+ $blueberry300: #7abecc;
17
+ $blueberry400: #58aabb;
18
+ $blueberry500: #188097;
19
+ $blueberry600: #126f87;
20
+ $blueberry60010: #126f8710;
21
+ $blueberry700: #08667c;
22
+ $blueberry800: #06596c;
23
+ $blueberry900: #084350;
24
+ $cherry50: #fff2ea;
25
+ $cherry100: #f7e1d2;
26
+ $cherry200: #eec0a5;
27
+ $cherry300: #e39376;
28
+ $cherry400: #d56147;
29
+ $cherry500: #c83521;
30
+ $cherry600: #b62e1c;
31
+ $cherry700: #a31f0e;
32
+ $cherry800: #912112;
33
+ $cherry900: #7e1c0e;
34
+ $kiwi50: #e6f8ee;
35
+ $kiwi100: #c2edd6;
36
+ $kiwi200: #9de2bf;
37
+ $kiwi300: #79d6aa;
38
+ $kiwi400: #56ca96;
39
+ $kiwi500: #33be84;
40
+ $kiwi600: #10b172;
41
+ $kiwi700: #0ca161;
42
+ $kiwi800: #099150;
43
+ $kiwi900: #078141;
44
+ $neutral50: #f5f3f3;
45
+ $neutral100: #eae7e7;
46
+ $neutral200: #d6d4d3;
47
+ $neutral300: #bdbab9;
48
+ $neutral400: #aaa8a6;
49
+ $neutral500: #989693;
50
+ $neutral600: #7d7c79;
51
+ $neutral700: #62625f;
52
+ $neutral800: #474745;
53
+ $neutral900: #2b2c2b;
54
+ $plum50: #efe4fd;
55
+ $plum100: #d7bdf9;
56
+ $plum200: #bf98f3;
57
+ $plum300: #a875eb;
58
+ $plum400: #9153e2;
59
+ $plum500: #7a33d7;
60
+ $plum600: #6a2abf;
61
+ $plum700: #5b22a6;
62
+ $plum800: #4c1b8c;
63
+ $plum900: #3c1471;
64
+ $inverted-hover-old: #ffffff0d;
65
+ $inverted-hover: #ffffff1a;
66
+ $transparent-grey: rgb(102 102 102 / 75%);
67
+ $palette-map: (
68
+ 'banana50': $banana50,
69
+ 'banana100': $banana100,
70
+ 'banana200': $banana200,
71
+ 'banana300': $banana300,
72
+ 'banana400': $banana400,
73
+ 'banana500': $banana500,
74
+ 'banana600': $banana600,
75
+ 'banana700': $banana700,
76
+ 'banana800': $banana800,
77
+ 'banana900': $banana900,
78
+ 'blueberry50': $blueberry50,
79
+ 'blueberry100': $blueberry100,
80
+ 'blueberry200': $blueberry200,
81
+ 'blueberry300': $blueberry300,
82
+ 'blueberry400': $blueberry400,
83
+ 'blueberry500': $blueberry500,
84
+ 'blueberry600': $blueberry600,
85
+ 'blueberry700': $blueberry700,
86
+ 'blueberry800': $blueberry800,
87
+ 'blueberry900': $blueberry900,
88
+ 'cherry50': $cherry50,
89
+ 'cherry100': $cherry100,
90
+ 'cherry200': $cherry200,
91
+ 'cherry300': $cherry300,
92
+ 'cherry400': $cherry400,
93
+ 'cherry500': $cherry500,
94
+ 'cherry600': $cherry600,
95
+ 'cherry700': $cherry700,
96
+ 'cherry800': $cherry800,
97
+ 'cherry900': $cherry900,
98
+ 'kiwi50': $kiwi50,
99
+ 'kiwi100': $kiwi100,
100
+ 'kiwi200': $kiwi200,
101
+ 'kiwi300': $kiwi300,
102
+ 'kiwi400': $kiwi400,
103
+ 'kiwi500': $kiwi500,
104
+ 'kiwi600': $kiwi600,
105
+ 'kiwi700': $kiwi700,
106
+ 'kiwi800': $kiwi800,
107
+ 'kiwi900': $kiwi900,
108
+ 'neutral50': $neutral50,
109
+ 'neutral100': $neutral100,
110
+ 'neutral200': $neutral200,
111
+ 'neutral300': $neutral300,
112
+ 'neutral400': $neutral400,
113
+ 'neutral500': $neutral500,
114
+ 'neutral600': $neutral600,
115
+ 'neutral700': $neutral700,
116
+ 'neutral800': $neutral800,
117
+ 'neutral900': $neutral900,
118
+ 'plum50': $plum50,
119
+ 'plum100': $plum100,
120
+ 'plum200': $plum200,
121
+ 'plum300': $plum300,
122
+ 'plum400': $plum400,
123
+ 'plum500': $plum500,
124
+ 'plum600': $plum600,
125
+ 'plum700': $plum700,
126
+ 'plum800': $plum800,
127
+ 'plum900': $plum900,
128
+ 'black': $black,
129
+ 'white': $white,
130
+ );
131
+
132
+ /**
133
+ * Konverter en gjennomsiktig farge til en ugjennomsiktig farge ved å simulere fargen plassert
134
+ * på en bakgrunnsfarge (f.eks. 50% gjennomsiktig $blueberry200 på hvit bakgrunn).
135
+ *
136
+ * Fra https://makandracards.com/makandra/42500-sass-how-to-convert-an-rgba-color-to-its-rgb-look-alike
137
+ *
138
+ * @param $rgba Farge med alpha-verdi, f.eks. rgba(black, 0.67)
139
+ * @param $background Bakgrunnsfarge. Default: $white
140
+ *
141
+ * @returns Farge uten gjennomsiktighet
142
+ */
143
+ @function rgba-to-rgb($rgba, $background: $white) {
144
+ /* stylelint-disable-next-line scss/no-global-function-names */
145
+ @return mix(rgb(red($rgba), green($rgba), blue($rgba)), $background, alpha($rgba) * 100%);
146
+ }
@@ -0,0 +1,219 @@
1
+ @use 'sass:map';
2
+ @use 'palette' as palette;
3
+ @use 'breakpoints' as breakpoints;
4
+
5
+ @media print {
6
+ *,
7
+ *::before,
8
+ *::after {
9
+ text-shadow: none !important;
10
+ box-shadow: none !important;
11
+ }
12
+
13
+ @page {
14
+ size: a3;
15
+ }
16
+
17
+ body {
18
+ min-width: map.get(breakpoints.$grid-breakpoints, lg) !important;
19
+ }
20
+
21
+ .container {
22
+ min-width: map.get(breakpoints.$grid-breakpoints, lg) !important;
23
+ }
24
+
25
+ abbr[title]::after {
26
+ content: ' (' attr(title) ')';
27
+ }
28
+
29
+ pre {
30
+ white-space: pre-wrap !important;
31
+ }
32
+
33
+ pre,
34
+ blockquote {
35
+ border: 1px solid palette.$neutral500;
36
+ page-break-inside: avoid;
37
+ }
38
+
39
+ .table {
40
+ border-collapse: collapse !important;
41
+ }
42
+
43
+ thead {
44
+ display: table-header-group;
45
+ }
46
+
47
+ tr,
48
+ img {
49
+ page-break-inside: avoid;
50
+ }
51
+
52
+ p,
53
+ h2,
54
+ h3 {
55
+ orphans: 3;
56
+ widows: 3;
57
+ }
58
+
59
+ h2,
60
+ h3 {
61
+ page-break-after: avoid;
62
+ }
63
+
64
+ .col-print-1 {
65
+ max-width: 8.3333%;
66
+ }
67
+
68
+ .col-print-2 {
69
+ max-width: 16.6667%;
70
+ }
71
+
72
+ .col-print-3 {
73
+ max-width: 25%;
74
+ }
75
+
76
+ .col-print-4 {
77
+ max-width: 33.3333%;
78
+ }
79
+
80
+ .col-print-5 {
81
+ max-width: 41.6667%;
82
+ }
83
+
84
+ .col-print-6 {
85
+ max-width: 50%;
86
+ }
87
+
88
+ .col-print-7 {
89
+ max-width: 58.3333%;
90
+ }
91
+
92
+ .col-print-8 {
93
+ max-width: 66.6667%;
94
+ }
95
+
96
+ .col-print-9 {
97
+ max-width: 75%;
98
+ }
99
+
100
+ .col-print-10 {
101
+ max-width: 83.3333%;
102
+ }
103
+
104
+ .col-print-11 {
105
+ max-width: 91.6667%;
106
+ }
107
+
108
+ .col-print-12 {
109
+ max-width: 100%;
110
+ }
111
+
112
+ .order-print-first {
113
+ order: -1;
114
+ }
115
+
116
+ .order-print-last {
117
+ order: 13;
118
+ }
119
+
120
+ .order-print-0 {
121
+ order: 0;
122
+ }
123
+
124
+ .order-print-1 {
125
+ order: 1;
126
+ }
127
+
128
+ .order-print-2 {
129
+ order: 2;
130
+ }
131
+
132
+ .order-print-3 {
133
+ order: 3;
134
+ }
135
+
136
+ .order-print-4 {
137
+ order: 4;
138
+ }
139
+
140
+ .order-print-5 {
141
+ order: 5;
142
+ }
143
+
144
+ .order-print-6 {
145
+ order: 6;
146
+ }
147
+
148
+ .order-print-7 {
149
+ order: 7;
150
+ }
151
+
152
+ .order-print-8 {
153
+ order: 8;
154
+ }
155
+
156
+ .order-print-9 {
157
+ order: 9;
158
+ }
159
+
160
+ .order-print-10 {
161
+ order: 10;
162
+ }
163
+
164
+ .order-print-11 {
165
+ order: 11;
166
+ }
167
+
168
+ .order-print-12 {
169
+ order: 12;
170
+ }
171
+
172
+ .offset-print-0 {
173
+ margin-left: 0;
174
+ }
175
+
176
+ .offset-print-1 {
177
+ margin-left: 8.3333%;
178
+ }
179
+
180
+ .offset-print-2 {
181
+ margin-left: 16.6667%;
182
+ }
183
+
184
+ .offset-print-3 {
185
+ margin-left: 25%;
186
+ }
187
+
188
+ .offset-print-4 {
189
+ margin-left: 33.3333%;
190
+ }
191
+
192
+ .offset-print-5 {
193
+ margin-left: 41.6667%;
194
+ }
195
+
196
+ .offset-print-6 {
197
+ margin-left: 50%;
198
+ }
199
+
200
+ .offset-print-7 {
201
+ margin-left: 58.3333%;
202
+ }
203
+
204
+ .offset-print-8 {
205
+ margin-left: 66.6667%;
206
+ }
207
+
208
+ .offset-print-9 {
209
+ margin-left: 75%;
210
+ }
211
+
212
+ .offset-print-10 {
213
+ margin-left: 83.3333%;
214
+ }
215
+
216
+ .offset-print-11 {
217
+ margin-left: 91.6667%;
218
+ }
219
+ }
@@ -0,0 +1,13 @@
1
+ @import 'normalize.css/normalize.css';
2
+
3
+ /** Fiks for iOS og Safari 15 */
4
+ button,
5
+ input,
6
+ optgroup,
7
+ select,
8
+ textarea,
9
+ [type='button'],
10
+ [type='reset'],
11
+ [type='submit'] {
12
+ color: black;
13
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ Improved screen reader only CSS class
3
+ @author Gaël Poupard
4
+ @note Based on Yahoo!'s technique
5
+ @author Thierry Koblentz
6
+ @see https://developer.yahoo.com/blogs/ydn/clip-hidden-content-better-accessibility-53456.html
7
+ * 1.
8
+ @note `clip` is deprecated but works everywhere
9
+ @see https://developer.mozilla.org/en-US/docs/Web/CSS/clip
10
+ * 2.
11
+ @note `clip-path` is the future-proof version, but not very well supported yet
12
+ @see https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path
13
+ @see http://caniuse.com/#search=clip-path
14
+ @author Yvain Liechti
15
+ @see https://twitter.com/ryuran78/status/778943389819604992
16
+ * 3.
17
+ @note preventing text to be condensed
18
+ author J. Renée Beach
19
+ @see https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
20
+ @note Drupal 8 goes with word-wrap: normal instead
21
+ @see https://www.drupal.org/node/2045151
22
+ @see http://cgit.drupalcode.org/drupal/commit/?id=5b847ea
23
+ * 4.
24
+ @note !important is important
25
+ @note Obviously you wanna hide something
26
+ @author Harry Roberts
27
+ @see https://csswizardry.com/2016/05/the-importance-of-important/
28
+ */
29
+
30
+ @mixin sr-only() {
31
+ border: 0 !important;
32
+ clip: rect(1px, 1px, 1px, 1px) !important; /* 1 */
33
+ clip-path: inset(50%) !important; /* 2 */
34
+ height: 1px !important;
35
+ margin: -1px !important;
36
+ overflow: hidden !important;
37
+ padding: 0 !important;
38
+ position: absolute !important;
39
+ width: 1px !important;
40
+ white-space: nowrap !important; /* 3 */
41
+ }
42
+
43
+ /*
44
+ Use in conjunction with .sr-only to only display content when it's focused.
45
+ @note Useful for skip links
46
+ @see http://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1
47
+ @note Based on a HTML5 Boilerplate technique, included in Bootstrap
48
+ @note Fixed a bug with position: static on iOS 10.0.2 + VoiceOver
49
+ @author Sylvain Pigeard
50
+ @see https://github.com/twbs/bootstrap/issues/20732
51
+ */
52
+ @mixin sr-only-focusable() {
53
+ &:active,
54
+ &:focus {
55
+ clip: auto !important;
56
+ clip-path: none !important;
57
+ height: auto !important;
58
+ margin: auto !important;
59
+ overflow: visible !important;
60
+ width: auto !important;
61
+ white-space: normal !important;
62
+ }
63
+ }
@@ -0,0 +1,42 @@
1
+ @use 'sass:map';
2
+
3
+ $spacer: 1rem;
4
+ $spacers: (
5
+ 0: 0,
6
+ 1: $spacer * 0.125,
7
+ 2: $spacer * 0.25,
8
+ 3: $spacer * 0.5,
9
+ 4: $spacer * 0.75,
10
+ 5: $spacer * 1,
11
+ 6: $spacer * 1.5,
12
+ 7: $spacer * 2,
13
+ 8: $spacer * 3,
14
+ 9: $spacer * 4,
15
+ 10: $spacer * 5,
16
+ 11: $spacer * 6,
17
+ 12: $spacer * 7,
18
+ 13: $spacer * 8,
19
+ );
20
+ /* stylelint-disable-next-line */
21
+ @function getSpacer($spacerSize) {
22
+ $spacer-value: map.get(
23
+ (
24
+ 4xs: map.get($spacers, 1),
25
+ 3xs: map.get($spacers, 2),
26
+ 2xs: map.get($spacers, 3),
27
+ xs: map.get($spacers, 4),
28
+ s: map.get($spacers, 5),
29
+ m: map.get($spacers, 6),
30
+ l: map.get($spacers, 7),
31
+ xl: map.get($spacers, 8),
32
+ 2xl: map.get($spacers, 9),
33
+ 3xl: map.get($spacers, 10),
34
+ 4xl: map.get($spacers, 11),
35
+ 5xl: map.get($spacers, 12),
36
+ 6xl: map.get($spacers, 13),
37
+ ),
38
+ $spacerSize
39
+ );
40
+
41
+ @return $spacer-value;
42
+ }
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011-2022 Twitter, Inc.
4
+ Copyright (c) 2011-2022 The Bootstrap Authors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,210 @@
1
+ @use 'sass:map';
2
+ @use 'sass:math';
3
+ @use 'sass:meta';
4
+ @use 'sass:string';
5
+ @use 'sass:list';
6
+ // stylelint-disable scss/comment-no-empty, scss/no-global-function-names, scss/at-mixin-pattern, scss/at-if-no-null, scss/operator-no-newline-after
7
+
8
+ // Bootstrap functions
9
+ //
10
+ // Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
11
+
12
+ // Ascending
13
+ // Used to evaluate Sass maps like our grid breakpoints.
14
+ @mixin _assert-ascending($map, $map-name) {
15
+ $prev-key: null;
16
+ $prev-num: null;
17
+
18
+ @each $key, $num in $map {
19
+ @if $prev-num == null or math.unit($num) == '%' or math.unit($prev-num) == '%' {
20
+ // Do nothing
21
+ } @else if not math.compatible($prev-num, $num) {
22
+ @warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !";
23
+ } @else if $prev-num >= $num {
24
+ @warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !";
25
+ }
26
+
27
+ $prev-key: $key;
28
+ $prev-num: $num;
29
+ }
30
+ }
31
+
32
+ // Starts at zero
33
+ // Used to ensure the min-width of the lowest breakpoint starts at 0.
34
+ @mixin _assert-starts-at-zero($map, $map-name: '$grid-breakpoints') {
35
+ @if list.length($map) > 0 {
36
+ $values: map.values($map);
37
+ $first-value: list.nth($values, 1);
38
+
39
+ @if $first-value != 0 {
40
+ @warn "First breakpoint in #{$map-name} must start at 0, but starts at #{$first-value}.";
41
+ }
42
+ }
43
+ }
44
+
45
+ // Replace `$search` with `$replace` in `$string`
46
+ // Used on our SVG icon backgrounds for custom forms.
47
+ //
48
+ // @author Hugo Giraudel
49
+ // @param {String} $string - Initial string
50
+ // @param {String} $search - Substring to replace
51
+ // @param {String} $replace ('') - New value
52
+ // @return {String} - Updated string
53
+ @function str-replace($string, $search, $replace: '') {
54
+ $index: string.index($string, $search);
55
+
56
+ @if $index {
57
+ @return string.slice($string, 1, $index - 1) + $replace +
58
+ str-replace(string.slice($string, $index + string.length($search)), $search, $replace);
59
+ }
60
+
61
+ @return $string;
62
+ }
63
+
64
+ // See https://codepen.io/kevinweber/pen/dXWoRw
65
+ //
66
+ // Requires the use of quotes around data URIs.
67
+
68
+ @function escape-svg($string) {
69
+ @if string.index($string, 'data:image/svg+xml') {
70
+ @each $char, $encoded in $escaped-characters {
71
+ // Do not escape the url brackets
72
+ @if string.index($string, 'url(') == 1 {
73
+ $string: url('#{str-replace(string.slice($string, 6, -3), $char, $encoded)}');
74
+ } @else {
75
+ $string: str-replace($string, $char, $encoded);
76
+ }
77
+ }
78
+ }
79
+
80
+ @return $string;
81
+ }
82
+
83
+ // Color contrast
84
+ @function color-yiq($color, $dark: $yiq-text-dark, $light: $yiq-text-light) {
85
+ $r: red($color);
86
+ $g: green($color);
87
+ $b: blue($color);
88
+ $yiq: (($r * 299) + ($g * 587) + ($b * 114)) * 0.001;
89
+
90
+ @if $yiq >= $yiq-contrasted-threshold {
91
+ @return $dark;
92
+ } @else {
93
+ @return $light;
94
+ }
95
+ }
96
+
97
+ // Retrieve color Sass maps
98
+ @function color($key: 'blue') {
99
+ @return map.get($colors, $key);
100
+ }
101
+
102
+ @function theme-color($key: 'primary') {
103
+ @return map.get($theme-colors, $key);
104
+ }
105
+
106
+ @function gray($key: '100') {
107
+ @return map.get($grays, $key);
108
+ }
109
+
110
+ // Request a theme color level
111
+ @function theme-color-level($color-name: 'primary', $level: 0) {
112
+ $color: theme-color($color-name);
113
+ $color-base: if($level > 0, $black, $white);
114
+ $level: math.abs($level);
115
+
116
+ @return mix($color-base, $color, $level * $theme-color-interval);
117
+ }
118
+
119
+ // Return valid calc
120
+ @function add($value1, $value2, $return-calc: true) {
121
+ @if $value1 == null {
122
+ @return $value2;
123
+ }
124
+
125
+ @if $value2 == null {
126
+ @return $value1;
127
+ }
128
+
129
+ @if meta.type-of($value1) == number and meta.type-of($value2) == number and math.compatible($value1, $value2) {
130
+ @return $value1 + $value2;
131
+ }
132
+
133
+ @return if($return-calc == true, calc(#{$value1} + #{$value2}), $value1 + string.unquote(' + ') + $value2);
134
+ }
135
+
136
+ @function subtract($value1, $value2, $return-calc: true) {
137
+ @if $value1 == null and $value2 == null {
138
+ @return null;
139
+ }
140
+
141
+ @if $value1 == null {
142
+ @return -$value2;
143
+ }
144
+
145
+ @if $value2 == null {
146
+ @return $value1;
147
+ }
148
+
149
+ @if meta.type-of($value1) == number and meta.type-of($value2) == number and math.compatible($value1, $value2) {
150
+ @return $value1 - $value2;
151
+ }
152
+
153
+ @if meta.type-of($value2) != number {
154
+ $value2: string.unquote('(') + $value2 + string.unquote(')');
155
+ }
156
+
157
+ @return if($return-calc == true, calc(#{$value1} - #{$value2}), $value1 + string.unquote(' - ') + $value2);
158
+ }
159
+
160
+ @function divide($dividend, $divisor, $precision: 10) {
161
+ $sign: if($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0, 1, -1);
162
+ $dividend: math.abs($dividend);
163
+ $divisor: math.abs($divisor);
164
+
165
+ @if $dividend == 0 {
166
+ @return 0;
167
+ }
168
+
169
+ @if $divisor == 0 {
170
+ @error "Cannot divide by 0";
171
+ }
172
+
173
+ $remainder: $dividend;
174
+ $result: 0;
175
+ $factor: 10;
176
+
177
+ @while $remainder > 0 and $precision >= 0 {
178
+ $quotient: 0;
179
+
180
+ @while $remainder >= $divisor {
181
+ $remainder: $remainder - $divisor;
182
+ $quotient: $quotient + 1;
183
+ }
184
+
185
+ $result: $result * 10 + $quotient;
186
+ $factor: $factor * 0.1;
187
+ $remainder: $remainder * 10;
188
+ $precision: $precision - 1;
189
+
190
+ @if $precision < 0 and $remainder >= $divisor * 5 {
191
+ $result: $result + 1;
192
+ }
193
+ }
194
+
195
+ $result: $result * $factor * $sign;
196
+ $dividend-unit: math.unit($dividend);
197
+ $divisor-unit: math.unit($divisor);
198
+ $unit-map: (
199
+ 'px': 1px,
200
+ 'rem': 1rem,
201
+ 'em': 1em,
202
+ '%': 1%,
203
+ );
204
+
205
+ @if $dividend-unit != $divisor-unit and map.has-key($unit-map, $dividend-unit) {
206
+ $result: $result * map.get($unit-map, $dividend-unit);
207
+ }
208
+
209
+ @return $result;
210
+ }