import * as React from 'react'; import { message } from 'antd'; import { injectIntl } from 'react-intl'; import CopyableIcon from './CopyableIcon'; import { ThemeType } from './index'; import { CategoriesKeys } from './fields'; interface CategoryProps { title: CategoriesKeys; icons: string[]; theme: ThemeType; newIcons: string[]; intl: any; } interface CategoryState { justCopied: string | null; } class Category extends React.Component { copyId?: number; state = { justCopied: null, }; componentWillUnmount() { window.clearTimeout(this.copyId); } onCopied = (type: string, text: string) => { message.success( {text} copied 🎉 , ); this.setState({ justCopied: type }, () => { this.copyId = window.setTimeout(() => { this.setState({ justCopied: null }); }, 2000); }); }; render() { const { icons, title, newIcons, theme, intl: { messages }, } = this.props; const items = icons.map(name => ( = 0} justCopied={this.state.justCopied} onCopied={this.onCopied} /> )); return (

{messages[`app.docs.components.icon.category.${title}`]}

    {items}
); } } export default injectIntl(Category);