Skip to content

Commit

Permalink
Tip: Covert component to TypeScript (#42262)
Browse files Browse the repository at this point in the history
* Tip: Covert component to TypeScript

* Update CHANGELOG.md
  • Loading branch information
Petter Walbø Johnsgård authored Jul 9, 2022
1 parent 54c90b7 commit 66bd34a
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 50 deletions.
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;
};

0 comments on commit 66bd34a

Please sign in to comment.