Skip to content
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
4 changes: 4 additions & 0 deletions projects/js-packages/components/changelog/remove-text-h2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

Remove the unused `H2` heading component; use `Text` with `variant="headline-medium"` instead.
18 changes: 6 additions & 12 deletions projects/js-packages/components/components/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 } ) => (
<Text variant="headline-medium" mb={ 3 } { ...componentProps }>
{ children }
</Text>
);

/**
* Heading component - Small size,
*
* @deprecated Use `Text` from `@wordpress/ui` instead.
*
* @param {H3Props} props - Component props.
* @return {ReactElement} - JSX.Element
*/
Expand All @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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' },
Expand Down Expand Up @@ -36,15 +44,6 @@ function Instance( { children } ) {
);
}

const TemplateH2 = args => (
<Instance>
<H2 { ...args }>
{ args?.children ||
'Headline Medium - Manage your Jetpack plan and products all in one place' }
</H2>
</Instance>
);

const TemplateH3 = args => (
<Instance>
<H3 { ...args }>
Expand All @@ -54,25 +53,6 @@ const TemplateH3 = args => (
</Instance>
);

const Template = args => {
return (
<>
<TemplateH2 { ...args } />
<TemplateH3 { ...args } />
</>
);
};

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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

<Meta of={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.

## &lt;Text /&gt;
Expand Down Expand Up @@ -143,12 +146,9 @@ The text itself that will be rendered.

# Text based components

## &lt;H2 /&gt;
Text shorthand to render a `heading-medium` text, applying proper spacing.

[▶️ Story](.?path=/story/js-packages-components-text-heading--headline-h-2)

## &lt;H3 /&gt;
> **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)
Expand All @@ -171,6 +171,8 @@ Text shorthand to render a `heading-small` text, applying proper spacing.
/>

## &lt;Title /&gt;
> **Deprecated:** Use `Text` from `@wordpress/ui` with a `heading-*` variant instead.

Text shorthand to render a `body` text, applying proper spacing.

### Props
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 ) => ( {
Expand All @@ -25,7 +33,7 @@ export default {
options: Object.keys( VARIANTS_MAPPING ),
},
},
subcomponents: { H2, H3, Title },
subcomponents: { H3, Title },
};

const Template = args => <Text { ...args }>{ args.variant ?? 'body' }</Text>;
Expand Down
2 changes: 1 addition & 1 deletion projects/js-packages/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading