silphius/stories/hotbar.stories.js

51 lines
985 B
JavaScript
Raw Normal View History

2024-06-10 22:42:30 -05:00
import {useArgs} from '@storybook/preview-api';
import {fn} from '@storybook/test';
2024-07-20 04:32:33 -05:00
import Hotbar from '@/react/components/hotbar.jsx';
2024-06-10 22:42:30 -05:00
import DomDecorator from './dom-decorator.jsx';
const slots = Array(10).fill({});
2024-06-29 06:28:03 -05:00
slots[2] = {qty: 24, icon: '/assets/potion/icon.png'};
2024-06-10 22:42:30 -05:00
export default {
title: 'Dom/Inventory/Hotbar',
component: Hotbar,
decorators: [
(Hotbar, ctx) => {
const [, updateArgs] = useArgs();
const {onActivate} = ctx.args;
ctx.args.onActivate = (i) => {
updateArgs({active: i});
if (onActivate) {
onActivate(i);
}
};
return Hotbar();
},
2024-06-24 05:00:24 -05:00
DomDecorator({
style: {
display: 'flex',
flexDirection: 'column',
},
}),
2024-06-10 22:42:30 -05:00
],
tags: ['autodocs'],
args: {
active: 0,
onActivate: fn(),
slots,
},
argTypes: {
active: {
control: {
type: 'number',
min: 0,
max: 9,
}
},
},
};
export const Default = {};