import { Meta, StoryFn, StoryObj } from '@storybook/react'; import React, { useState } from 'react'; import { TokenLabelField } from '.'; export default { args: {}, component: TokenLabelField, title: 'Components/Fields/TokenLabelField', } as Meta; const Template: StoryFn = (args) => { const [value, setValue] = useState(args.value); const [tokenOption, setTokenOption] = useState( typeof args.token === 'string' ? args.token : undefined, ); return ( setValue(args.max?.value.toString()), } : undefined } token={tokenOption} value={value} onChange={setValue} onTokenOptionSelected={setTokenOption} /> ); }; export const Default: StoryObj = { args: { bottomLeftText: 'Bottom left text', bottomRightTextValue: '123', label: 'Label', token: 'usdc', tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithMax: StoryObj = { args: { bottomLeftText: 'Max value is', bottomRightTextValue: 123456, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, token: 'usdc', tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithError: StoryObj = { args: { bottomLeftText: 'Max value is', bottomLeftTextColorToken: 'error500', bottomRightTextColorToken: 'error500', bottomRightTextTokenColorToken: 'error700', bottomRightTextValue: 123456, error: true, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, token: 'usdc', tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithDifferentBottomRightTextToken: StoryObj = { args: { bottomLeftText: 'Max value is', bottomRightTextToken: '%', bottomRightTextTokenColorToken: 'white950', bottomRightTextValue: 123456, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, token: 'usdc', tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithMaxTokenOptionsAndTokenFormatter: StoryObj = { args: { bottomLeftText: 'Max value is', bottomRightTextValue: 123456, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, token: 'usdc', tokenFormatter: (token: string | undefined) => (!token ? '' : token.toUpperCase()), tokenOptions: ['eth', 'usdc'], tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithMaxTokenOptionsAndNoInitialTokenFormatter: StoryObj = { args: { bottomLeftText: 'Max value is', bottomRightTextValue: 123456, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, token: '', tokenFormatter: (token: string | undefined) => (!token ? '' : token.toUpperCase()), tokenOptions: ['eth', 'usdc'], tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithPrefixTokenFormatter: StoryObj = { args: { bottomLeftText: 'Max value is', bottomRightTextValue: 123456, label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, prefixToken: '+', token: 'usdc', tokenFormatter: (token: string | undefined) => (!token ? '' : token.toUpperCase()), tokenOptions: ['eth', 'usdc'], tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, }; export const WithCustomStyle: StoryObj = { args: { backgroundColorToken: 'primary800', borderColorToken: 'primary500', bottomLeftText: 'Max value is', bottomRightTextValue: 123456, colorToken: 'primary300', disabledBackgroundColorToken: 'warning800', disabledBorderColorToken: 'warning500', disabledColorToken: 'warning500', errorBorderColorToken: 'error500', errorColorToken: 'error500', hoverBackgroundColorToken: 'secondary700', hoverBorderColorToken: 'primary800', hoverColorToken: 'primary700', hoverErrorBorderColorToken: 'error200', hoverErrorColorToken: 'error700', label: 'Label', max: { onClick: () => {}, showButton: true, value: 123456, }, placeholderColorToken: 'secondary700', prefixToken: '+', token: 'usdc', tokenFormatter: (token: string | undefined) => (!token ? '' : token.toUpperCase()), tokenOptions: ['eth', 'usdc'], tooltip: 'Tooltip message here!', topRightText: 'Top right text', }, render: Template, };