Skip to content

Commit

Permalink
checkbox and switch css fixes for high contrast mode (#2317)
Browse files Browse the repository at this point in the history
fix: checkbox and switch CSS fixes for high contrast mode
  • Loading branch information
tshimber authored Aug 29, 2024
1 parent 0b21978 commit 318df56
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/components/src/components/checkbox/checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ scale-checkbox.indeterminate [part='checkbox'] {
border: none;
color: var(--color-icon-checked-active);
}

@media screen and (forced-colors: active), (-ms-high-contrast: active) {
scale-checkbox.indeterminate [part='checkbox'] {
border: 1px solid;
}
}

scale-checkbox.indeterminate [part='icon'] {
color: var(--color-icon-checked-active);
}
Expand Down Expand Up @@ -256,6 +263,12 @@ scale-checkbox.error [part='checkbox'] {
border: none;
}

@media screen and (forced-colors: active), (-ms-high-contrast: active) {
scale-checkbox.error [part='checkbox'] {
border: 1px solid;
}
}

scale-checkbox.error
[part='input']:focus
~ [part='container']
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/switch/switch.css
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ scale-switch scale-icon-action-success {
.switch__toggle {
border: 1px solid;
}
scale-icon-action-checkmark {
scale-switch scale-icon-action-checkmark {
visibility: hidden !important;
}
}
50 changes: 50 additions & 0 deletions packages/components/src/html/checkbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"
/>
<title>Stencil Component Starter</title>

<script type="module" src="/build/scale-components.esm.js"></script>
<link rel="stylesheet" href="/build/scale-components.css" />
<style type="text/css" media="screen, print">
html {
margin: 0;
padding: 0;
}

body {
margin: 0;
padding: 4rem;
}
</style>
</head>

<body>
<p>
<scale-checkbox
checked
disabled
label="Selected Disabled"
></scale-checkbox>
</p>
<p>
<scale-checkbox indeterminate label="Indeterminate"></scale-checkbox>
</p>
<p>
<scale-checkbox
label="Standard with error"
helper-text="This is the error message"
invalid
></scale-checkbox>
</p>
<p>
<scale-switch
label="My styles were affecting checkbox styles"
></scale-switch>
</p>
</body>
</html>

0 comments on commit 318df56

Please sign in to comment.