diff --git a/packages/css/src/components/field/field.scss b/packages/css/src/components/field/field.scss index 6218c05077..681d1f88ee 100644 --- a/packages/css/src/components/field/field.scss +++ b/packages/css/src/components/field/field.scss @@ -10,7 +10,7 @@ gap: var(--ams-field-gap); } -.ams-field--has-error { - border-inline-start: var(--ams-field-has-error-border-inline-start); - padding-inline-start: var(--ams-field-has-error-padding-inline-start); +.ams-field--invalid { + border-inline-start: var(--ams-field-invalid-border-inline-start); + padding-inline-start: var(--ams-field-invalid-padding-inline-start); } diff --git a/packages/react/src/Field/Field.test.tsx b/packages/react/src/Field/Field.test.tsx index 7d8b175498..a2a5cf7577 100644 --- a/packages/react/src/Field/Field.test.tsx +++ b/packages/react/src/Field/Field.test.tsx @@ -27,10 +27,10 @@ describe('Field', () => { }) it('renders with the error class', () => { - const { container } = render() + const { container } = render() const component = container.querySelector(':only-child') - expect(component).toHaveClass('ams-field--has-error') + expect(component).toHaveClass('ams-field--invalid') }) it('supports ForwardRef in React', () => { diff --git a/packages/react/src/Field/Field.tsx b/packages/react/src/Field/Field.tsx index d9c5d011f8..e8404fbf10 100644 --- a/packages/react/src/Field/Field.tsx +++ b/packages/react/src/Field/Field.tsx @@ -9,12 +9,12 @@ import type { ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react' export type FieldProps = { /** Whether the field has an input with a validation error */ - hasError?: boolean + invalid?: boolean } & PropsWithChildren> export const Field = forwardRef( - ({ children, className, hasError, ...restProps }: FieldProps, ref: ForwardedRef) => ( -
+ ({ children, className, invalid, ...restProps }: FieldProps, ref: ForwardedRef) => ( +
{children}
), diff --git a/proprietary/tokens/src/components/ams/field.tokens.json b/proprietary/tokens/src/components/ams/field.tokens.json index 82178f5485..e76480abcc 100644 --- a/proprietary/tokens/src/components/ams/field.tokens.json +++ b/proprietary/tokens/src/components/ams/field.tokens.json @@ -4,7 +4,7 @@ "gap": { "value": "{ams.space.stack.sm}" }, - "has-error": { + "invalid": { "border-inline-start": { "value": "3px solid {ams.color.primary-red}" }, diff --git a/storybook/src/components/Field/Field.stories.tsx b/storybook/src/components/Field/Field.stories.tsx index 50c37782cf..1eb2bb8480 100644 --- a/storybook/src/components/Field/Field.stories.tsx +++ b/storybook/src/components/Field/Field.stories.tsx @@ -11,15 +11,15 @@ const meta = { title: 'Components/Forms/Field', component: Field, args: { - hasError: false, + invalid: false, }, render: (args) => ( - + Typ geen persoonsgegevens in deze omschrijving. We vragen dit later in dit formulier aan u. - + ), } satisfies Meta @@ -31,14 +31,14 @@ type Story = StoryObj export const Default: Story = {} export const WithError: Story = { - args: { hasError: true }, + args: { invalid: true }, render: (args) => ( - + Typ geen persoonsgegevens in deze omschrijving. We vragen dit later in dit formulier aan u. - + ), }