Skip to content

Commit ddec5b0

Browse files
committed
feat: add cursor pointer to interactive components
1 parent 9c301a5 commit ddec5b0

File tree

13 files changed

+108
-69
lines changed

13 files changed

+108
-69
lines changed

packages/components/src/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ Main use-case to overwrite a color or change colors by `data-variant`. Example:
4848

4949
```scss
5050
@use "@db-ui/foundations/build/scss/colors";
51+
@use "@db-ui/foundations/build/scss/helpers";
5152

5253
.db-xxx {
53-
&:enabled {
54-
&:hover {
55-
background-color: colors.$db-current-color-bg-transparent-hover;
56-
}
57-
&:active {
58-
background-color: colors.$db-current-color-bg-transparent-pressed;
59-
}
54+
@include helpers.hover {
55+
background-color: colors.$db-current-color-bg-transparent-hover;
56+
}
57+
58+
@include helpers.active {
59+
background-color: colors.$db-current-color-bg-transparent-pressed;
6060
}
6161

6262
@each $name in colors.$variant-colors {

packages/components/src/components/accordion-item/accordion-item.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
padding: variables.$db-spacing-fixed-md;
4343
gap: variables.$db-spacing-fixed-md;
4444

45-
&:hover {
45+
@include helpers.hover {
4646
background-color: colors.$db-current-color-bg-transparent-hover;
4747
}
4848

49-
&:active {
49+
@include helpers.active {
5050
background-color: colors.$db-current-color-bg-transparent-pressed;
5151
}
5252

packages/components/src/components/button/button.scss

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@use "@db-ui/foundations/build/scss/variables";
44
@use "@db-ui/foundations/build/scss/colors";
55
@use "@db-ui/foundations/build/scss/icons";
6+
@use "@db-ui/foundations/build/scss/helpers";
67
@use "../../styles/component";
78
@use "../../styles/button-components";
89

@@ -19,6 +20,14 @@
1920
// disable text-decoration if someone wants to use the button for an <a> tag
2021
text-decoration: none;
2122

23+
@include helpers.hover {
24+
background-color: colors.$db-current-color-bg-transparent-hover;
25+
}
26+
27+
@include helpers.active {
28+
background-color: colors.$db-current-color-bg-transparent-pressed;
29+
}
30+
2231
// Square icon only buttons
2332
&[data-no-text="true"] {
2433
@include icons.is-icon-text-replace();
@@ -59,14 +68,12 @@
5968
background-color: colors.$db-brand-origin-enabled;
6069
color: colors.$db-brand-on-enabled;
6170

62-
&:not(:disabled) {
63-
&:hover {
64-
background-color: colors.$db-brand-origin-hover;
65-
}
71+
@include helpers.hover {
72+
background-color: colors.$db-brand-origin-hover;
73+
}
6674

67-
&:active {
68-
background-color: colors.$db-brand-origin-pressed;
69-
}
75+
@include helpers.active {
76+
background-color: colors.$db-brand-origin-pressed;
7077
}
7178
}
7279

@@ -85,16 +92,6 @@
8592
background-color: colors.$db-current-color-bg-transparent-semi-enabled;
8693
}
8794

88-
&:not(:disabled) {
89-
&:hover {
90-
background-color: colors.$db-current-color-bg-transparent-hover;
91-
}
92-
93-
&:active {
94-
background-color: colors.$db-current-color-bg-transparent-pressed;
95-
}
96-
}
97-
9895
&:disabled {
9996
opacity: component.$default-disabled;
10097
}

packages/components/src/components/card/card.scss

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use "@db-ui/foundations/build/scss/variables";
22
@use "@db-ui/foundations/build/scss/colors";
3+
@use "@db-ui/foundations/build/scss/helpers";
34
@use "../../styles/component";
45

56
.db-card {
@@ -29,12 +30,12 @@
2930
&:not([data-elevation-level]) {
3031
background-color: colors.$db-current-color-bg-lvl-1-enabled;
3132

32-
&[data-behaviour="interactive"]:not(:disabled) {
33-
&:hover {
33+
&[data-behaviour="interactive"] {
34+
@include helpers.hover {
3435
background-color: colors.$db-current-color-bg-lvl-1-hover;
3536
}
3637

37-
&:active {
38+
@include helpers.active {
3839
background-color: colors.$db-current-color-bg-lvl-1-pressed;
3940
}
4041
}
@@ -43,12 +44,12 @@
4344
&[data-elevation-level="2"] {
4445
background-color: colors.$db-current-color-bg-lvl-2-enabled;
4546

46-
&[data-behaviour="interactive"]:not(:disabled) {
47-
&:hover {
47+
&[data-behaviour="interactive"] {
48+
@include helpers.hover {
4849
background-color: colors.$db-current-color-bg-lvl-2-hover;
4950
}
5051

51-
&:active {
52+
@include helpers.active {
5253
background-color: colors.$db-current-color-bg-lvl-2-pressed;
5354
}
5455
}
@@ -57,12 +58,12 @@
5758
&[data-elevation-level="3"] {
5859
background-color: colors.$db-current-color-bg-lvl-3-enabled;
5960

60-
&[data-behaviour="interactive"]:not(:disabled) {
61-
&:hover {
61+
&[data-behaviour="interactive"] {
62+
@include helpers.hover {
6263
background-color: colors.$db-current-color-bg-lvl-3-hover;
6364
}
6465

65-
&:active {
66+
@include helpers.active {
6667
background-color: colors.$db-current-color-bg-lvl-3-pressed;
6768
}
6869
}

packages/components/src/components/checkbox/checkbox.scss

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use "@db-ui/foundations/build/scss/icons";
33
@use "@db-ui/foundations/build/scss/density";
44
@use "@db-ui/foundations/build/scss/colors";
5+
@use "@db-ui/foundations/build/scss/helpers";
56
@use "../../styles/component";
67
@use "../../styles/form-components";
78

@@ -28,18 +29,16 @@
2829
color: colors.$db-current-color-bg-enabled;
2930
background-color: colors.$db-current-color-enabled;
3031

31-
&::before {
32-
color: colors.$db-current-color-bg-enabled;
32+
@include helpers.hover {
33+
background-color: colors.$db-current-color-hover;
3334
}
3435

35-
&:not(:disabled) {
36-
&:hover {
37-
background-color: colors.$db-current-color-hover;
38-
}
36+
@include helpers.active {
37+
background-color: colors.$db-current-color-pressed;
38+
}
3939

40-
&:active {
41-
background-color: colors.$db-current-color-pressed;
42-
}
40+
&::before {
41+
color: colors.$db-current-color-bg-enabled;
4342
}
4443
}
4544

packages/components/src/components/link/link.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
--db-current-icon-color: #{colors.$db-brand-contrast-high-enabled};
4646
color: colors.$db-current-color-enabled;
4747

48-
&:hover {
48+
@include helpers.hover {
4949
--db-current-color-enabled: #{colors.$db-brand-contrast-high-hover};
5050
}
5151

52-
&:active {
52+
@include helpers.active {
5353
--db-current-color-enabled: #{colors.$db-brand-contrast-high-pressed};
5454
}
5555
}

packages/components/src/components/navigation-item/navigation-item.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,17 @@
5757
text-align: center;
5858
align-items: center; // Centering the content vertically and horizontally
5959

60-
&:hover,
61-
&:has(~ .db-sub-navigation:hover) {
60+
@include helpers.hover {
6261
background-color: colors.$db-current-color-bg-transparent-hover;
6362
}
6463

65-
&:active {
64+
@include helpers.active {
6665
background-color: colors.$db-current-color-bg-transparent-pressed;
6766
}
67+
68+
&:has(~ .db-sub-navigation:hover) {
69+
background-color: colors.$db-current-color-bg-transparent-hover;
70+
}
6871
}
6972

7073
.db-navigation-item {

packages/components/src/components/tab/tab.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use "@db-ui/foundations/build/scss/colors";
33
@use "@db-ui/foundations/build/scss/focus";
44
@use "@db-ui/foundations/build/scss/icons";
5+
@use "@db-ui/foundations/build/scss/helpers";
56
@use "../../styles/component";
67
@use "../../styles/db-puls";
78
@use "../../styles/form-components";
@@ -17,11 +18,11 @@
1718
position: relative;
1819
background-color: colors.$db-current-color-bg-transparent-full-enabled;
1920

20-
&:hover {
21+
@include helpers.hover {
2122
background-color: colors.$db-current-color-bg-transparent-hover;
2223
}
2324

24-
&:active {
25+
@include helpers.active {
2526
background-color: colors.$db-current-color-bg-transparent-pressed;
2627
}
2728

@@ -38,6 +39,7 @@
3839
block-size: calc(100% + #{variables.$db-border-height-3xs});
3940
margin-inline-end: initial;
4041
inset: 0;
42+
cursor: inherit;
4143

4244
&:focus-within,
4345
&:focus-visible {

packages/components/src/styles/_form-components.scss

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ $floating-label-size: calc(
237237
opacity: component.$default-disabled;
238238
}
239239

240-
&:hover {
240+
@include helpers.hover {
241241
background-color: colors.$db-current-color-bg-transparent-hover;
242242
}
243243

@@ -373,6 +373,11 @@ $floating-label-size: calc(
373373
display: flex;
374374
align-items: center;
375375
position: relative;
376+
377+
&:not(:has(input:disabled)) {
378+
@include helpers.hover;
379+
@include helpers.active;
380+
}
376381
}
377382

378383
input {
@@ -396,14 +401,12 @@ $floating-label-size: calc(
396401
inline-size: auto;
397402
padding: 0;
398403

399-
&:enabled {
400-
&:hover {
401-
background-color: colors.$db-current-color-bg-transparent-hover;
402-
}
404+
@include helpers.hover {
405+
background-color: colors.$db-current-color-bg-transparent-hover;
406+
}
403407

404-
&:active {
405-
background-color: colors.$db-current-color-bg-transparent-pressed;
406-
}
408+
@include helpers.active {
409+
background-color: colors.$db-current-color-bg-transparent-pressed;
407410
}
408411
}
409412

packages/components/src/styles/_link-components.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
%db-link-default-color {
1313
color: colors.$db-current-color-enabled;
1414

15-
&:hover {
15+
@include helpers.hover {
1616
color: color-mix(
1717
in srgb,
1818
transparent 25%,
1919
colors.$db-current-color-enabled
2020
);
2121
}
2222

23-
&:active {
23+
@include helpers.active {
2424
color: color-mix(
2525
in srgb,
2626
transparent 50%,

0 commit comments

Comments
 (0)