diff --git a/projects/js-packages/components/changelog/remove-text-h2 b/projects/js-packages/components/changelog/remove-text-h2 new file mode 100644 index 000000000000..a0b9096de8a9 --- /dev/null +++ b/projects/js-packages/components/changelog/remove-text-h2 @@ -0,0 +1,4 @@ +Significance: major +Type: removed + +Remove the unused `H2` heading component; use `Text` with `variant="headline-medium"` instead. diff --git a/projects/js-packages/components/components/text/index.tsx b/projects/js-packages/components/components/text/index.tsx index c5870611c6ff..5f9d35b098df 100644 --- a/projects/js-packages/components/components/text/index.tsx +++ b/projects/js-packages/components/components/text/index.tsx @@ -8,6 +8,8 @@ import type { FC, ReactElement } from 'react'; /** * Text component. * + * @deprecated Use `Text` from `@wordpress/ui` instead. + * * @param {TextProps} props - Component props. * @return {ReactElement} - JSX.Element */ @@ -42,21 +44,11 @@ Text.displayName = 'Text'; export default Text; -/** - * Heading component - Medium size. - * - * @param {TextProps} props - Component props. - * @return {ReactElement} - JSX.Element - */ -export const H2: FC< TextProps > = ( { children, ...componentProps } ) => ( - - { children } - -); - /** * Heading component - Small size, * + * @deprecated Use `Text` from `@wordpress/ui` instead. + * * @param {H3Props} props - Component props. * @return {ReactElement} - JSX.Element */ @@ -75,6 +67,8 @@ export const H3: FC< H3Props > = ( { children, weight = 'bold', ...componentProp /** * Title component, based on Text component. * + * @deprecated Use `Text` from `@wordpress/ui` instead. + * * @param {TitleProps} props - Component props. * @return {ReactElement} - JSX.Element */ diff --git a/projects/js-packages/components/components/text/stories/headings.index.stories.tsx b/projects/js-packages/components/components/text/stories/headings.index.stories.tsx index 5f1428d73118..c48fa194a176 100644 --- a/projects/js-packages/components/components/text/stories/headings.index.stories.tsx +++ b/projects/js-packages/components/components/text/stories/headings.index.stories.tsx @@ -1,4 +1,4 @@ -import { H2, H3 } from '../index.tsx'; +import { H3 } from '../index.tsx'; import styles from './style.module.scss'; import type { H3Props } from '../types.ts'; import type { Component } from 'react'; @@ -7,7 +7,15 @@ const TIPOGRAPHY_WEIGHTS: Array< H3Props[ 'weight' ] > = [ 'regular', 'bold' ]; export default { title: 'JS Packages/Components/Text/Heading', - component: H2, + component: H3, + parameters: { + docs: { + description: { + component: + '**Deprecated:** Use `Text` from `@wordpress/ui` instead, with a `heading-*` variant.', + }, + }, + }, argTypes: { children: { control: { type: 'text' }, @@ -36,15 +44,6 @@ function Instance( { children } ) { ); } -const TemplateH2 = args => ( - -

- { args?.children || - 'Headline Medium - Manage your Jetpack plan and products all in one place' } -

-
-); - const TemplateH3 = args => (

@@ -54,25 +53,6 @@ const TemplateH3 = args => ( ); -const Template = args => { - return ( - <> - - - - ); -}; - -const DefaultArgs = {}; -export const Default = Template.bind( {} ); -Default.args = DefaultArgs; - -export const HeadlineH2 = TemplateH2.bind( {} ); -HeadlineH2.storyName = 'H2'; -HeadlineH2.args = { - weight: 'bold', -} as H3Props; - export const HeadlineH3 = TemplateH3.bind( {} ); HeadlineH3.storyName = 'H3'; HeadlineH3.args = { diff --git a/projects/js-packages/components/components/text/stories/index.mdx b/projects/js-packages/components/components/text/stories/index.mdx index 64b9acb7f950..bfe46e9fafdf 100644 --- a/projects/js-packages/components/components/text/stories/index.mdx +++ b/projects/js-packages/components/components/text/stories/index.mdx @@ -1,11 +1,14 @@ import { Meta, Source, Story } from '@storybook/addon-docs/blocks'; import dedent from 'ts-dedent'; -import Text, { BOX_MODEL_VALUES, H2, H3, Title } from '../index.tsx'; +import Text, { BOX_MODEL_VALUES, H3, Title } from '../index.tsx'; import * as Stories from './index.stories'; # Text + +> **Deprecated:** Prefer `Text` from [`@wordpress/ui`](https://www.npmjs.com/package/@wordpress/ui) for new code. It covers the same need with `heading-*` and `body-*` variants. `Text`, `H3` and `Title` here are kept for existing usage. + Set of React jetpack-components intended to facilitate when dealing with rendering text content. ## <Text /> @@ -143,12 +146,9 @@ The text itself that will be rendered. # Text based components -## <H2 /> -Text shorthand to render a `heading-medium` text, applying proper spacing. - -[▶️ Story](.?path=/story/js-packages-components-text-heading--headline-h-2) - ## <H3 /> +> **Deprecated:** Use `Text` from `@wordpress/ui` with a `heading-*` variant instead. + Text shorthand to render a `heading-small` text, applying proper spacing. [▶️ Story](.?path=/story/js-packages-components-text-heading--headline-h-3) @@ -171,6 +171,8 @@ Text shorthand to render a `heading-small` text, applying proper spacing. /> ## <Title /> +> **Deprecated:** Use `Text` from `@wordpress/ui` with a `heading-*` variant instead. + Text shorthand to render a `body` text, applying proper spacing. ### Props diff --git a/projects/js-packages/components/components/text/stories/index.stories.tsx b/projects/js-packages/components/components/text/stories/index.stories.tsx index a23d9939d82e..1a5e7e55c469 100644 --- a/projects/js-packages/components/components/text/stories/index.stories.tsx +++ b/projects/js-packages/components/components/text/stories/index.stories.tsx @@ -1,4 +1,4 @@ -import Text, { BOX_MODEL_VALUES, H2, H3, Title, VARIANTS_MAPPING } from '../index.tsx'; +import Text, { BOX_MODEL_VALUES, H3, Title, VARIANTS_MAPPING } from '../index.tsx'; import styles from './style.module.scss'; import type { SpacingValue } from '../types.ts'; @@ -7,6 +7,14 @@ const SPACING_VALUES: Array< SpacingValue > = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]; export default { title: 'JS Packages/Components/Text', component: Text, + parameters: { + docs: { + description: { + component: + '**Deprecated:** Use `Text` from `@wordpress/ui` instead, with a `heading-*` or `body-*` variant.', + }, + }, + }, argTypes: { ...BOX_MODEL_VALUES.reduce( ( obj, cur ) => ( { @@ -25,7 +33,7 @@ export default { options: Object.keys( VARIANTS_MAPPING ), }, }, - subcomponents: { H2, H3, Title }, + subcomponents: { H3, Title }, }; const Template = args => { args.variant ?? 'body' }; diff --git a/projects/js-packages/components/index.ts b/projects/js-packages/components/index.ts index e76aa2456ca9..cae4e35cbcbb 100644 --- a/projects/js-packages/components/index.ts +++ b/projects/js-packages/components/index.ts @@ -44,7 +44,7 @@ export { default as CopyToClipboard } from './components/copy-to-clipboard/index export { default as JitmSlot } from './components/jitm-slot/index.tsx'; export * from './components/icons/index.tsx'; export { default as ThemeProvider } from './components/theme-provider/index.tsx'; -export { default as Text, H2, H3, Title } from './components/text/index.tsx'; +export { default as Text, H3, Title } from './components/text/index.tsx'; export { default as QRCode } from './components/qr-code/index.tsx'; export { default as Button } from './components/button/index.tsx'; export type { ButtonProps } from './components/button/types.ts';