-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
part of #2444 This does not include the `invalid` prop mentioned, and does not rename CSS vars, as this will be done in separate PRs
- Loading branch information
Showing
17 changed files
with
94 additions
and
79 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,5 @@ | ||
--- | ||
"@digdir/designsystemet-css": patch | ||
--- | ||
|
||
Rename classes from `ds-error-message*` to `ds-validation-message*` |
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 @@ | ||
--- | ||
"@digdir/designsystemet-react": patch | ||
--- | ||
|
||
Rename `ErrorMessage` to `ValidationMessage` |
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
47 changes: 0 additions & 47 deletions
47
packages/react/src/components/Typography/ErrorMessage/ErrorMessage.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
10 changes: 5 additions & 5 deletions
10
...phy/ErrorMessage/ErrorMessage.stories.tsx → ...tionMessage/ValidationMessage.stories.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
46 changes: 46 additions & 0 deletions
46
packages/react/src/components/Typography/ValidationMessage/ValidationMessage.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,46 @@ | ||
import { Slot } from '@radix-ui/react-slot'; | ||
import cl from 'clsx/lite'; | ||
import type { HTMLAttributes } from 'react'; | ||
import { forwardRef } from 'react'; | ||
|
||
export type ValidationMessageProps = { | ||
/** | ||
* Changes text sizing | ||
* @default md | ||
*/ | ||
size?: 'xs' | 'sm' | 'md' | 'lg'; | ||
/** Adds margin-bottom */ | ||
spacing?: boolean; | ||
/** Toggle error color */ | ||
error?: boolean; | ||
/** | ||
* Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
* @default false | ||
*/ | ||
asChild?: boolean; | ||
} & HTMLAttributes<HTMLParagraphElement>; | ||
|
||
/** Use `ValidationMessage` to display validation text */ | ||
export const ValidationMessage = forwardRef< | ||
HTMLParagraphElement, | ||
ValidationMessageProps | ||
>(function ValidationMessage( | ||
{ size = 'md', className, spacing, asChild, error = true, ...rest }, | ||
ref, | ||
) { | ||
const Component = asChild ? Slot : 'div'; | ||
|
||
return ( | ||
<Component | ||
ref={ref} | ||
className={cl( | ||
'ds-validation-message', | ||
`ds-error_message--${size}`, | ||
spacing && 'ds-validation-message--spacing', | ||
error && 'ds-validation-message--error', | ||
className, | ||
)} | ||
{...rest} | ||
/> | ||
); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/react/src/components/Typography/ValidationMessage/index.ts
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 @@ | ||
export * from './ValidationMessage'; |
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
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
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