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

Tip: Covert component to TypeScript #42262

Merged
merged 2 commits into from
Jul 9, 2022
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- `Grid`: Convert to TypeScript ([#41923](https://github.com/WordPress/gutenberg/pull/41923)).
- `TextHighlight`: Convert to TypeScript ([#41698](https://github.com/WordPress/gutenberg/pull/41698)).
- `Tip`: Convert to TypeScript ([#42262](https://github.com/WordPress/gutenberg/pull/42262)).
- `Scrollable`: Convert to TypeScript ([#42016](https://github.com/WordPress/gutenberg/pull/42016)).
- `Spacer`: Complete TypeScript migration ([#42013](https://github.com/WordPress/gutenberg/pull/42013)).
- `TreeSelect`: Refactor away from `_.repeat()` ([#42070](https://github.com/WordPress/gutenberg/pull/42070/)).
Expand Down
24 changes: 0 additions & 24 deletions packages/components/src/tip/index.js

This file was deleted.

22 changes: 22 additions & 0 deletions packages/components/src/tip/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* WordPress dependencies
*/
import { Icon, tip } from '@wordpress/icons';

/**
* Internal dependencies
*/
import type { TipProps } from './types';

export function Tip( props: TipProps ) {
const { children } = props;

return (
<div className="components-tip">
<Icon icon={ tip } />
<p>{ children }</p>
</div>
);
}

export default Tip;
26 changes: 0 additions & 26 deletions packages/components/src/tip/stories/index.js

This file was deleted.

33 changes: 33 additions & 0 deletions packages/components/src/tip/stories/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import type { ComponentMeta, ComponentStory } from '@storybook/react';

/**
* Internal dependencies
*/
import Tip from '..';

const meta: ComponentMeta< typeof Tip > = {
component: Tip,
title: 'Components/Tip',
argTypes: {
children: { control: { type: 'text' } },
},
parameters: {
controls: {
expanded: true,
},
docs: { source: { state: 'open' } },
},
};
export default meta;

const Template: ComponentStory< typeof Tip > = ( args ) => {
return <Tip { ...args } />;
};

export const Default: ComponentStory< typeof Tip > = Template.bind( {} );
Default.args = {
children: 'An example tip',
};
11 changes: 11 additions & 0 deletions packages/components/src/tip/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* External dependencies
*/
import type { ReactNode } from 'react';

export type TipProps = {
/**
* Children to render in the tip.
*/
children: ReactNode;
};