2022-11-28 02:00:28 +00:00
|
|
|
import { ReactNode } from 'react';
|
2021-11-16 14:51:49 +00:00
|
|
|
import type { Meta } from '@storybook/react';
|
2022-11-28 02:00:28 +00:00
|
|
|
import { User } from 'lucide-react';
|
2021-11-16 14:51:49 +00:00
|
|
|
|
|
|
|
import { Widget } from './Widget';
|
|
|
|
import { WidgetBody } from './WidgetBody';
|
|
|
|
import { WidgetTitle } from './WidgetTitle';
|
|
|
|
import { WidgetFooter } from './WidgetFooter';
|
|
|
|
import { WidgetTaskbar } from './WidgetTaskbar';
|
|
|
|
|
|
|
|
interface WidgetProps {
|
|
|
|
loading: boolean;
|
|
|
|
title: string;
|
2022-11-28 02:00:28 +00:00
|
|
|
icon: ReactNode;
|
2021-11-16 14:51:49 +00:00
|
|
|
bodyText: string;
|
|
|
|
footerText: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const meta: Meta<WidgetProps> = {
|
|
|
|
title: 'Widget',
|
|
|
|
component: Widget,
|
|
|
|
args: {
|
|
|
|
loading: false,
|
|
|
|
title: 'Title',
|
2022-11-28 02:00:28 +00:00
|
|
|
icon: User,
|
2021-11-16 14:51:49 +00:00
|
|
|
bodyText: 'Body',
|
|
|
|
footerText: 'Footer',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
2021-12-16 18:52:54 +00:00
|
|
|
export { Default, WidgetWithCustomImage, WidgetWithTaskBar };
|
|
|
|
|
|
|
|
function Default({ loading, bodyText, footerText, icon, title }: WidgetProps) {
|
2021-11-16 14:51:49 +00:00
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<WidgetTitle title={title} icon={icon} />
|
|
|
|
<WidgetBody loading={loading}>{bodyText}</WidgetBody>
|
|
|
|
<WidgetFooter>{footerText}</WidgetFooter>
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-16 18:52:54 +00:00
|
|
|
function WidgetWithCustomImage({
|
2021-11-16 14:51:49 +00:00
|
|
|
loading,
|
|
|
|
bodyText,
|
|
|
|
footerText,
|
|
|
|
icon,
|
|
|
|
title,
|
|
|
|
}: WidgetProps) {
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<WidgetTitle
|
|
|
|
title={title}
|
|
|
|
icon={
|
2022-11-28 02:00:28 +00:00
|
|
|
typeof icon === 'string' ? (
|
|
|
|
<img
|
|
|
|
className="custom-header-ico space-right"
|
|
|
|
src={icon}
|
|
|
|
alt="header-icon"
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
icon
|
|
|
|
)
|
2021-11-16 14:51:49 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
<WidgetBody loading={loading}>{bodyText}</WidgetBody>
|
|
|
|
<WidgetFooter>{footerText}</WidgetFooter>
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetWithCustomImage.args = {
|
|
|
|
icon: 'https://via.placeholder.com/150',
|
|
|
|
};
|
|
|
|
|
2021-12-16 18:52:54 +00:00
|
|
|
function WidgetWithTaskBar({
|
2021-11-16 14:51:49 +00:00
|
|
|
loading,
|
|
|
|
bodyText,
|
|
|
|
footerText,
|
|
|
|
icon,
|
|
|
|
title,
|
|
|
|
}: WidgetProps) {
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<WidgetTitle title={title} icon={icon} />
|
|
|
|
<WidgetTaskbar>
|
|
|
|
<button type="button" className="btn btn-primary">
|
|
|
|
Button
|
|
|
|
</button>
|
|
|
|
</WidgetTaskbar>
|
|
|
|
<WidgetBody loading={loading}>{bodyText}</WidgetBody>
|
|
|
|
<WidgetFooter>{footerText}</WidgetFooter>
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|