generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into react-components/select
- Loading branch information
Showing
39 changed files
with
2,158 additions
and
57 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,9 @@ | ||
--- | ||
"@lux-design-system/components-react": major | ||
--- | ||
|
||
In deze commit: | ||
|
||
- Nieuw component: Radio Button | ||
- Nieuw component: Form Field Radio Option | ||
- Nieuw component: Form Field Radio Group |
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,5 @@ | ||
--- | ||
"@lux-design-system/components-react": minor | ||
--- | ||
|
||
Nieuw component: Checkbox |
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,11 @@ | ||
--- | ||
"@lux-design-system/design-tokens": major | ||
--- | ||
|
||
In deze commit: | ||
|
||
- Gewijzigde tokens: | ||
- utrecht heading-1: color van `brand` naar `foreground`, font-weight van `bold` naar `regular` | ||
- utrecht heading-3: color van `brand` naar `foreground` | ||
|
||
**Let op:** visuele wijziging op alle thema's, H1 en H3 hebben nu een andere vormgeving. |
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,5 @@ | ||
--- | ||
"@lux-design-system/components-react": minor | ||
--- | ||
|
||
Nieuw component: Link |
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 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 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,27 @@ | ||
.lux-checkbox:checked:focus { | ||
border-color: var(--lux-checkbox-checked-focus-border-color); | ||
background-color: var(--lux-checkbox-checked-focus-background-color); | ||
color: var(--lux-checkbox-checked-focus-color); | ||
} | ||
|
||
.lux-checkbox:checked:hover { | ||
border-color: var(--lux-checkbox-checked-hover-border-color); | ||
background-color: var(--lux-checkbox-checked-hover-background-color); | ||
color: var(--lux-checkbox-checked-hover-color); | ||
} | ||
|
||
.lux-checkbox:checked:active { | ||
border-color: var(--lux-checkbox-checked-active-border-color); | ||
background-color: var(--lux-checkbox-checked-active-background-color); | ||
color: var(--lux-checkbox-checked-active-color); | ||
} | ||
|
||
.lux-checkbox:checked:disabled { | ||
border-color: var(--lux-checkbox-checked-disabled-border-color); | ||
background-color: var(--lux-checkbox-checked-disabled-background-color); | ||
color: var(--lux-checkbox-checked-disabled-color); | ||
} | ||
|
||
.lux-checkbox--disabled { | ||
cursor: not-allowed; | ||
} |
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,48 @@ | ||
import { | ||
Checkbox as UtrechtCheckbox, | ||
type CheckboxProps as UtrechtCheckboxProps, | ||
} from '@utrecht/component-library-react/dist/css-module'; | ||
import './Checkbox.css'; | ||
import clsx from 'clsx'; | ||
import { ForwardedRef, forwardRef, PropsWithChildren } from 'react'; | ||
|
||
export type LuxCheckboxProps = UtrechtCheckboxProps & { | ||
invalid?: boolean; | ||
name?: string; | ||
checked?: boolean; | ||
disabled?: boolean; | ||
className?: string; | ||
}; | ||
|
||
const CLASSNAME = { | ||
checkbox: 'lux-checkbox', | ||
disabled: 'lux-checkbox--disabled', | ||
}; | ||
|
||
export const LuxCheckbox = forwardRef( | ||
( | ||
{ disabled, className, name, checked, ...restProps }: PropsWithChildren<LuxCheckboxProps>, | ||
ref: ForwardedRef<HTMLInputElement>, | ||
) => { | ||
const combinedClassName = clsx( | ||
CLASSNAME.checkbox, | ||
{ | ||
[CLASSNAME.disabled]: disabled, | ||
}, | ||
className, | ||
); | ||
|
||
return ( | ||
<UtrechtCheckbox | ||
ref={ref} | ||
name={name} | ||
className={combinedClassName} | ||
checked={checked} | ||
disabled={disabled} | ||
{...restProps} | ||
/> | ||
); | ||
}, | ||
); | ||
|
||
LuxCheckbox.displayName = 'LuxCheckbox'; |
66 changes: 66 additions & 0 deletions
66
packages/components-react/src/checkbox/test/Checkbox.spec.tsx
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,66 @@ | ||
import { describe, expect, it } from '@jest/globals'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { LuxCheckbox } from '../Checkbox'; | ||
|
||
describe('Checkbox', () => { | ||
it('renders a checkbox', () => { | ||
render(<LuxCheckbox name="test-checkbox" />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders a checkbox with correct name attribute', () => { | ||
render(<LuxCheckbox name="test-checkbox" />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toHaveAttribute('name', 'test-checkbox'); | ||
}); | ||
|
||
it('renders a checked checkbox when checked prop is true', () => { | ||
render(<LuxCheckbox name="test-checkbox" checked={true} />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toBeChecked(); | ||
}); | ||
|
||
it('renders an unchecked checkbox when checked prop is false', () => { | ||
render(<LuxCheckbox name="test-checkbox" checked={false} />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).not.toBeChecked(); | ||
}); | ||
|
||
it('renders a disabled checkbox when disabled prop is true', () => { | ||
render(<LuxCheckbox name="test-checkbox" disabled={true} />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toBeDisabled(); | ||
expect(checkbox).toHaveClass('lux-checkbox--disabled'); | ||
}); | ||
|
||
it('applies custom className when provided', () => { | ||
const customClass = 'custom-checkbox'; | ||
render(<LuxCheckbox name="test-checkbox" className={customClass} />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toHaveClass(customClass); | ||
}); | ||
|
||
it('forwards additional props to the checkbox input', () => { | ||
render(<LuxCheckbox name="test-checkbox" data-testid="test-id" aria-label="test label" />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toHaveAttribute('data-testid', 'test-id'); | ||
expect(checkbox).toHaveAttribute('aria-label', 'test label'); | ||
}); | ||
|
||
it('combines multiple classes correctly', () => { | ||
render(<LuxCheckbox name="test-checkbox" className="custom-class" disabled={true} />); | ||
|
||
const checkbox = screen.getByRole('checkbox'); | ||
expect(checkbox).toHaveClass('lux-checkbox'); | ||
expect(checkbox).toHaveClass('lux-checkbox--disabled'); | ||
expect(checkbox).toHaveClass('custom-class'); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/components-react/src/form-field-radio-group/FormFieldRadioGroup.css
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,15 @@ | ||
.lux-radio-group { | ||
display: flex; | ||
row-gap: var(--lux-radio-group-row-gap); | ||
flex-direction: column; | ||
} | ||
|
||
.lux-radio-group__options { | ||
display: flex; | ||
row-gap: var(--lux-radio-group-row-gap); | ||
flex-direction: column; | ||
} | ||
|
||
.lux-radio-group__fieldset { | ||
border: 0; | ||
} |
Oops, something went wrong.