51 lines
985 B
JavaScript
51 lines
985 B
JavaScript
import {useArgs} from '@storybook/preview-api';
|
|
import {fn} from '@storybook/test';
|
|
|
|
import Hotbar from '@/react-components/hotbar.jsx';
|
|
|
|
import DomDecorator from './dom-decorator.jsx';
|
|
|
|
const slots = Array(10).fill({});
|
|
slots[2] = {qty: 24, icon: '/assets/potion/icon.png'};
|
|
|
|
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();
|
|
},
|
|
DomDecorator({
|
|
style: {
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
},
|
|
}),
|
|
],
|
|
tags: ['autodocs'],
|
|
args: {
|
|
active: 0,
|
|
onActivate: fn(),
|
|
slots,
|
|
},
|
|
argTypes: {
|
|
active: {
|
|
control: {
|
|
type: 'number',
|
|
min: 0,
|
|
max: 9,
|
|
}
|
|
},
|
|
},
|
|
};
|
|
|
|
export const Default = {};
|