Skip to content
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

Fix Checkbox, Radio outline with text #1046

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions packages/spindle-ui/src/Form/Checkbox.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Checkbox
*/
:root {
--Checkbox-backGroundColor: var(--color-surface-primary);
}

.spui-Checkbox-label {
align-items: center;
border-radius: 2px;
Expand All @@ -12,6 +16,19 @@
position: relative;
}

/* Outline with text */
.spui-Checkbox-label:focus-within:has(.spui-Checkbox-text:not(:empty)) {
box-shadow:
0 0 0 2px var(--Checkbox-backGroundColor),
0 0 0 4px var(--color-focus-clarity);
}

.spui-Checkbox-label:focus-within:has(
.spui-Checkbox-input:not(:focus-visible)
) {
box-shadow: none;
}

.spui-Checkbox-input {
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
Expand Down Expand Up @@ -56,12 +73,18 @@
width: 22px;
}

/* box-shadow is used to apply border-radius as outline */
.spui-Checkbox-input:focus ~ .spui-Checkbox-outline {
/* Outline without text */
.spui-Checkbox-label:has(:not(.spui-Checkbox-text))
.spui-Checkbox-input:focus-visible
~ .spui-Checkbox-outline {
box-shadow: 0 0 0 2px var(--color-focus-clarity);
}

.spui-Checkbox-input:focus:not(:focus-visible) ~ .spui-Checkbox-outline {
.spui-Checkbox-label:has(.spui-Checkbox-text):has(
:not(.spui-Checkbox-text:empty)
)
.spui-Checkbox-input:focus-visible
~ .spui-Checkbox-outline {
box-shadow: none;
}

Expand Down
25 changes: 22 additions & 3 deletions packages/spindle-ui/src/Form/Radio.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Radio
*/
:root {
--Radio-backGroundColor: var(--color-surface-primary);
}

.spui-Radio-label {
align-items: center;
border-radius: 2px;
Expand All @@ -12,6 +16,17 @@
position: relative;
}

/* Outline with text */
.spui-Radio-label:focus-within:has(.spui-Radio-text:not(:empty)) {
box-shadow:
0 0 0 2px var(--Radio-backGroundColor),
0 0 0 4px var(--color-focus-clarity);
}

.spui-Radio-label:focus-within:has(.spui-Radio-input:not(:focus-visible)) {
box-shadow: none;
}

.spui-Radio-input {
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
Expand Down Expand Up @@ -58,12 +73,16 @@
width: 24px;
}

/* box-shadow is used to apply border-radius as outline */
.spui-Radio-input:focus ~ .spui-Radio-outline {
/* Outline without text */
.spui-Radio-label:has(:not(.spui-Radio-text))
.spui-Radio-input:focus-visible
~ .spui-Radio-outline {
box-shadow: 0 0 0 2px var(--color-focus-clarity);
}

.spui-Radio-input:focus:not(:focus-visible) ~ .spui-Radio-outline {
.spui-Radio-label:has(.spui-Radio-text):has(:not(.spui-Radio-text:empty))
.spui-Radio-input:focus-visible
~ .spui-Radio-outline {
box-shadow: none;
}

Expand Down
Loading