@kirbydesign/designsystem 4.0.25 → 5.0.1

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,3 +1,5 @@
1
+ @use "sass:color";
2
+ @use "sass:map";
1
3
  $brand-colors: (
2
4
  'primary': #00e89a,
3
5
  'secondary': #005c3c,
@@ -31,13 +33,13 @@ $text-colors: (
31
33
  $focus-ring-color: rgb(77, 144, 254);
32
34
 
33
35
  @function getAllColors() {
34
- @return map-merge(map-merge($brand-colors, $notification-colors), $system-colors);
36
+ @return map.merge(map.merge($brand-colors, $notification-colors), $system-colors);
35
37
  }
36
38
 
37
39
  $_color-palette: getAllColors();
38
40
 
39
41
  // TODO Deprecated variable, used to generate colors in some components - don't use it anymore!
40
- $main-colors: map-remove(
42
+ $main-colors: map.remove(
41
43
  $_color-palette,
42
44
  'background-color',
43
45
  'black',
@@ -47,8 +49,8 @@ $main-colors: map-remove(
47
49
  );
48
50
 
49
51
  @function _get-color-contrast($color) {
50
- $contrast-light: map-get($system-colors, 'white');
51
- $contrast-dark: map-get($system-colors, 'black');
52
+ $contrast-light: map.get($system-colors, 'white');
53
+ $contrast-dark: map.get($system-colors, 'black');
52
54
  $color-brightness: _get-color-brightness($color);
53
55
  @if $color-brightness == 'dark' {
54
56
  @return $contrast-light;
@@ -58,14 +60,14 @@ $main-colors: map-remove(
58
60
  }
59
61
 
60
62
  @function _get-color-brightness($color) {
61
- $red: red($color);
62
- $green: green($color);
63
- $blue: blue($color);
63
+ $red: color.red($color);
64
+ $green: color.green($color);
65
+ $blue: color.blue($color);
64
66
  /*
65
67
  Color brightness is determined by the following formula:
66
68
  ((Red value X 299) + (Green value X 587) + (Blue value X 114)) / 1000
67
69
  */
68
- $color-brightness: (($red * 299) + ($green * 587) + ($blue * 114)) / 1000;
70
+ $color-brightness: (($red * 299) + ($green * 587) + ($blue * 114)) * 0.001;
69
71
  /* The range for color brightness difference is 125 */
70
72
  $color-range: 128;
71
73
 
@@ -79,21 +81,21 @@ $main-colors: map-remove(
79
81
  }
80
82
 
81
83
  @function _get-tint-value($color, $weight: 10) {
82
- @return mix(white, $color, $weight);
84
+ @return color.mix(white, $color, $weight);
83
85
  }
84
86
 
85
87
  @function _get-shade-value($color, $weight: 12) {
86
- @return mix(black, $color, $weight);
88
+ @return color.mix(black, $color, $weight);
87
89
  }
88
90
 
89
91
  @function _get-rgb-values($color) {
90
- @return red($color), green($color), blue($color);
92
+ @return color.red($color), color.green($color), color.blue($color);
91
93
  }
92
94
 
93
95
  @function generate-colors($colors: $_color-palette) {
94
96
  $color-list: ();
95
97
  @each $color-name, $color-value in $colors {
96
- $color-list: map-merge(
98
+ $color-list: map.merge(
97
99
  (
98
100
  $color-name: $color-value,
99
101
  #{$color-name}-rgb: #{_get-rgb-values($color-value)},
@@ -1,589 +0,0 @@
1
- @charset "UTF-8";
2
-
3
- // _ _ _ _ _
4
- // (_) | | | | | (_)
5
- // _ _ __ ___| |_ _ __| | ___ _ __ ___ ___ __| |_ __ _
6
- // | | '_ \ / __| | | | |/ _` |/ _ \ | '_ ` _ \ / _ \/ _` | |/ _` |
7
- // | | | | | (__| | |_| | (_| | __/ | | | | | | __/ (_| | | (_| |
8
- // |_|_| |_|\___|_|\__,_|\__,_|\___| |_| |_| |_|\___|\__,_|_|\__,_|
9
- //
10
- // Simple, elegant and maintainable media queries in Sass
11
- // v1.4.9
12
- //
13
- // http://include-media.com
14
- //
15
- // Authors: Eduardo Boucas (@eduardoboucas)
16
- // Hugo Giraudel (@hugogiraudel)
17
- //
18
- // This project is licensed under the terms of the MIT license
19
-
20
- ////
21
- /// include-media library public configuration
22
- /// @author Eduardo Boucas
23
- /// @access public
24
- ////
25
-
26
- ///
27
- /// Creates a list of global breakpoints
28
- ///
29
- /// @example scss - Creates a single breakpoint with the label `phone`
30
- /// $breakpoints: ('phone': 320px);
31
- ///
32
- $breakpoints: (
33
- 'phone': 320px,
34
- 'tablet': 768px,
35
- 'desktop': 1024px,
36
- ) !default;
37
-
38
- ///
39
- /// Creates a list of static expressions or media types
40
- ///
41
- /// @example scss - Creates a single media type (screen)
42
- /// $media-expressions: ('screen': 'screen');
43
- ///
44
- /// @example scss - Creates a static expression with logical disjunction (OR operator)
45
- /// $media-expressions: (
46
- /// 'retina2x': '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)'
47
- /// );
48
- ///
49
- $media-expressions: (
50
- 'screen': 'screen',
51
- 'print': 'print',
52
- 'handheld': 'handheld',
53
- 'landscape': '(orientation: landscape)',
54
- 'portrait': '(orientation: portrait)',
55
- 'retina2x':
56
- '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 2dppx)',
57
- 'retina3x':
58
- '(-webkit-min-device-pixel-ratio: 3), (min-resolution: 350dpi), (min-resolution: 3dppx)',
59
- ) !default;
60
-
61
- ///
62
- /// Defines a number to be added or subtracted from each unit when declaring breakpoints with exclusive intervals
63
- ///
64
- /// @example scss - Interval for pixels is defined as `1` by default
65
- /// @include media('>128px') {}
66
- ///
67
- /// /* Generates: */
68
- /// @media (min-width: 129px) {}
69
- ///
70
- /// @example scss - Interval for ems is defined as `0.01` by default
71
- /// @include media('>20em') {}
72
- ///
73
- /// /* Generates: */
74
- /// @media (min-width: 20.01em) {}
75
- ///
76
- /// @example scss - Interval for rems is defined as `0.1` by default, to be used with `font-size: 62.5%;`
77
- /// @include media('>2.0rem') {}
78
- ///
79
- /// /* Generates: */
80
- /// @media (min-width: 2.1rem) {}
81
- ///
82
- $unit-intervals: (
83
- 'px': 1,
84
- 'em': 0.01,
85
- 'rem': 0.1,
86
- '': 0,
87
- ) !default;
88
-
89
- ///
90
- /// Defines whether support for media queries is available, useful for creating separate stylesheets
91
- /// for browsers that don't support media queries.
92
- ///
93
- /// @example scss - Disables support for media queries
94
- /// $im-media-support: false;
95
- /// @include media('>=tablet') {
96
- /// .foo {
97
- /// color: tomato;
98
- /// }
99
- /// }
100
- ///
101
- /// /* Generates: */
102
- /// .foo {
103
- /// color: tomato;
104
- /// }
105
- ///
106
- $im-media-support: true !default;
107
-
108
- ///
109
- /// Selects which breakpoint to emulate when support for media queries is disabled. Media queries that start at or
110
- /// intercept the breakpoint will be displayed, any others will be ignored.
111
- ///
112
- /// @example scss - This media query will show because it intercepts the static breakpoint
113
- /// $im-media-support: false;
114
- /// $im-no-media-breakpoint: 'desktop';
115
- /// @include media('>=tablet') {
116
- /// .foo {
117
- /// color: tomato;
118
- /// }
119
- /// }
120
- ///
121
- /// /* Generates: */
122
- /// .foo {
123
- /// color: tomato;
124
- /// }
125
- ///
126
- /// @example scss - This media query will NOT show because it does not intercept the desktop breakpoint
127
- /// $im-media-support: false;
128
- /// $im-no-media-breakpoint: 'tablet';
129
- /// @include media('>=desktop') {
130
- /// .foo {
131
- /// color: tomato;
132
- /// }
133
- /// }
134
- ///
135
- /// /* No output */
136
- ///
137
- $im-no-media-breakpoint: 'desktop' !default;
138
-
139
- ///
140
- /// Selects which media expressions are allowed in an expression for it to be used when media queries
141
- /// are not supported.
142
- ///
143
- /// @example scss - This media query will show because it intercepts the static breakpoint and contains only accepted media expressions
144
- /// $im-media-support: false;
145
- /// $im-no-media-breakpoint: 'desktop';
146
- /// $im-no-media-expressions: ('screen');
147
- /// @include media('>=tablet', 'screen') {
148
- /// .foo {
149
- /// color: tomato;
150
- /// }
151
- /// }
152
- ///
153
- /// /* Generates: */
154
- /// .foo {
155
- /// color: tomato;
156
- /// }
157
- ///
158
- /// @example scss - This media query will NOT show because it intercepts the static breakpoint but contains a media expression that is not accepted
159
- /// $im-media-support: false;
160
- /// $im-no-media-breakpoint: 'desktop';
161
- /// $im-no-media-expressions: ('screen');
162
- /// @include media('>=tablet', 'retina2x') {
163
- /// .foo {
164
- /// color: tomato;
165
- /// }
166
- /// }
167
- ///
168
- /// /* No output */
169
- ///
170
- $im-no-media-expressions: ('screen', 'portrait', 'landscape') !default;
171
-
172
- ////
173
- /// Cross-engine logging engine
174
- /// @author Hugo Giraudel
175
- /// @access private
176
- ////
177
-
178
- ///
179
- /// Log a message either with `@error` if supported
180
- /// else with `@warn`, using `feature-exists('at-error')`
181
- /// to detect support.
182
- ///
183
- /// @param {String} $message - Message to log
184
- ///
185
- @function im-log($message) {
186
- @if feature-exists('at-error') {
187
- @error $message;
188
- } @else {
189
- @warn $message;
190
- $_: noop();
191
- }
192
-
193
- @return $message;
194
- }
195
-
196
- ///
197
- /// Wrapper mixin for the log function so it can be used with a more friendly
198
- /// API than `@if im-log('..') {}` or `$_: im-log('..')`. Basically, use the function
199
- /// within functions because it is not possible to include a mixin in a function
200
- /// and use the mixin everywhere else because it's much more elegant.
201
- ///
202
- /// @param {String} $message - Message to log
203
- ///
204
- @mixin log($message) {
205
- @if im-log($message) {
206
- }
207
- }
208
-
209
- ///
210
- /// Function with no `@return` called next to `@warn` in Sass 3.3
211
- /// to trigger a compiling error and stop the process.
212
- ///
213
- @function noop() {
214
- }
215
-
216
- ///
217
- /// Determines whether a list of conditions is intercepted by the static breakpoint.
218
- ///
219
- /// @param {Arglist} $conditions - Media query conditions
220
- ///
221
- /// @return {Boolean} - Returns true if the conditions are intercepted by the static breakpoint
222
- ///
223
- @function im-intercepts-static-breakpoint($conditions...) {
224
- $no-media-breakpoint-value: map-get($breakpoints, $im-no-media-breakpoint);
225
-
226
- @if not $no-media-breakpoint-value {
227
- @if im-log('`#{$im-no-media-breakpoint}` is not a valid breakpoint.') {
228
- }
229
- }
230
-
231
- @each $condition in $conditions {
232
- @if not map-has-key($media-expressions, $condition) {
233
- $operator: get-expression-operator($condition);
234
- $prefix: get-expression-prefix($operator);
235
- $value: get-expression-value($condition, $operator);
236
-
237
- // scss-lint:disable SpaceAroundOperator
238
- @if ($prefix == 'max' and $value <= $no-media-breakpoint-value) or
239
- ($prefix == 'min' and $value > $no-media-breakpoint-value)
240
- {
241
- @return false;
242
- }
243
- } @else if not index($im-no-media-expressions, $condition) {
244
- @return false;
245
- }
246
- }
247
-
248
- @return true;
249
- }
250
-
251
- ////
252
- /// Parsing engine
253
- /// @author Hugo Giraudel
254
- /// @access private
255
- ////
256
-
257
- ///
258
- /// Get operator of an expression
259
- ///
260
- /// @param {String} $expression - Expression to extract operator from
261
- ///
262
- /// @return {String} - Any of `>=`, `>`, `<=`, `<`, `≥`, `≤`
263
- ///
264
- @function get-expression-operator($expression) {
265
- @each $operator in ('>=', '>', '<=', '<', '≥', '≤') {
266
- @if str-index($expression, $operator) {
267
- @return $operator;
268
- }
269
- }
270
-
271
- // It is not possible to include a mixin inside a function, so we have to
272
- // rely on the `im-log(..)` function rather than the `log(..)` mixin. Because
273
- // functions cannot be called anywhere in Sass, we need to hack the call in
274
- // a dummy variable, such as `$_`. If anybody ever raise a scoping issue with
275
- // Sass 3.3, change this line in `@if im-log(..) {}` instead.
276
- $_: im-log('No operator found in `#{$expression}`.');
277
- }
278
-
279
- ///
280
- /// Get dimension of an expression, based on a found operator
281
- ///
282
- /// @param {String} $expression - Expression to extract dimension from
283
- /// @param {String} $operator - Operator from `$expression`
284
- ///
285
- /// @return {String} - `width` or `height` (or potentially anything else)
286
- ///
287
- @function get-expression-dimension($expression, $operator) {
288
- $operator-index: str-index($expression, $operator);
289
- $parsed-dimension: str-slice($expression, 0, $operator-index - 1);
290
- $dimension: 'width';
291
-
292
- @if str-length($parsed-dimension) > 0 {
293
- $dimension: $parsed-dimension;
294
- }
295
-
296
- @return $dimension;
297
- }
298
-
299
- ///
300
- /// Get dimension prefix based on an operator
301
- ///
302
- /// @param {String} $operator - Operator
303
- ///
304
- /// @return {String} - `min` or `max`
305
- ///
306
- @function get-expression-prefix($operator) {
307
- @return if(index(('<', '<=', '≤'), $operator), 'max', 'min');
308
- }
309
-
310
- ///
311
- /// Get value of an expression, based on a found operator
312
- ///
313
- /// @param {String} $expression - Expression to extract value from
314
- /// @param {String} $operator - Operator from `$expression`
315
- ///
316
- /// @return {Number} - A numeric value
317
- ///
318
- @function get-expression-value($expression, $operator) {
319
- $operator-index: str-index($expression, $operator);
320
- $value: str-slice($expression, $operator-index + str-length($operator));
321
-
322
- @if map-has-key($breakpoints, $value) {
323
- $value: map-get($breakpoints, $value);
324
- } @else {
325
- $value: to-number($value);
326
- }
327
-
328
- $interval: map-get($unit-intervals, unit($value));
329
-
330
- @if not $interval {
331
- // It is not possible to include a mixin inside a function, so we have to
332
- // rely on the `im-log(..)` function rather than the `log(..)` mixin. Because
333
- // functions cannot be called anywhere in Sass, we need to hack the call in
334
- // a dummy variable, such as `$_`. If anybody ever raise a scoping issue with
335
- // Sass 3.3, change this line in `@if im-log(..) {}` instead.
336
- $_: im-log('Unknown unit `#{unit($value)}`.');
337
- }
338
-
339
- @if $operator == '>' {
340
- $value: $value + $interval;
341
- } @else if $operator == '<' {
342
- $value: $value - $interval;
343
- }
344
-
345
- @return $value;
346
- }
347
-
348
- ///
349
- /// Parse an expression to return a valid media-query expression
350
- ///
351
- /// @param {String} $expression - Expression to parse
352
- ///
353
- /// @return {String} - Valid media query
354
- ///
355
- @function parse-expression($expression) {
356
- // If it is part of $media-expressions, it has no operator
357
- // then there is no need to go any further, just return the value
358
- @if map-has-key($media-expressions, $expression) {
359
- @return map-get($media-expressions, $expression);
360
- }
361
-
362
- $operator: get-expression-operator($expression);
363
- $dimension: get-expression-dimension($expression, $operator);
364
- $prefix: get-expression-prefix($operator);
365
- $value: get-expression-value($expression, $operator);
366
-
367
- @return '(#{$prefix}-#{$dimension}: #{$value})';
368
- }
369
-
370
- ///
371
- /// Slice `$list` between `$start` and `$end` indexes
372
- ///
373
- /// @access private
374
- ///
375
- /// @param {List} $list - List to slice
376
- /// @param {Number} $start [1] - Start index
377
- /// @param {Number} $end [length($list)] - End index
378
- ///
379
- /// @return {List} Sliced list
380
- ///
381
- @function slice($list, $start: 1, $end: length($list)) {
382
- @if length($list) < 1 or $start > $end {
383
- @return ();
384
- }
385
-
386
- $result: ();
387
-
388
- @for $i from $start through $end {
389
- $result: append($result, nth($list, $i));
390
- }
391
-
392
- @return $result;
393
- }
394
-
395
- ////
396
- /// String to number converter
397
- /// @author Hugo Giraudel
398
- /// @access private
399
- ////
400
-
401
- ///
402
- /// Casts a string into a number
403
- ///
404
- /// @param {String | Number} $value - Value to be parsed
405
- ///
406
- /// @return {Number}
407
- ///
408
- @function to-number($value) {
409
- @if type-of($value) == 'number' {
410
- @return $value;
411
- } @else if type-of($value) != 'string' {
412
- $_: im-log('Value for `to-number` should be a number or a string.');
413
- }
414
-
415
- $first-character: str-slice($value, 1, 1);
416
- $result: 0;
417
- $digits: 0;
418
- $minus: ($first-character == '-');
419
- $numbers: (
420
- '0': 0,
421
- '1': 1,
422
- '2': 2,
423
- '3': 3,
424
- '4': 4,
425
- '5': 5,
426
- '6': 6,
427
- '7': 7,
428
- '8': 8,
429
- '9': 9,
430
- );
431
-
432
- // Remove +/- sign if present at first character
433
- @if ($first-character == '+' or $first-character == '-') {
434
- $value: str-slice($value, 2);
435
- }
436
-
437
- @for $i from 1 through str-length($value) {
438
- $character: str-slice($value, $i, $i);
439
-
440
- @if not(index(map-keys($numbers), $character) or $character == '.') {
441
- @return to-length(if($minus, -$result, $result), str-slice($value, $i));
442
- }
443
-
444
- @if $character == '.' {
445
- $digits: 1;
446
- } @else if $digits == 0 {
447
- $result: $result * 10 + map-get($numbers, $character);
448
- } @else {
449
- $digits: $digits * 10;
450
- $result: $result + map-get($numbers, $character) / $digits;
451
- }
452
- }
453
-
454
- @return if($minus, -$result, $result);
455
- }
456
-
457
- ///
458
- /// Add `$unit` to `$value`
459
- ///
460
- /// @param {Number} $value - Value to add unit to
461
- /// @param {String} $unit - String representation of the unit
462
- ///
463
- /// @return {Number} - `$value` expressed in `$unit`
464
- ///
465
- @function to-length($value, $unit) {
466
- $units: (
467
- 'px': 1px,
468
- 'cm': 1cm,
469
- 'mm': 1mm,
470
- '%': 1%,
471
- 'ch': 1ch,
472
- 'pc': 1pc,
473
- 'in': 1in,
474
- 'em': 1em,
475
- 'rem': 1rem,
476
- 'pt': 1pt,
477
- 'ex': 1ex,
478
- 'vw': 1vw,
479
- 'vh': 1vh,
480
- 'vmin': 1vmin,
481
- 'vmax': 1vmax,
482
- );
483
-
484
- @if not index(map-keys($units), $unit) {
485
- $_: im-log('Invalid unit `#{$unit}`.');
486
- }
487
-
488
- @return $value * map-get($units, $unit);
489
- }
490
-
491
- ///
492
- /// This mixin aims at redefining the configuration just for the scope of
493
- /// the call. It is helpful when having a component needing an extended
494
- /// configuration such as custom breakpoints (referred to as tweakpoints)
495
- /// for instance.
496
- ///
497
- /// @author Hugo Giraudel
498
- ///
499
- /// @param {Map} $tweakpoints [()] - Map of tweakpoints to be merged with `$breakpoints`
500
- /// @param {Map} $tweak-media-expressions [()] - Map of tweaked media expressions to be merged with `$media-expression`
501
- ///
502
- /// @example scss - Extend the global breakpoints with a tweakpoint
503
- /// @include media-context(('custom': 678px)) {
504
- /// .foo {
505
- /// @include media('>phone', '<=custom') {
506
- /// // ...
507
- /// }
508
- /// }
509
- /// }
510
- ///
511
- /// @example scss - Extend the global media expressions with a custom one
512
- /// @include media-context($tweak-media-expressions: ('all': 'all')) {
513
- /// .foo {
514
- /// @include media('all', '>phone') {
515
- /// // ...
516
- /// }
517
- /// }
518
- /// }
519
- ///
520
- /// @example scss - Extend both configuration maps
521
- /// @include media-context(('custom': 678px), ('all': 'all')) {
522
- /// .foo {
523
- /// @include media('all', '>phone', '<=custom') {
524
- /// // ...
525
- /// }
526
- /// }
527
- /// }
528
- ///
529
- @mixin media-context($tweakpoints: (), $tweak-media-expressions: ()) {
530
- // Save global configuration
531
- $global-breakpoints: $breakpoints;
532
- $global-media-expressions: $media-expressions;
533
-
534
- // Update global configuration
535
- $breakpoints: map-merge($breakpoints, $tweakpoints) !global;
536
- $media-expressions: map-merge($media-expressions, $tweak-media-expressions) !global;
537
-
538
- @content;
539
-
540
- // Restore global configuration
541
- $breakpoints: $global-breakpoints !global;
542
- $media-expressions: $global-media-expressions !global;
543
- }
544
-
545
- ////
546
- /// include-media public exposed API
547
- /// @author Eduardo Boucas
548
- /// @access public
549
- ////
550
-
551
- ///
552
- /// Generates a media query based on a list of conditions
553
- ///
554
- /// @param {Arglist} $conditions - Media query conditions
555
- ///
556
- /// @example scss - With a single set breakpoint
557
- /// @include media('>phone') { }
558
- ///
559
- /// @example scss - With two set breakpoints
560
- /// @include media('>phone', '<=tablet') { }
561
- ///
562
- /// @example scss - With custom values
563
- /// @include media('>=358px', '<850px') { }
564
- ///
565
- /// @example scss - With set breakpoints with custom values
566
- /// @include media('>desktop', '<=1350px') { }
567
- ///
568
- /// @example scss - With a static expression
569
- /// @include media('retina2x') { }
570
- ///
571
- /// @example scss - Mixing everything
572
- /// @include media('>=350px', '<tablet', 'retina3x') { }
573
- ///
574
- @mixin media($conditions...) {
575
- // scss-lint:disable SpaceAroundOperator
576
- @if ($im-media-support and length($conditions) == 0) or
577
- (not $im-media-support and im-intercepts-static-breakpoint($conditions...))
578
- {
579
- @content;
580
- } @else if ($im-media-support and length($conditions) > 0) {
581
- @media #{unquote(parse-expression(nth($conditions, 1)))} {
582
- // Recursive call
583
- $sliced: slice($conditions, 2);
584
- @include media($sliced...) {
585
- @content;
586
- }
587
- }
588
- }
589
- }