dso-toolkit 79.1.0 → 80.0.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.
@@ -11,7 +11,7 @@
11
11
  .dso-close {
12
12
  @include button.element();
13
13
 
14
- $inset-unit: calc(units.$u1 / 2);
14
+ $inset-unit: units.$u1 * 0.5 - alert.$border-size;
15
15
 
16
16
  position: absolute;
17
17
  inset-block-start: $inset-unit;
@@ -45,57 +45,25 @@
45
45
  content: "";
46
46
  }
47
47
 
48
- &.dso-compact {
49
- @include alert.compact();
50
-
51
- // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
52
- & {
53
- min-block-size: alert.$inline-padding;
54
- }
55
- }
56
-
57
48
  &.alert-success {
58
- @include alert.status-success();
59
-
60
- &.dso-compact::before {
61
- background-color: alert.$success-compact-accent-bg;
62
- }
63
-
64
49
  &:not(.dso-compact)::before {
65
50
  @include di.base("status-success", alert.$icon-size);
66
51
  }
67
52
  }
68
53
 
69
54
  &.alert-error {
70
- @include alert.status-error();
71
-
72
- &.dso-compact::before {
73
- background-color: alert.$danger-compact-accent-bg;
74
- }
75
-
76
55
  &:not(.dso-compact)::before {
77
56
  @include di.base("status-error", alert.$icon-size);
78
57
  }
79
58
  }
80
59
 
81
60
  &.alert-warning {
82
- @include alert.status-warning();
83
-
84
- &.dso-compact::before {
85
- background-color: alert.$warning-compact-accent-bg;
86
- }
87
-
88
61
  &:not(.dso-compact)::before {
89
62
  @include di.base("status-warning", alert.$icon-size);
90
63
  }
91
64
  }
92
65
 
93
66
  &.alert-info {
94
- @include alert.status-info();
95
-
96
- &.dso-compact::before {
97
- background-color: alert.$info-compact-accent-bg;
98
- }
99
67
  &:not(.dso-compact)::before {
100
68
  @include di.base("status-info", alert.$icon-size);
101
69
  }
@@ -105,50 +73,4 @@
105
73
  // Web Component
106
74
  dso-alert {
107
75
  @include alert.children();
108
-
109
- &[status="success"] {
110
- @include alert.status-success();
111
- }
112
-
113
- &[status="error"] {
114
- @include alert.status-error();
115
- }
116
-
117
- &[status="warning"] {
118
- @include alert.status-warning();
119
- }
120
-
121
- &[status="info"] {
122
- @include alert.status-info();
123
- }
124
-
125
- &[compact]:not([compact="false"]) {
126
- @include alert.compact();
127
-
128
- position: relative;
129
- }
130
-
131
- &[status="success"][compact]:not([compact="false"]) {
132
- &::before {
133
- background-color: alert.$success-compact-accent-bg;
134
- }
135
- }
136
-
137
- &[status="error"][compact]:not([compact="false"]) {
138
- &::before {
139
- background-color: alert.$danger-compact-accent-bg;
140
- }
141
- }
142
-
143
- &[status="warning"][compact]:not([compact="false"]) {
144
- &::before {
145
- background-color: alert.$warning-compact-accent-bg;
146
- }
147
- }
148
-
149
- &[status="info"][compact]:not([compact="false"]) {
150
- &::before {
151
- background-color: alert.$info-compact-accent-bg;
152
- }
153
- }
154
76
  }
@@ -1,6 +1,7 @@
1
1
  @use "../../variables/units";
2
2
  @use "../../variables/states";
3
3
 
4
+ $border-size: 1px;
4
5
  $icon-size: units.$u3;
5
6
  $inline-padding: units.$u2;
6
7
  $block-padding: units.$u2;
@@ -5,7 +5,8 @@
5
5
  @use "badge.variables" as badge-variables;
6
6
 
7
7
  @mixin root() {
8
- border: 1px solid;
8
+ border-width: 1px;
9
+ border-style: solid;
9
10
  border-radius: 1em;
10
11
  display: inline-block;
11
12
  font-size: 0.875em;
@@ -16,34 +17,42 @@
16
17
  text-align: center;
17
18
 
18
19
  & {
19
- @include set-colors.apply(badge-variables.$default-bg-color, $icons: false, $links: false);
20
+ @include _variant(badge-variables.$default-bg-color);
20
21
  }
21
22
 
22
23
  &.badge-info {
23
- @include set-colors.apply(badge-variables.$info-bg-color, $icons: false, $links: false);
24
+ @include _variant(badge-variables.$info-bg-color);
24
25
  }
25
26
 
26
27
  &.badge-primary {
27
- @include set-colors.apply(badge-variables.$primary-bg-color, $icons: false, $links: false);
28
+ @include _variant(badge-variables.$primary-bg-color);
28
29
  }
29
30
 
30
31
  &.badge-success {
31
- @include set-colors.apply(badge-variables.$success-bg-color, $icons: false, $links: false);
32
+ @include _variant(badge-variables.$success-bg-color);
32
33
  }
33
34
 
34
35
  &.badge-warning {
35
- @include set-colors.apply(badge-variables.$warning-bg-color, $icons: false, $links: false);
36
+ @include _variant(badge-variables.$warning-bg-color);
36
37
  }
37
38
 
38
39
  &.badge-error {
39
- @include set-colors.apply(badge-variables.$error-bg-color, $icons: false, $links: false);
40
+ @include _variant(badge-variables.$error-bg-color);
40
41
  }
41
42
 
42
43
  &.badge-outline {
43
- @include set-colors.apply(colors.$wit, colors.$grijs-90, $icons: false, $links: false);
44
+ @include _variant(colors.$wit, colors.$grijs-90);
44
45
  }
45
46
 
46
47
  &.badge-attention {
47
- @include set-colors.apply(badge-variables.$attention-bg-color, $icons: false, $links: false);
48
+ @include _variant(badge-variables.$attention-bg-color);
49
+ }
50
+ }
51
+
52
+ @mixin _variant($background-color, $border-color: $background-color) {
53
+ @include set-colors.apply($background-color, "badge");
54
+
55
+ & {
56
+ border-color: $border-color;
48
57
  }
49
58
  }
@@ -79,19 +79,35 @@
79
79
  }
80
80
 
81
81
  @mixin success() {
82
- @include set-colors.apply(banner-variables.$success-bg, banner-variables.$success-border);
82
+ @include set-colors.apply(banner-variables.$success-bg, "banner");
83
+
84
+ & {
85
+ border-color: banner-variables.$success-border;
86
+ }
83
87
  }
84
88
 
85
89
  @mixin error() {
86
- @include set-colors.apply(banner-variables.$error-bg, banner-variables.$error-border);
90
+ @include set-colors.apply(banner-variables.$error-bg, "banner");
91
+
92
+ & {
93
+ border-color: banner-variables.$error-border;
94
+ }
87
95
  }
88
96
 
89
97
  @mixin info() {
90
- @include set-colors.apply(banner-variables.$info-bg, banner-variables.$info-border);
98
+ @include set-colors.apply(banner-variables.$info-bg, "banner");
99
+
100
+ & {
101
+ border-color: banner-variables.$info-border;
102
+ }
91
103
  }
92
104
 
93
105
  @mixin warning() {
94
- @include set-colors.apply(banner-variables.$warning-bg, banner-variables.$warning-border);
106
+ @include set-colors.apply(banner-variables.$warning-bg, "banner");
107
+
108
+ & {
109
+ border-color: banner-variables.$warning-border;
110
+ }
95
111
  }
96
112
 
97
113
  @mixin root() {
@@ -4,7 +4,7 @@
4
4
  /// The root mixin to apply the correct color and strikethrough for a delete visualisation.
5
5
  /// @param {Boolean} $strikethrough - Whether to apply a strikethrough or not. Default is true. If false, only background color will be applied. Consumers are responsible for setting strikethrough styles. For example with the `delete.strikethrough()` mixin.
6
6
  @mixin root($strikethrough: true) {
7
- @include set-colors.apply(colors.$rood-20);
7
+ @include set-colors.apply(colors.$rood-20, "delete");
8
8
 
9
9
  @if ($strikethrough) {
10
10
  & {
@@ -12,7 +12,7 @@
12
12
  @use "document-header.variables" as document-header-variables;
13
13
 
14
14
  .dso-document-header {
15
- @include set-colors.apply(colors.$grijs-5);
15
+ @include set-colors.apply(colors.$grijs-5, "document-header");
16
16
 
17
17
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
18
18
  & {
@@ -50,7 +50,7 @@
50
50
 
51
51
  &.dso-variant-ontwerp {
52
52
  .dso-document-header-status {
53
- @include set-colors.apply(colors.$geel);
53
+ @include set-colors.apply(colors.$geel, "document-header");
54
54
 
55
55
  // To do: remove in #2542
56
56
  dso-icon[icon="pencil"] {
@@ -61,7 +61,7 @@
61
61
 
62
62
  &.dso-variant-besluitversie {
63
63
  .dso-document-header-status {
64
- @include set-colors.apply(colors.$bosgroen);
64
+ @include set-colors.apply(colors.$bosgroen, "document-header");
65
65
 
66
66
  // To do: remove in #2542
67
67
  dso-icon[icon="hammer"] {
@@ -12,7 +12,7 @@
12
12
  footer {
13
13
  @include css-grid.full-width-row();
14
14
 
15
- @include set-colors.apply(colors.$grijs-5);
15
+ @include set-colors.apply(colors.$grijs-5, "footer");
16
16
 
17
17
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
18
18
  & {
@@ -35,19 +35,19 @@
35
35
  $step-counter-selector
36
36
  ) {
37
37
  &:not(#{$white-selector}, #{$yellow-selector}, #{$border-selector}) {
38
- @include set-colors.apply(colors.$grijs-5);
38
+ @include set-colors.apply(colors.$grijs-5, "highlight-box");
39
39
  }
40
40
 
41
41
  &#{$grey-selector} {
42
- @include set-colors.apply(colors.$grijs-5);
42
+ @include set-colors.apply(colors.$grijs-5, "highlight-box");
43
43
  }
44
44
 
45
45
  &#{$white-selector} {
46
- @include set-colors.apply(colors.$wit);
46
+ @include set-colors.apply(colors.$wit, "highlight-box");
47
47
  }
48
48
 
49
49
  &#{$yellow-selector} {
50
- @include set-colors.apply(colors.$geel-20);
50
+ @include set-colors.apply(colors.$geel-20, "highlight-box");
51
51
  }
52
52
 
53
53
  &#{$drop-shadow-selector} {
@@ -60,7 +60,11 @@
60
60
  }
61
61
 
62
62
  &#{$border-selector}:not(#{$grey-selector}, #{$yellow-selector}) {
63
- @include set-colors.apply(colors.$wit, $border-color: colors.$grijs-20);
63
+ @include set-colors.apply(colors.$wit, "highlight-box");
64
+
65
+ & {
66
+ border-color: colors.$grijs-20;
67
+ }
64
68
  }
65
69
 
66
70
  &#{$has-counter-selector} {
@@ -8,7 +8,7 @@
8
8
  padding-inline: units.$u2 units.$u4;
9
9
  position: relative;
10
10
 
11
- @include set-colors.apply(colors.$grijs-5);
11
+ @include set-colors.apply(colors.$grijs-5, "info");
12
12
  }
13
13
 
14
14
  @mixin richContent() {
@@ -58,5 +58,5 @@
58
58
  @include richContent();
59
59
  }
60
60
 
61
- @include set-colors.apply(colors.$grijs-5);
61
+ @include set-colors.apply(colors.$grijs-5, "info");
62
62
  }
@@ -8,7 +8,7 @@
8
8
  }
9
9
 
10
10
  @mixin root() {
11
- @include set-colors.apply(colors.$lime-20);
11
+ @include set-colors.apply(colors.$lime-20, "insert");
12
12
 
13
13
  & {
14
14
  box-shadow: insert-variables.$box-shadow;
@@ -20,31 +20,31 @@
20
20
  }
21
21
 
22
22
  & {
23
- @include set-colors.apply(label-variables.$default-bg-color, $icons: false, $links: false);
23
+ @include set-colors.apply(label-variables.$default-bg-color, "label");
24
24
  }
25
25
 
26
26
  &.dso-label-info {
27
- @include set-colors.apply(label-variables.$info-bg-color, $icons: false, $links: false);
27
+ @include set-colors.apply(label-variables.$info-bg-color, "label");
28
28
  }
29
29
 
30
30
  &.dso-label-primary {
31
- @include set-colors.apply(label-variables.$primary-bg-color, $icons: false, $links: false);
31
+ @include set-colors.apply(label-variables.$primary-bg-color, "label");
32
32
  }
33
33
 
34
34
  &.dso-label-success {
35
- @include set-colors.apply(label-variables.$success-bg-color, $icons: false, $links: false);
35
+ @include set-colors.apply(label-variables.$success-bg-color, "label");
36
36
  }
37
37
 
38
38
  &.dso-label-warning {
39
- @include set-colors.apply(label-variables.$warning-bg-color, $icons: false, $links: false);
39
+ @include set-colors.apply(label-variables.$warning-bg-color, "label");
40
40
  }
41
41
 
42
42
  &.dso-label-error {
43
- @include set-colors.apply(label-variables.$error-bg-color, $icons: false, $links: false);
43
+ @include set-colors.apply(label-variables.$error-bg-color, "label");
44
44
  }
45
45
 
46
46
  &.dso-label-bright {
47
- @include set-colors.apply(label-variables.$bright-bg-color, $icons: false, $links: false);
47
+ @include set-colors.apply(label-variables.$bright-bg-color, "label");
48
48
 
49
49
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
50
50
  & {
@@ -54,11 +54,11 @@
54
54
  }
55
55
 
56
56
  &.dso-label-attention {
57
- @include set-colors.apply(label-variables.$attention-bg-color, $icons: false, $links: false);
57
+ @include set-colors.apply(label-variables.$attention-bg-color, "label");
58
58
  }
59
59
 
60
60
  &.dso-label-filter {
61
- @include set-colors.apply(label-variables.$filter-bg-color, $icons: false, $links: false);
61
+ @include set-colors.apply(label-variables.$filter-bg-color, "label");
62
62
 
63
63
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
64
64
  & {
@@ -10,7 +10,7 @@
10
10
 
11
11
  .dso-shopping-cart {
12
12
  .dso-status {
13
- @include set-colors.apply(colors.$grijs-5);
13
+ @include set-colors.apply(colors.$grijs-5, "shopping-cart");
14
14
 
15
15
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
16
16
  & {
@@ -58,7 +58,7 @@
58
58
  }
59
59
 
60
60
  .dso-contents {
61
- @include set-colors.apply(colors.$grijs-5);
61
+ @include set-colors.apply(colors.$grijs-5, "shopping-cart");
62
62
 
63
63
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
64
64
  & {
@@ -87,7 +87,7 @@
87
87
  ol {
88
88
  @include list.unstyled();
89
89
 
90
- @include set-colors.apply(colors.$grijs-5, $icons: false);
90
+ @include set-colors.apply(colors.$grijs-5, "shopping-cart");
91
91
 
92
92
  // stylelint-disable-next-line no-duplicate-selectors -- needed to fix sass deprecation warnings: #2724
93
93
  & {
@@ -46,3 +46,12 @@
46
46
 
47
47
  @return null;
48
48
  }
49
+
50
+ // Returns `true` if the given color is pure white.
51
+ // Checks the lightness channel in HSL color space.
52
+
53
+ // @param {Color} $color - The color to evaluate.
54
+ // @return {Boolean} Whether the color is pure white.
55
+ @function is-white($color) {
56
+ @return color.channel($color, "lightness", $space: hsl) == 100%;
57
+ }
@@ -2,76 +2,81 @@
2
2
  @use "sass:color";
3
3
 
4
4
  @use "../../variables/colors";
5
+ @use "../../variables/states";
5
6
  @use "../../components/link/link.variables" as link-variables;
6
7
  @use "../../components/button/button.variables" as button-variables;
7
8
  @use "../../di";
8
9
 
9
- @use "../functions/contrast-color.functions" as contrast-color;
10
+ @use "../functions/contrast-color.functions" as contrast-color-functions;
10
11
 
11
- // SET COLORS
12
- // ==========
13
- // USAGE: @include setColors($bgcolor, $bordercolor: transparent, $links: true);
14
- // $background-color: background color of the element (required)
15
- // $border-color: border color of the element (optional)
16
- // $icons: boolean to set link icon colors according to background color (optional). set to false if you don't want to change the link icon colors.
17
- // $links: boolean to set link colors according to background color (optional). set to false if you don't want to change the link colors.
18
- // $reverse: in case the combination chosen by this mixin & contrast-color function still does not meet WCAG requirements, set $reverse to true. If this combination does not comply either, find another background-color.
12
+ // Automatically applies accessible (WCAG-compliant) text and UI colors based on a given background color.
19
13
 
20
- @mixin apply($background-color, $border-color: null, $icons: true, $links: true, $reverse: false) {
21
- $icon-color: null;
14
+ // This mixin determines an appropriate contrast color for text (`light` or `dark`)
15
+ // and dynamically adjusts related colors for links, icons, alerts, and buttons
16
+ // to ensure consistent readability and sufficient contrast across different backgrounds.
17
+ // Automatically applies accessible (WCAG-compliant) text and UI colors
18
+ // based on a provided background color. Adjusts related UI elements via custom css props to ensure consistent
19
+ // readability.
20
+
21
+ // @param {Color} $background-color
22
+ // The background color used to compute contrast colors.
23
+
24
+ // @param {String} $self
25
+ // The context of the component using this mixin (e.g., "alert", "link", "button").
26
+ // Determines which sections of styles should be skipped to avoid overriding component-specific rules.
27
+
28
+ @mixin apply($background-color, $self) {
22
29
  & {
23
30
  // run contrast-color function to determine WCAG-compliant text color
24
- $contrast-color: contrast-color.apply($background-color);
31
+ $contrast-color: contrast-color-functions.apply($background-color);
32
+
33
+ @if $self != "alert" {
34
+ @if contrast-color-functions.is-white($background-color) {
35
+ --_dso-alert-success-border-color: initial;
36
+ --_dso-alert-error-border-color: initial;
37
+ --_dso-alert-info-border-color: initial;
38
+ --_dso-alert-warning-border-color: initial;
39
+ } @else {
40
+ --_dso-alert-success-border-color: #{states.$success-compact-accent-color};
41
+ --_dso-alert-error-border-color: #{states.$danger-compact-accent-color};
42
+ --_dso-alert-info-border-color: #{states.$info-compact-accent-color};
43
+ --_dso-alert-warning-border-color: #{states.$warning-compact-accent-color};
44
+ }
45
+ }
25
46
 
26
- // set link and icon color according to text color
27
- @if color.channel($background-color, "lightness", $space: hsl) < 100% {
28
- @if $links == true {
47
+ @if $self != "link" {
48
+ @if not contrast-color-functions.is-white($background-color) {
29
49
  --link-color: currentColor;
30
50
  --link-hover-color: currentColor;
31
51
  --link-visited-color: currentColor;
32
- }
33
52
 
34
- @if $contrast-color == colors.$contrast-dark {
35
- --_dso-icon-button-tertiary-color: #{colors.$grijs-90};
36
- --_dso-icon-button-tertiary-hover-color: #{colors.$grijs-70};
37
- --_dso-icon-button-tertiary-active-color: #{colors.$bosgroen-140};
38
- --_dso-icon-button-tertiary-disabled-color: #{colors.$grijs-40};
39
- } @else if $contrast-color == colors.$contrast-light {
40
- --_dso-icon-button-tertiary-color: #{colors.$wit};
41
- }
53
+ // set according to contrast color determined by contrast-color function
54
+ $icon-color: if($contrast-color == colors.$contrast-dark, "zwart", "wit");
42
55
 
43
- // set according to contrast color determined by contrast-color function
44
- @if $contrast-color == colors.$contrast-dark {
45
- $icon-color: "zwart";
46
- } @else if $contrast-color == colors.$contrast-light {
47
- $icon-color: "wit";
56
+ @include _linkIconColors($icon-color);
48
57
  }
58
+ }
49
59
 
50
- // if contrast-color function gets it wrong, and therefore $reverse is set to true
51
- @if $contrast-color == colors.$contrast-dark and $reverse == true {
52
- $icon-color: "wit";
53
- $contrast-color: colors.$contrast-light;
54
- } @else if $contrast-color == colors.$contrast-light and $reverse == true {
55
- $icon-color: "zwart";
56
- $contrast-color: colors.$contrast-dark;
60
+ @if $self != "icon-button" {
61
+ @if not contrast-color-functions.is-white($background-color) {
62
+ @if $contrast-color == colors.$contrast-dark {
63
+ --_dso-icon-button-tertiary-color: #{colors.$grijs-90};
64
+ --_dso-icon-button-tertiary-hover-color: #{colors.$grijs-70};
65
+ --_dso-icon-button-tertiary-active-color: #{colors.$bosgroen-140};
66
+ --_dso-icon-button-tertiary-disabled-color: #{colors.$grijs-40};
67
+ } @else if $contrast-color == colors.$contrast-light {
68
+ --_dso-icon-button-tertiary-color: #{colors.$wit};
69
+ }
57
70
  }
58
71
  }
59
72
 
60
73
  // set css properties
61
74
  background-color: $background-color;
62
- border-color: if($border-color, $border-color, $background-color);
63
75
  color: $contrast-color;
64
-
65
- // implement icon color according to background color
66
- @if $icon-color and $icons == true {
67
- @include _anchorIconColors($icon-color);
68
- }
69
76
  }
70
77
  }
71
78
 
72
- // ANCHOR ICON COLORS
73
- // ==================
74
- @mixin _anchorIconColors($icon-color) {
79
+ @mixin _linkIconColors($icon-color) {
75
80
  // loop through map to set icon mode
76
81
  @each $mode, $value in link-variables.$linkIcons {
77
82
  $selector: map.get($value, "selector");