Skip to content

Commit

Permalink
feat(ErrorMessage): ✨ Add new option to toggle error color (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz authored and Magnusrm committed Sep 27, 2023
1 parent e7d1bf2 commit 7d16bd9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
--fdsc-bottom-spacing: var(--fds-spacing-5);

margin: 0;
}

.errorMessage.error {
color: var(--fds-semantic-text-danger-default);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export const Preview: Story = {
children: 'Dette er en beskrivende feilmelding.',
spacing: false,
size: 'medium',
error: 'true',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export type ErrorMessageProps = {
size?: 'xsmall' | 'small' | 'medium';
/** Adds margin-bottom */
spacing?: boolean;
/** Toggle error color */
error?: boolean;
} & HTMLAttributes<HTMLParagraphElement>;

/** Use `ErrorMessage` to display text as error message. */
Expand All @@ -19,7 +21,14 @@ export const ErrorMessage: OverridableComponent<
HTMLParagraphElement
> = forwardRef(
(
{ className, size = 'medium', spacing, as: Component = 'p', ...rest },
{
className,
size = 'medium',
spacing,
as: Component = 'p',
error = true,
...rest
},
ref,
) => (
<Component
Expand All @@ -31,6 +40,7 @@ export const ErrorMessage: OverridableComponent<
{
[classes.spacing]: !!spacing,
},
error && classes.error,
className,
)}
/>
Expand Down

0 comments on commit 7d16bd9

Please sign in to comment.