import { ArgTypes, Meta, Story } from '@storybook/react'; import Grid from '@mui/material/Grid'; import Typography from '@mui/material/Typography'; import { CustomIcon } from './custom-icon'; import type { CustomIconProps } from './types'; import { imagesAppsSources, imagesProvidersSources } from './helpers'; const argTypes: Partial> = { src: { description: 'The image URL.', options: imagesAppsSources, control: { type: 'select' } }, className: { description: 'Custom class name in case you need to add custom styles to the component.' } }; export default { component: CustomIcon, title: 'Foundations/Images', argTypes } as Meta; const renderCustomImage = (args: CustomIconProps) => (imageSrc: string) => { const imageName = imageSrc.split('/')[imageSrc.split('/').length - 1]; return imageName ? ( { alert(`${imageSrc}`); }} /> ) : null; }; const ImagesTemplateFactory: (imagesSources: string[]) => Story = imagesSources => args => { return ( <> Click on the image to get its SRC (address) {imagesSources.map(renderCustomImage(args))} ); }; export const AppsImages = ImagesTemplateFactory(imagesAppsSources).bind({}); AppsImages.args = { style: {} }; export const Providers = ImagesTemplateFactory(imagesProvidersSources).bind({}); Providers.args = { style: {} };