diff --git a/packages/core/src/components/asterisk/asterisk.scss b/packages/core/src/components/asterisk/asterisk.scss new file mode 100644 index 000000000..c87b62d1b --- /dev/null +++ b/packages/core/src/components/asterisk/asterisk.scss @@ -0,0 +1,7 @@ +@use '../../helpers'; + +@mixin Asterisk() { + .ods-asterisk { + color: helpers.color('content-negative'); + } +} diff --git a/packages/core/src/components/index.scss b/packages/core/src/components/index.scss index 14d861022..bfbac84d8 100644 --- a/packages/core/src/components/index.scss +++ b/packages/core/src/components/index.scss @@ -1,5 +1,7 @@ @use './includes'; +@use './asterisk/asterisk'; +@forward './asterisk/asterisk'; @use './button/button'; @forward './button/button'; @use './checkbox/checkbox'; @@ -24,6 +26,7 @@ @forward './validation/validation'; @mixin components() { + @include asterisk.Asterisk(); @include button.Button(); @include checkbox.Checkbox(); @include field.Field(); diff --git a/packages/react/src/components/asterisk/asterisk.tsx b/packages/react/src/components/asterisk/asterisk.tsx new file mode 100644 index 000000000..28132e2e5 --- /dev/null +++ b/packages/react/src/components/asterisk/asterisk.tsx @@ -0,0 +1,18 @@ +import { c, classy } from '@onfido/castor'; +import React from 'react'; + +/** + * Use in `FieldLabel` to denote required fields. + */ +export const Asterisk = ({ + className, + ...restProps +}: AsteriskProps): JSX.Element => ( + + {' *'} + +); + +export type AsteriskProps = Omit & { + 'aria-label': string; +}; diff --git a/packages/react/src/components/field-label/field-label.stories.tsx b/packages/react/src/components/field-label/field-label.stories.tsx index a41748b8c..d373b42e9 100644 --- a/packages/react/src/components/field-label/field-label.stories.tsx +++ b/packages/react/src/components/field-label/field-label.stories.tsx @@ -1,5 +1,6 @@ import { color } from '@onfido/castor'; import { + Asterisk, Field, FieldLabel, FieldLabelProps, @@ -44,10 +45,8 @@ export const AsRequired: Story = ({ }: FieldLabelProps) => ( - {children}{' '} - - * - + {children} + ); diff --git a/packages/react/src/components/index.ts b/packages/react/src/components/index.ts index 59ccdcd5b..7e973a8e3 100644 --- a/packages/react/src/components/index.ts +++ b/packages/react/src/components/index.ts @@ -1,3 +1,4 @@ +export * from './asterisk/asterisk'; export * from './button/button'; export * from './checkbox/checkbox'; export * from './field-label/field-label';