Skip to content

Commit

Permalink
Merge pull request #1228 from City-of-Helsinki/HDS-2142-checkbox-no-l…
Browse files Browse the repository at this point in the history
…abel-layout-fix

(HDS-2142) fix checkbox layout issue
  • Loading branch information
mrTuomoK authored Feb 23, 2024
2 parents d356f3e + 6570b7f commit 7cbae42
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Changes that are not related to specific components

- Removed old & deprecated individual `lodash` dependencies and replaced with the full package and importing the needed functions only.
- [HeaderActionBarItemWithDropdown] Removed useless `@layer` css style which caused Jest/jsdom tests output errors.
- [Checkbox] Layout issue when using external label with htmlLabelFor-attribute

### Core

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/checkbox/checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}

.hds-checkbox .hds-checkbox__label--hidden {
padding-left: 0;
padding-left: var(--size);
}

/* ERROR */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/react/src/components/checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ export const GroupWithParent = () => {

GroupWithParent.storyName = 'Group with a parent';

export const WithExternalLabel = () => {
const customStyle = {
'--background-unselected': 'teal',
'margin-right': 'var(--spacing-2-xs)',
} as React.CSSProperties;

return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<Checkbox id="withExternalLabel" style={customStyle} />
<label htmlFor="withExternalLabel">
<h3>External label</h3>
</label>
</div>
);
};

export const Playground = (args) => {
const [checkedItems, setCheckedItems] = useState({});
const options = ['Option 1', 'Option 2', 'Option 3'];
Expand Down

0 comments on commit 7cbae42

Please sign in to comment.