2021-12-14 19:14:53 +00:00
|
|
|
import { Meta } from '@storybook/react';
|
2023-02-07 03:33:57 +00:00
|
|
|
import { ReactNode } from 'react';
|
|
|
|
import { Briefcase } from 'lucide-react';
|
2021-12-14 19:14:53 +00:00
|
|
|
|
2022-11-13 08:10:18 +00:00
|
|
|
import { init as initFeatureService } from '@/react/portainer/feature-flags/feature-flags.service';
|
|
|
|
import { Edition, FeatureId } from '@/react/portainer/feature-flags/enums';
|
2023-02-07 03:33:57 +00:00
|
|
|
import Docker from '@/assets/ico/vendor/docker.svg?c';
|
2021-12-14 19:14:53 +00:00
|
|
|
|
2022-11-28 02:00:28 +00:00
|
|
|
import { IconProps } from '@@/Icon';
|
|
|
|
|
2021-12-14 19:14:53 +00:00
|
|
|
import { BoxSelectorItem } from './BoxSelectorItem';
|
|
|
|
import { BoxSelectorOption } from './types';
|
|
|
|
|
|
|
|
const meta: Meta = {
|
|
|
|
title: 'BoxSelector/Item',
|
|
|
|
args: {
|
|
|
|
selected: false,
|
|
|
|
description: 'description',
|
2023-02-07 03:33:57 +00:00
|
|
|
icon: Briefcase,
|
2021-12-14 19:14:53 +00:00
|
|
|
label: 'label',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default meta;
|
|
|
|
|
|
|
|
interface ExampleProps {
|
|
|
|
selected?: boolean;
|
|
|
|
description?: string;
|
2022-11-28 02:00:28 +00:00
|
|
|
icon?: IconProps['icon'];
|
2021-12-14 19:14:53 +00:00
|
|
|
label?: string;
|
|
|
|
feature?: FeatureId;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Template({
|
2023-02-07 03:33:57 +00:00
|
|
|
selected = false,
|
2021-12-14 19:14:53 +00:00
|
|
|
description = 'description',
|
|
|
|
icon,
|
|
|
|
label = 'label',
|
|
|
|
feature,
|
|
|
|
}: ExampleProps) {
|
|
|
|
const option: BoxSelectorOption<number> = {
|
|
|
|
description,
|
2022-11-28 02:00:28 +00:00
|
|
|
icon,
|
2021-12-14 19:14:53 +00:00
|
|
|
id: 'id',
|
|
|
|
label,
|
|
|
|
value: 1,
|
|
|
|
feature,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="boxselector_wrapper">
|
|
|
|
<BoxSelectorItem
|
2023-02-07 03:33:57 +00:00
|
|
|
onSelect={() => {}}
|
2021-12-14 19:14:53 +00:00
|
|
|
option={option}
|
|
|
|
radioName="radio"
|
2023-02-07 03:33:57 +00:00
|
|
|
isSelected={() => selected}
|
2021-12-14 19:14:53 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Example = Template.bind({});
|
|
|
|
|
|
|
|
export function SelectedItem() {
|
|
|
|
return <Template selected />;
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectedItem.args = {
|
|
|
|
selected: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export function LimitedFeatureItem() {
|
|
|
|
initFeatureService(Edition.CE);
|
|
|
|
|
|
|
|
return <Template feature={FeatureId.ACTIVITY_AUDIT} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function SelectedLimitedFeatureItem() {
|
|
|
|
initFeatureService(Edition.CE);
|
|
|
|
|
|
|
|
return <Template feature={FeatureId.ACTIVITY_AUDIT} selected />;
|
|
|
|
}
|
2023-02-07 03:33:57 +00:00
|
|
|
|
|
|
|
function IconTemplate({
|
|
|
|
icon,
|
|
|
|
iconType,
|
|
|
|
}: {
|
|
|
|
icon: ReactNode;
|
|
|
|
iconType: 'raw' | 'logo' | 'badge';
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<BoxSelectorItem
|
|
|
|
onSelect={() => {}}
|
|
|
|
option={{
|
|
|
|
description: 'description',
|
|
|
|
icon,
|
|
|
|
iconType,
|
|
|
|
label: 'label',
|
|
|
|
id: 'id',
|
|
|
|
value: 'value',
|
|
|
|
}}
|
|
|
|
isSelected={() => false}
|
|
|
|
radioName="radio"
|
|
|
|
slim
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function LogoItem() {
|
|
|
|
return <IconTemplate icon={Docker} iconType="logo" />;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function BadgeItem() {
|
|
|
|
return <IconTemplate icon={Briefcase} iconType="badge" />;
|
|
|
|
}
|