-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Radio+Checkbox): use input component (#2607)
- Loading branch information
1 parent
f96289a
commit 7520547
Showing
39 changed files
with
966 additions
and
1,966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@digdir/designsystemet-css": major | ||
"@digdir/designsystemet-react": major | ||
--- | ||
|
||
Radio + Checkbox: | ||
- Use `label` prop instead of `children` as label text | ||
- Remove `Radio.Group` and `Checkbox.Group` and use `Fieldset` instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,71 @@ | ||
.ds-field { | ||
display: contents; | ||
align-items: start; | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--ds-spacing-2); | ||
|
||
& > * + * { | ||
margin-top: var(--ds-spacing-2); | ||
@composes ds-body-text--md from './base/base.css'; | ||
|
||
&[data-size='sm'] { | ||
@composes ds-body-text--sm from './base/base.css'; | ||
} | ||
|
||
&[data-size='lg'] { | ||
@composes ds-body-text--lg from './base/base.css'; | ||
} | ||
|
||
& [data-field='description'] { | ||
color: var(--ds-color-neutral-text-subtle); /* TODO: Change to opacity or color-mix(currentColor, trasparent) to ensure contrast when parent element color changes? */ | ||
} | ||
|
||
/** | ||
* States | ||
*/ | ||
&:has([aria-disabled='true'], :disabled) > * { | ||
cursor: not-allowed; | ||
opacity: var(--ds-disabled-opacity); | ||
} | ||
|
||
&:has([aria-readonly='true'], [readonly]) label { | ||
--dsc-label--readonly: ; /* Activate lock icon for label when readonly */ | ||
} | ||
|
||
/** | ||
* Toggle inputs | ||
*/ | ||
&:has(input:is([type='radio'], [type='checkbox'])) { | ||
border-radius: var(--ds-border-radius-md); | ||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
row-gap: 0; | ||
width: fit-content; /* Rather do display: grid + width: fit-content than display: inline-grid to encourage stacked radios */ | ||
|
||
& > * { | ||
grid-column: 2; /* Only allow input in column 1 */ | ||
} | ||
|
||
& label { | ||
--dsc-label--readonly: initial; /* Never show lock icon on toggle inputs */ | ||
font-weight: var(--ds-font-weight-regular); | ||
} | ||
|
||
& input { | ||
grid-column: 1; /* Always place input in column 1 */ | ||
grid-row: 1; /* Always place input in row 1 */ | ||
outline: none; | ||
box-shadow: none; | ||
} | ||
|
||
&:not(:has([readonly], [aria-disabled='true'], :disabled)) label { | ||
cursor: pointer; | ||
} | ||
|
||
&:has(input:focus-visible) { | ||
@composes ds-focus--visible from './base/base.css'; | ||
} | ||
|
||
&:has(input:only-child) { | ||
gap: 0; /* No gap only <input> with aria-label/aria-labelledby */ | ||
} | ||
} | ||
} |
Oops, something went wrong.