Skip to content

Commit 43a8379

Browse files
fix(ContentSwitcher): resolve text contrast violations (#8130)
* fix(content-switcher): set unselected background color * fix(content-switcher): add unselected switcher button borders * fix(theme-tokens): update content switcher divider token * fix(content-switcher): update switcher button hover color * fix(content-switcher): remove borders for middle selected switchers * fix(content-switcher): update disabled switcher button styles * fix(content-switcher): update disabled switcher styles * refactor(content-switcher): remove unused styles * fix(content-switcher): update divider token per new spec * docs(ContentSwitcher): mark `light` prop for deprecation * refactor(content-switcher): remove redundant light variant styles * chore: update snapshots Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent e928b91 commit 43a8379

File tree

4 files changed

+38
-40
lines changed

4 files changed

+38
-40
lines changed

packages/components/src/components/content-switcher/_content-switcher.scss

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
height: rem(48px);
3131
}
3232

33-
.#{$prefix}--content-switcher--disabled {
34-
cursor: not-allowed;
35-
}
36-
3733
.#{$prefix}--content-switcher-btn {
3834
@include reset;
3935
@include type-style('body-short-01');
@@ -50,8 +46,10 @@
5046
white-space: nowrap;
5147
text-align: left;
5248
text-decoration: none;
53-
background-color: $ui-01;
49+
background-color: transparent;
5450
border: none;
51+
border-top: rem(1px) solid $ui-05;
52+
border-bottom: rem(1px) solid $ui-05;
5553
transition: all $duration--fast-01 motion(standard, productive);
5654

5755
&:focus {
@@ -66,6 +64,7 @@
6664
}
6765

6866
&:hover {
67+
color: $text-01;
6968
cursor: pointer;
7069
}
7170

@@ -78,33 +77,38 @@
7877

7978
&:disabled {
8079
color: $disabled-02;
81-
background-color: $disabled-01;
82-
pointer-events: none;
80+
background-color: transparent;
81+
border-color: $disabled-02;
8382

8483
&:hover {
8584
cursor: not-allowed;
8685
}
8786
}
88-
}
89-
90-
.#{$prefix}--content-switcher--light .#{$prefix}--content-switcher-btn {
91-
background-color: $ui-02;
9287

93-
&:hover {
94-
background-color: $hover-light-ui;
88+
&:disabled:first-child,
89+
&:disabled:last-child {
90+
border-color: $disabled-02;
9591
}
9692
}
9793

9894
.#{$prefix}--content-switcher-btn:first-child {
95+
border-left: rem(1px) solid $ui-05;
9996
border-top-left-radius: rem(4px);
10097
border-bottom-left-radius: rem(4px);
10198
}
10299

103100
.#{$prefix}--content-switcher-btn:last-child {
101+
border-right: rem(1px) solid $ui-05;
104102
border-top-right-radius: rem(4px);
105103
border-bottom-right-radius: rem(4px);
106104
}
107105

106+
.#{$prefix}--content-switcher--selected,
107+
.#{$prefix}--content-switcher--selected:first-child,
108+
.#{$prefix}--content-switcher--selected:last-child {
109+
border: 0;
110+
}
111+
108112
.#{$prefix}--content-switcher-btn::before {
109113
position: absolute;
110114
left: 0;
@@ -120,26 +124,6 @@
120124
display: none;
121125
}
122126

123-
.#{$prefix}--content-switcher--light
124-
.#{$prefix}--content-switcher-btn::before {
125-
background-color: $decorative-01;
126-
}
127-
128-
.#{$prefix}--content-switcher--light
129-
.#{$prefix}--content-switcher-btn:focus::before,
130-
.#{$prefix}--content-switcher--light
131-
.#{$prefix}--content-switcher-btn:focus
132-
+ .#{$prefix}--content-switcher-btn::before,
133-
.#{$prefix}--content-switcher--light
134-
.#{$prefix}--content-switcher-btn:hover::before,
135-
.#{$prefix}--content-switcher--light
136-
.#{$prefix}--content-switcher-btn:hover
137-
+ .#{$prefix}--content-switcher-btn::before,
138-
.#{$prefix}--content-switcher--light
139-
.#{$prefix}--content-switcher--selected::before,
140-
.#{$prefix}--content-switcher--light
141-
.#{$prefix}--content-switcher--selected
142-
+ .#{$prefix}--content-switcher-btn::before,
143127
.#{$prefix}--content-switcher-btn:focus::before,
144128
.#{$prefix}--content-switcher-btn:focus
145129
+ .#{$prefix}--content-switcher-btn::before,
@@ -152,6 +136,19 @@
152136
background-color: transparent;
153137
}
154138

139+
.#{$prefix}--content-switcher-btn:disabled::before,
140+
.#{$prefix}--content-switcher-btn:disabled:hover
141+
+ .#{$prefix}--content-switcher-btn:disabled::before {
142+
background-color: $disabled-02;
143+
}
144+
145+
.#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected:disabled
146+
+ .#{$prefix}--content-switcher-btn::before,
147+
.#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected:disabled:hover
148+
+ .#{$prefix}--content-switcher-btn::before {
149+
background-color: transparent;
150+
}
151+
155152
.#{$prefix}--content-switcher__icon {
156153
transition: fill $duration--fast-01 motion(standard, productive);
157154
fill: $text-02;
@@ -173,8 +170,6 @@
173170
fill: $text-01;
174171
}
175172

176-
.#{$prefix}--content-switcher--light
177-
.#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected,
178173
.#{$prefix}--content-switcher-btn.#{$prefix}--content-switcher--selected {
179174
z-index: 3;
180175
color: $inverse-01;

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,7 @@ Map {
854854
"className": Object {
855855
"type": "string",
856856
},
857-
"light": Object {
858-
"type": "bool",
859-
},
857+
"light": [Function],
860858
"onChange": Object {
861859
"isRequired": true,
862860
"type": "func",

packages/react/src/components/ContentSwitcher/ContentSwitcher-story.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const sizes = {
2525

2626
const props = {
2727
contentSwitcher: () => ({
28-
light: boolean('Light variant (light)', false),
28+
light: boolean('[Deprecated]: Light variant (light)', false),
2929
selectedIndex: select('Selected index (selectedIndex)', [0, 1, 2], 0),
3030
selectionMode: select(
3131
'Selection mode (selectionMode)',

packages/react/src/components/ContentSwitcher/ContentSwitcher.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import classNames from 'classnames';
1111
import { settings } from 'carbon-components';
1212
import { composeEventHandlers } from '../../tools/events';
1313
import { getNextIndex, matches, keys } from '../../internal/keyboard';
14+
import deprecate from '../../prop-types/deprecate';
1415

1516
const { prefix } = settings;
1617

@@ -38,7 +39,11 @@ export default class ContentSwitcher extends React.Component {
3839
/**
3940
* `true` to use the light variant.
4041
*/
41-
light: PropTypes.bool,
42+
light: deprecate(
43+
PropTypes.bool,
44+
'The `light` prop for `ContentSwitcher` is no longer needed and has ' +
45+
'been deprecated. It will be removed in the next major release.'
46+
),
4247

4348
/**
4449
* Specify an `onChange` handler that is called whenever the ContentSwitcher

0 commit comments

Comments
 (0)