-
Notifications
You must be signed in to change notification settings - Fork 80
feat(switch): enhance component's colors for a11y and usability #11951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(switch): enhance component's colors for a11y and usability #11951
Conversation
…ciado88/10483-switch-enhance-component-colors-for-a11y-and-usability
@ashetland @SkyeSeitz Can you please take a look? |
Updates look great! ✨ |
@@ -4,11 +4,12 @@ | |||
* These properties can be overridden using the component's tag as selector. | |||
* | |||
* @prop --calcite-switch-background-color: Specifies the component's background color. | |||
* @prop --calcite-switch-border-color: Specifies the component's border color. | |||
* @prop --calcite-switch-background-color-hover: Specifies the component's background color when hovered or pressed. | |||
* @prop --calcite-switch-border-color: [Deprecated] Specifies the component's border color. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we specify any deprecation reasoning or what they should use instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have other similar references across our CSS doc, but since the border is no longer applicable, maybe we could go with:
* @prop --calcite-switch-border-color: [Deprecated] Specifies the component's border color. | |
* @prop --calcite-switch-border-color: [Deprecated] No longer necessary. Specifies the component's border color. |
cc @DitwanP
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand)); | ||
box-shadow: var(--calcite-switch-handle-shadow, inset 0 0 0 1px var(--calcite-color-brand)); | ||
border-color: var(--calcite-switch-handle-border-color); | ||
box-shadow: var(--calcite-switch-handle-shadow, inset 0 0 0 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to set box-shadow here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this, thanks for catching it!
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand-hover)); | ||
box-shadow: var(--calcite-switch-handle-shadow, inset 0 0 0 1px var(--calcite-color-brand-hover)); | ||
border-color: var(--calcite-switch-handle-border-color); | ||
box-shadow: var(--calcite-switch-handle-shadow, inset 0 0 0 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to set box-shadow here?
…ciado88/10483-switch-enhance-component-colors-for-a11y-and-usability
transition-all | ||
duration-150 | ||
ease-in-out; | ||
inset-block-start: -1px; | ||
inset-inline: -1px theme("inset.auto"); | ||
inset-block-start: 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a platform design token that can be used here? Maybe a border width one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this to use --calcite-border-width-md
inset-block-start: -1px; | ||
inset-inline: -1px theme("inset.auto"); | ||
inset-block-start: 2px; | ||
inset-inline: 2px theme("inset.auto"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the theme()
be replaced with a css var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a css var with auto
as a value, but I replaced theme("inset.auto")
with just "auto"
.
background-color: var(--calcite-switch-background-color, var(--calcite-color-brand)); | ||
} | ||
.handle { | ||
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand)); | ||
inset-inline: theme("inset.auto") -1px; | ||
inset-inline: theme("inset.auto") 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a platform design token that can be used here? Maybe a border width one? can the theme() be replaced with a css var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think theme("inset.auto")
can just be replaced with auto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the inset-inline could be calc(var(--calcite-spacing-base) * -1)
background-color: var(--calcite-switch-background-color, var(--calcite-color-brand)); | ||
} | ||
.handle { | ||
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand)); | ||
inset-inline: theme("inset.auto") -1px; | ||
inset-inline: theme("inset.auto") 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think theme("inset.auto")
can just be replaced with auto
background-color: var(--calcite-switch-background-color, var(--calcite-color-brand)); | ||
} | ||
.handle { | ||
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand)); | ||
inset-inline: theme("inset.auto") -1px; | ||
inset-inline: theme("inset.auto") 2px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the inset-inline could be calc(var(--calcite-spacing-base) * -1)
transition-all | ||
duration-150 | ||
ease-in-out; | ||
inset-block-start: -1px; | ||
inset-inline: -1px theme("inset.auto"); | ||
inset-block-start: var(--calcite-border-width-md); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aPreciado88 this should be a negative value right? Also, I think a spacing value is better since its not a border.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a positive value now, since we removed the border. I'm updating this to inset-block-start: var(--calcite-spacing-base);
background-color: var(--calcite-switch-background-color, var(--calcite-color-brand)); | ||
} | ||
.handle { | ||
border-color: var(--calcite-switch-handle-border-color, var(--calcite-color-brand)); | ||
inset-inline: theme("inset.auto") -1px; | ||
inset-inline: auto var(--calcite-border-width-md); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aPreciado88 this should be a negative value right? Also, I think a spacing value is better since its not a border.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need a positive value here, since the border is now gone. I'm updating this to inset-inline: auto var(--calcite-spacing-base);
…ciado88/10483-switch-enhance-component-colors-for-a11y-and-usability
@@ -151,9 +151,10 @@ describe("calcite-switch", () => { | |||
shadowSelector: `.${CSS.track}`, | |||
targetProp: "backgroundColor", | |||
}, | |||
"--calcite-switch-border-color": { | |||
"--calcite-switch-background-color-hover": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this var to the switch custom theme story tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this, thanks for catching it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
inset-block-start: -1px; | ||
inset-inline: -1px theme("inset.auto"); | ||
inset-block-start: var(--calcite-spacing-base); | ||
inset-inline: var(--calcite-border-width-md) auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this should be using a border var and not a spacing one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I missed this. Updating it now!
…gis-deps * origin/dev: (31 commits) chore: add workflow manager to team issue templates (#11971) chore: release next feat(accordion-item): enhance component's interactivity states (#11935) chore: release next build(deps): update dependency lerna to v8.2.2 (#11948) feat(switch): enhance component's colors for a11y and usability (#11951) chore: release next ci: remove redundant test mode environment variable (#11958) fix(input-date-picker): allow clearing invalid date value (#11937) build: update browserslist db (#11946) feat(notice): add token for close icon and title text color (#11938) fix(list, block-group): fix drag handle events when lists or blocks are nested (#11816) chore: release next build(deps): update dependency vite to v5.4.18 (#11949) ci: default to stable tests when experimental mode is not set (#11957) fix(input-number): cancel arrow down event (#11956) refactor: tidy up (#11945) docs(checkbox): update icon color prop context (#11950) build(deps): bump node minor version (#11927) chore: release next ...
Related Issue: #10483
Summary