Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Label)!: remove deprecated props #1868

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/components/Label/Label.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
display: inline-block;
}

/**
* Label flag
*
* A flag to mark whether or not a field is required or optional. Currently a flag
* is only present for optional fields.
*/
.label__flag {
font: var(--eds-theme-typography-body-sm);
}

/**
* Label after
*
Expand Down
21 changes: 0 additions & 21 deletions src/components/Label/Label.stories.ts

This file was deleted.

39 changes: 39 additions & 0 deletions src/components/Label/Label.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { StoryObj, Meta } from '@storybook/react';
import React from 'react';

import { Label } from './Label';
import Tooltip from '../Tooltip';

export default {
title: 'Components/Label',
component: Label,
parameters: {
badges: ['1.0'],
},
} as Meta<Args>;

type Args = React.ComponentProps<typeof Label>;

/**
* Labels can denote some text to label the content, and whether that content is marked as required.
*/
export const Default: StoryObj<Args> = {
args: {
text: 'Label',
required: true,
},
};

/**
* You can use `labelAfter` to affix additional functionality to the label, like an optional `<Tooltip>`.
*/
export const LabelAfter: StoryObj<Args> = {
args: {
text: 'Label',
labelAfter: (
<Tooltip text="Test">
<span>*</span>
</Tooltip>
),
},
};
30 changes: 5 additions & 25 deletions src/components/Label/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import clsx from 'clsx';
import type { ReactNode } from 'react';
import React from 'react';

import Text from '../Text';
import styles from './Label.module.css';

export interface Props {
Expand All @@ -24,26 +26,10 @@ export interface Props {
* Slot for node to appear directly after field label. Typically used to include a Toolip
*/
labelAfter?: ReactNode;
/**
* String for the optional label.
*
* **Default is `"(optional)"`**
*
* **Deprecated**. This will be removed in the next major version.
* @deprecated
*/
optionalLabel?: string;
/**
* Indicates that field is required for form to be successfully submitted.
*/
required?: boolean;
/**
* String for the required label to add additional information if needed.
*
* **Deprecated**. This will be removed in the next major version.
* @deprecated
*/
requiredLabel?: string;
/**
* The label text string
*/
Expand All @@ -61,9 +47,7 @@ export const Label = ({
htmlFor,
id,
labelAfter,
optionalLabel = '(optional)',
required = true,
requiredLabel,
text,
...other
}: Props) => {
Expand All @@ -76,14 +60,10 @@ export const Label = ({
return (
<label className={componentClassName} htmlFor={htmlFor} id={id} {...other}>
{text}{' '}
{!required && (
<span className={styles['label__flag']}>{optionalLabel}</span>
)}
{requiredLabel && (
<span className={styles['label__flag']}>{requiredLabel}</span>
)}
{labelAfter && (
<span className={styles['label__after']}>{labelAfter}</span>
<Text as="span" preset="body-sm">
{labelAfter}
</Text>
)}
</label>
);
Expand Down
16 changes: 16 additions & 0 deletions src/components/Label/__snapshots__/Label.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,19 @@ exports[`<Label /> Default story renders snapshot 1`] = `

</label>
`;

exports[`<Label /> LabelAfter story renders snapshot 1`] = `
<label
class="label"
>
Label

<span
class="text text--body-sm"
>
<span>
*
</span>
</span>
</label>
`;
Loading