Skip to content

Commit

Permalink
Merge branch 'main' into react-components/select
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSkippy authored Nov 26, 2024
2 parents 3f2d856 + 3f11d69 commit a77e675
Show file tree
Hide file tree
Showing 39 changed files with 2,158 additions and 57 deletions.
9 changes: 9 additions & 0 deletions .changeset/mean-books-sleep.md
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
5 changes: 5 additions & 0 deletions .changeset/rude-fishes-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lux-design-system/components-react": minor
---

Nieuw component: Checkbox
11 changes: 11 additions & 0 deletions .changeset/ten-avocados-agree.md
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.
5 changes: 5 additions & 0 deletions .changeset/weak-weeks-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lux-design-system/components-react": minor
---

Nieuw component: Link
8 changes: 4 additions & 4 deletions .lux.stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
}
],
"order/properties-alphabetical-order": null,
"scss/dollar-variable-pattern": "^(lux)-[a-z0-9-]+$",
"scss/percent-placeholder-pattern": "^(lux)-[a-z0-9-]+$",
"scss/dollar-variable-pattern": "^(lux|utrecht)-[a-z0-9-]+$",
"scss/percent-placeholder-pattern": "^(lux|utrecht)-[a-z0-9-]+$",
"custom-property-pattern": "^_?(lux|utrecht)-[a-z0-9-]+$",
"selector-class-pattern": "^(lux)-[a-z0-9_-]+|(force-state)--[a-z]+$",
"keyframes-name-pattern": "^(lux)-[a-z0-9-]+$"
"selector-class-pattern": "^(lux|utrecht)-[a-z0-9_-]+|(force-state)--[a-z]+$",
"keyframes-name-pattern": "^(lux|utrecht)-[a-z0-9-]+$"
}
}
81 changes: 73 additions & 8 deletions packages/components-react/src/alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,88 @@ export interface LuxAlertProps extends Omit<UtrechtAlertProps, 'type'> {

//TODO replace icons in #308
const InfoIcon = () => (
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg">
<circle r="7" cx="8" cy="8" fill="transparent" stroke="var(--utrecht-alert-icon-info-color)" />
<svg
style={{
width: 'var(--lux-alert-icon-size)',
height: 'var(--lux-alert-icon-size)',
}}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
className="lux-icon"
d="M22.04 3.78C21.88 2.83 21.16 2.11 20.21 1.95C17.48 1.5 12.91 1.5 12 1.5C11.09 1.5 6.52 1.5 3.78 1.96C2.84 2.11 2.11 2.84 1.96 3.78C1.5 6.52 1.5 11.09 1.5 12C1.5 12.91 1.5 17.48 1.96 20.22C2.12 21.17 2.84 21.89 3.79 22.05C6.53 22.51 11.09 22.51 12.01 22.51C12.92 22.51 17.49 22.51 20.23 22.05C21.18 21.89 21.9 21.17 22.06 20.22C22.52 17.48 22.52 12.92 22.52 12C22.5 9.26 22.5 6.52 22.04 3.78Z"
style={{ fill: 'var(--lux-icon-primary-color, #007BC7)' }}
/>
<path
className="lux-icon"
fill-rule="evenodd"
clip-rule="evenodd"
d="M11.04 6.05C10.82 6.3 10.71 6.59 10.71 6.93C10.71 7.28 10.82 7.57 11.04 7.81C11.27 8.04 11.58 8.16 11.99 8.16C12.39 8.16 12.71 8.04 12.93 7.79C13.15 7.54 13.26 7.25 13.26 6.93C13.26 6.57 13.15 6.27 12.93 6.03C12.71 5.79 12.4 5.67 11.99 5.67C11.58 5.67 11.26 5.8 11.04 6.05ZM13.11 18.28V9.32L10.9 9.41V18.28H13.11Z"
style={{ fill: 'var(--lux-icon-secondary-color, white)' }}
/>
</svg>
);
const SuccessIcon = () => (
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg">
<circle r="7" cx="8" cy="8" fill="transparent" stroke="var(--utrecht-alert-icon-ok-color)" />
<svg
style={{
width: 'var(--lux-alert-icon-size)',
height: 'var(--lux-alert-icon-size)',
}}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
className="lux-icon"
d="M22.04 3.78C21.88 2.83 21.16 2.11 20.21 1.95C17.48 1.5 12.91 1.5 12 1.5C11.09 1.5 6.52 1.5 3.78 1.96C2.83 2.11 2.11 2.83 1.96 3.78C1.5 6.52 1.5 11.09 1.5 12C1.5 12.91 1.5 17.48 1.96 20.22C2.12 21.17 2.84 21.89 3.79 22.05C6.53 22.51 11.09 22.51 12.01 22.51C12.92 22.51 17.49 22.51 20.23 22.05C21.18 21.89 21.9 21.17 22.06 20.22C22.52 17.48 22.52 12.92 22.52 12C22.5 9.26 22.5 6.52 22.04 3.78Z"
style={{ fill: 'var(--lux-icon-primary-color, #39870C)' }}
/>
<path
className="lux-icon"
d="M16.5 7.35C16.19 7.12 15.75 7.16 15.49 7.45L11.09 12.4L8.44002 10.1C8.16002 9.86 7.75002 9.86 7.47002 10.1C7.19002 10.34 7.12002 10.75 7.31002 11.07L10.51 16.45C10.65 16.68 10.89 16.82 11.15 16.82C11.41 16.82 11.66 16.68 11.79 16.46L16.68 8.37C16.89 8.02 16.81 7.59 16.5 7.35Z"
style={{ fill: 'var(--lux-icon-secondary-color, white)' }}
/>
</svg>
);
const WarningIcon = () => (
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg">
<circle r="7" cx="8" cy="8" fill="transparent" stroke="var(--utrecht-alert-icon-warning-color)" />
<svg
style={{
width: 'var(--lux-alert-icon-size)',
height: 'var(--lux-alert-icon-size)',
}}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M23.38 19.64L13.67 2.47C12.94 1.17 11.07 1.17 10.33 2.47L0.620021 19.64C-0.0999792 20.92 0.820021 22.5 2.29002 22.5H21.72C23.18 22.5 24.1 20.92 23.38 19.64Z"
style={{ fill: 'var(--lux-icon-primary-color, #FFB612)' }}
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M13.33 6.98L10.85 7.18H10.84V15.17L13.11 15.12V12.49L13.33 6.98ZM10.9 16.33C10.66 16.63 10.54 17.01 10.54 17.45C10.54 17.96 10.67 18.34 10.92 18.59C11.17 18.85 11.54 18.98 12.02 18.98C12.51 18.98 12.87 18.83 13.11 18.54C13.35 18.25 13.47 17.88 13.47 17.45C13.47 16.93 13.34 16.54 13.09 16.27C12.84 16.01 12.47 15.87 11.99 15.87C11.5 15.87 11.14 16.02 10.9 16.33Z"
style={{ fill: 'var(--lux-icon-secondary-color, black)' }}
/>
</svg>
);
const ErrorIcon = () => (
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg">
<circle r="7" cx="8" cy="8" fill="transparent" stroke="var(--utrecht-alert-icon-error-color)" />
<svg
style={{
width: 'var(--lux-alert-icon-size)',
height: 'var(--lux-alert-icon-size)',
}}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="12" cy="12" r="10.5" style={{ fill: 'var(--_lux-icon-primary-color, #D52B1E)' }} />
<path
d="M15.12 7.71L12 10.48L8.88 7.71C8.55 7.42 8.05 7.43 7.73 7.73C7.43 8.05 7.42 8.54 7.71 8.87L10.48 12L7.71 15.12C7.42 15.45 7.42 15.95 7.73 16.26C8.05 16.56 8.54 16.57 8.87 16.28L12 13.52L15.12 16.29C15.45 16.58 15.95 16.57 16.26 16.27C16.56 15.95 16.57 15.46 16.28 15.13L13.52 12L16.29 8.88C16.58 8.55 16.58 8.05 16.27 7.74C15.95 7.43 15.45 7.42 15.12 7.71Z"
style={{ fill: 'var(--lux-icon-secondary-color, white)' }}
/>
</svg>
);

Expand Down
27 changes: 27 additions & 0 deletions packages/components-react/src/checkbox/Checkbox.css
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;
}
48 changes: 48 additions & 0 deletions packages/components-react/src/checkbox/Checkbox.tsx
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 packages/components-react/src/checkbox/test/Checkbox.spec.tsx
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');
});
});
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;
}
Loading

0 comments on commit a77e675

Please sign in to comment.