-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Opetushallitus/OK-656
OK-656: OphCheckbox-komponentti
- Loading branch information
Showing
68 changed files
with
331 additions
and
41 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Binary file added
BIN
+5.83 KB
...ight/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.05 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.8 KB
...right/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked-focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.06 KB
...right/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked-hovered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.26 KB
...ight/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked-required.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.06 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.67 KB
...ight/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.85 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.41 KB
...right/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default-focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.84 KB
...right/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default-hovered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.06 KB
...ight/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default-required.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.68 KB
...napshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
...t/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.59 KB
...snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate-focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
...snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate-hovered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.05 KB
...napshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate-required.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--indeterminate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.35 KB
...napshots/stories.spec.ts-snapshots/oph--ophcheckbox--without-label-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.38 KB
...t/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--without-label-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.91 KB
...snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--without-label-focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.38 KB
...snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--without-label-hovered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.36 KB
playwright/snapshots/stories.spec.ts-snapshots/oph--ophcheckbox--without-label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--clearable-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--clearable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--default-focused.png
Oops, something went wrong.
Binary file modified
BIN
+3 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--default-open.png
Oops, something went wrong.
Binary file modified
BIN
+6 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--default.png
Oops, something went wrong.
Binary file modified
BIN
-5 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/oph--ophselect--disabled.png
Oops, something went wrong.
Binary file added
BIN
+5.83 KB
...pshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked-disabled.png
Oops, something went wrong.
Binary file added
BIN
+6.06 KB
...snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked-error.png
Oops, something went wrong.
Binary file added
BIN
+6.84 KB
...apshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked-focused.png
Oops, something went wrong.
Binary file added
BIN
+6.07 KB
...apshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked-hovered.png
Oops, something went wrong.
Binary file added
BIN
+6.26 KB
...pshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked-required.png
Oops, something went wrong.
Binary file added
BIN
+6.07 KB
...right/snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--checked.png
Oops, something went wrong.
Binary file added
BIN
+5.67 KB
...pshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default-disabled.png
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
...snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default-error.png
Oops, something went wrong.
Binary file added
BIN
+6.42 KB
...apshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default-focused.png
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
...apshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default-hovered.png
Oops, something went wrong.
Binary file added
BIN
+6.03 KB
...pshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default-required.png
Oops, something went wrong.
Binary file added
BIN
+5.84 KB
...right/snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--default.png
Oops, something went wrong.
Binary file added
BIN
+5.68 KB
.../stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate-disabled.png
Oops, something went wrong.
Binary file added
BIN
+5.87 KB
...ots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate-error.png
Oops, something went wrong.
Binary file added
BIN
+6.61 KB
...s/stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate-focused.png
Oops, something went wrong.
Binary file added
BIN
+5.87 KB
...s/stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate-hovered.png
Oops, something went wrong.
Binary file added
BIN
+6.06 KB
.../stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate-required.png
Oops, something went wrong.
Binary file added
BIN
+5.87 KB
...snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--indeterminate.png
Oops, something went wrong.
Binary file added
BIN
+4.35 KB
.../stories.spec.ts-snapshots/opintopolku--ophcheckbox--without-label-disabled.png
Oops, something went wrong.
Binary file added
BIN
+4.38 KB
...ots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--without-label-error.png
Oops, something went wrong.
Binary file added
BIN
+4.93 KB
...s/stories.spec.ts-snapshots/opintopolku--ophcheckbox--without-label-focused.png
Oops, something went wrong.
Binary file added
BIN
+4.39 KB
...s/stories.spec.ts-snapshots/opintopolku--ophcheckbox--without-label-hovered.png
Oops, something went wrong.
Binary file added
BIN
+4.36 KB
...snapshots/stories.spec.ts-snapshots/opintopolku--ophcheckbox--without-label.png
Oops, something went wrong.
Binary file modified
BIN
+9 Bytes
(100%)
.../snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--clearable-open.png
Oops, something went wrong.
Binary file modified
BIN
+9 Bytes
(100%)
...right/snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--clearable.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
...snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--default-focused.png
Oops, something went wrong.
Binary file modified
BIN
+6 Bytes
(100%)
...ht/snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--default-open.png
Oops, something went wrong.
Binary file modified
BIN
+9 Bytes
(100%)
playwright/snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--default.png
Oops, something went wrong.
Binary file modified
BIN
-12 Bytes
(100%)
...wright/snapshots/stories.spec.ts-snapshots/opintopolku--ophselect--disabled.png
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { within } from '@storybook/test'; | ||
import { OphCheckbox } from './OphCheckbox'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta = { | ||
component: OphCheckbox, | ||
} satisfies Meta<typeof OphCheckbox>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof OphCheckbox>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
label: 'Otsake', | ||
}, | ||
}; | ||
|
||
export const DefaultRequired: Story = { | ||
args: { ...Default.args, required: true }, | ||
}; | ||
|
||
export const DefaultHovered: Story = { | ||
args: Default.args, | ||
parameters: { | ||
pseudo: { hover: true }, | ||
}, | ||
}; | ||
|
||
export const DefaultFocused: Story = { | ||
args: Default.args, | ||
play: ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
const checkboxes = canvas.getAllByRole('checkbox'); | ||
for (const checkbox of checkboxes) { | ||
checkbox.focus(); | ||
} | ||
}, | ||
}; | ||
|
||
export const DefaultDisabled: Story = { | ||
args: { ...Default.args, disabled: true }, | ||
}; | ||
|
||
export const DefaultError: Story = { | ||
args: { ...Default.args, error: true }, | ||
}; | ||
|
||
export const Indeterminate: Story = { | ||
args: { ...Default.args, indeterminate: true }, | ||
}; | ||
|
||
export const IndeterminateRequired: Story = { | ||
args: { ...Indeterminate.args, required: true }, | ||
}; | ||
|
||
export const IndeterminateFocused: Story = { | ||
...DefaultFocused, | ||
args: Indeterminate.args, | ||
}; | ||
|
||
export const IndeterminateHovered: Story = { | ||
...DefaultHovered, | ||
args: Indeterminate.args, | ||
}; | ||
|
||
export const IndeterminateDisabled: Story = { | ||
args: { ...Indeterminate.args, disabled: true }, | ||
}; | ||
|
||
export const IndeterminateError: Story = { | ||
...Indeterminate, | ||
args: { ...Indeterminate.args, error: true }, | ||
}; | ||
|
||
export const Checked: Story = { | ||
args: { ...Default.args, checked: true }, | ||
}; | ||
|
||
export const CheckedRequired: Story = { | ||
args: { ...Checked.args, required: true }, | ||
}; | ||
|
||
export const CheckedFocused: Story = { | ||
...DefaultFocused, | ||
args: Checked.args, | ||
}; | ||
|
||
export const CheckedHovered: Story = { | ||
...DefaultHovered, | ||
args: Checked.args, | ||
}; | ||
|
||
export const CheckedDisabled: Story = { | ||
args: { ...Checked.args, disabled: true }, | ||
}; | ||
|
||
export const CheckedError: Story = { | ||
args: { ...Checked.args, error: true }, | ||
}; | ||
|
||
export const WithoutLabel: Story = { | ||
args: { | ||
...Default.args, | ||
label: undefined, | ||
inputProps: { 'aria-label': 'Otsake' }, | ||
}, | ||
}; | ||
|
||
export const WithoutLabelFocused: Story = { | ||
...DefaultFocused, | ||
args: WithoutLabel.args, | ||
}; | ||
|
||
export const WithoutLabelHovered: Story = { | ||
...DefaultHovered, | ||
args: WithoutLabel.args, | ||
}; | ||
|
||
export const WithoutLabelDisabled: Story = { | ||
...DefaultDisabled, | ||
args: { ...WithoutLabel.args, disabled: true }, | ||
}; | ||
|
||
export const WithoutLabelError: Story = { | ||
...DefaultError, | ||
args: { ...WithoutLabel.args, error: true }, | ||
}; |
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,44 @@ | ||
import { | ||
Checkbox, | ||
FormControlLabel, | ||
type CheckboxProps, | ||
type FormControlLabelProps, | ||
} from '@mui/material'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
export type OphCheckboxProps = Omit< | ||
CheckboxProps, | ||
| 'centerRipple' | ||
| 'checkedIcon' | ||
| 'disableRipple' | ||
| 'icon' | ||
| 'indeterminateIcon' | ||
| 'size' | ||
| 'LinkComponent' | ||
> & { | ||
formControlLabelProps?: Omit<FormControlLabelProps, 'label' | 'control'>; | ||
label?: React.ReactNode; | ||
error?: boolean; | ||
}; | ||
|
||
export const OphCheckbox = forwardRef<HTMLButtonElement, OphCheckboxProps>( | ||
function renderCheckbox( | ||
{ label, error, formControlLabelProps, ...props }, | ||
ref, | ||
) { | ||
const checkboxProps = { | ||
...props, | ||
color: error ? 'error' : props.color, | ||
ref, | ||
}; | ||
return label ? ( | ||
<FormControlLabel | ||
{...formControlLabelProps} | ||
label={label} | ||
control={<Checkbox {...checkboxProps} />} | ||
/> | ||
) : ( | ||
<Checkbox {...checkboxProps} /> | ||
); | ||
}, | ||
); |
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,6 +1,7 @@ | ||
export { OphButton } from './OphButton'; | ||
export { OphTypography } from './OphTypography'; | ||
export { OphCheckbox } from './OphCheckbox'; | ||
export { OphSelect } from './OphSelect'; | ||
export { OphTypography } from './OphTypography'; | ||
export { ophColors } from './colors'; | ||
|
||
export type { OphThemeParams, OphThemeVariant, OphLanguage } from './types'; |
Oops, something went wrong.