hooks#useNotify TypeScript Examples
The following examples show how to use
hooks#useNotify.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Notify.stories.tsx From ebs-design with MIT License | 6 votes |
Regular: React.FC<NotifyItemProps> & { args: NotifyItemProps } = ({ children, ...props }) => {
const Notify: React.FC<NotifyItemProps> = ({ ...params }) => {
const notify = useNotify();
return (
<Template>
<Button size="small" type="fill" onClick={() => notify.regular(params)}>
Regular
</Button>
<Button size="small" type="primary" onClick={() => notify.primary(params)}>
Primary
</Button>
<Button type="text">
<Label status="success" type="fill" text="Success" onClick={() => notify.success(params)} />
</Button>
<Button type="text">
<Label status="danger" type="fill" text="Danger" onClick={() => notify.error(params)} />
</Button>
<Button type="text">
<Label status="info" type="fill" text="Info" onClick={() => notify.info(params)} />
</Button>
<Button type="text">
<Label status="warning" type="fill" text="Warning" onClick={() => notify.warning(params)} />
</Button>
</Template>
);
};
return (
<NotifyProvider>
<NotifyContainer />
<Notify {...props} />
</NotifyProvider>
);
}
Example #2
Source File: Icon.stories.tsx From ebs-design with MIT License | 5 votes |
Regular = (): React.ReactNode => {
const IconList: React.FC = () => {
const notify = useNotify();
const onCopied = (): void => {
notify.success({ title: 'Success', description: 'Copied to clipboard' });
};
return (
<Space direction="vertical">
<div className="storybook-header">Copy to clipboard on hover</div>
<div className="storybook-icon-items">
{(Object.keys(icons) as modelType[]).map((model) => {
return Object.keys(icons[model]).map((icon) => {
const iconName = `<Icon type="${icon}" ${model === 'bold' ? 'model="bold"' : ''} />`;
const onCopy = async (): Promise<void> => {
await copyToClipboard(iconName);
onCopied();
};
return (
<Button className="storybook-icon-item" key={icon} onClick={onCopy}>
<div className="storybook-icon">
<Icon type={icon} model={model} />
</div>
<div className="storybook-icon-name">{iconName}</div>
</Button>
);
});
})}
</div>
</Space>
);
};
return (
<NotifyProvider>
<NotifyContainer />
<IconList />
</NotifyProvider>
);
}