import { Story, Meta } from '@storybook/react' import { Eth } from '@lidofinance/icons' import { Block } from '@lidofinance/block' import { Button } from '@lidofinance/button' import { Identicon } from '@lidofinance/identicon' import Input from './Input' import styled from 'styled-components' import { InputProps, InputType, InputVariant, InputColor } from './types' import { useState } from 'react' const getOptions = (enumObject: Record) => Object.values(enumObject).filter((value) => typeof value === 'string') export default { component: Input, title: 'Controls/Input', args: { disabled: false, fullwidth: false, active: false, }, argTypes: { onChange: { action: 'change', table: { disable: true }, }, }, } as Meta export const Basic: Story = (props) => Basic.args = { placeholder: 'Amount', label: '', type: 'text', } Basic.argTypes = { type: { options: getOptions(InputType), control: 'inline-radio', }, color: { options: getOptions(InputColor), control: 'inline-radio', }, } export const Small: Story = (props) => Small.args = { variant: 'small', placeholder: 'Amount', } Small.argTypes = { variant: { options: getOptions(InputVariant), control: 'inline-radio', }, } export const Label: Story = (props) => Label.args = { label: 'Email address', } Label.argTypes = { color: { options: getOptions(InputColor), control: 'inline-radio', }, } const EthIcon = styled(Eth)` fill: ${({ theme }) => theme.colors.text}; ` const MaxButton = () => ( ) export const WithDecorators: Story = (props) => ( } rightDecorator={} {...props} /> ) WithDecorators.args = { placeholder: 'Amount', } WithDecorators.argTypes = { color: { options: getOptions(InputColor), control: 'inline-radio', }, } export const WithIdenticon: Story = (props) => { const [value, setValue] = useState('') return ( { setValue(event.currentTarget.value) props.onChange?.(event) }} rightDecorator={} /> ) } WithIdenticon.args = { placeholder: 'Ethereum address', } export const WithButton: Story = (props) => ( Subscribe } {...props} /> ) WithButton.args = { fullwidth: true, label: 'Email address', } WithButton.argTypes = { color: { options: getOptions(InputColor), control: 'inline-radio', }, } export const WithError: Story = (props) => WithError.args = { fullwidth: true, defaultValue: 'info@lido.', label: 'Email address', error: 'Email is invalid', } WithError.argTypes = { color: { options: getOptions(InputColor), control: 'inline-radio', }, } export const WithWarning: Story = (props) => WithWarning.args = { fullwidth: true, defaultValue: '10', label: 'Token amount', warning: 'Amount may be insufficient.', } const Success = styled.span` font-weight: 600; font-size: ${({ theme }) => theme.fontSizesMap.xs}px; color: ${({ theme }) => theme.colors.success}; ` export const WithSuccess: Story = (props) => ( Subscribed} {...props} /> ) WithSuccess.args = { fullwidth: true, disabled: true, defaultValue: 'info@lido.fi', success: 'Thank you for subscribing! We will notify you once we kick off our platform.', } export const AccentColor: Story = (props) => { const [value, setValue] = useState('') return ( { setValue(event.currentTarget.value) props.onChange?.(event) }} rightDecorator={} color='accent' /> ) } AccentColor.args = { fullwidth: true, label: '', placeholder: 'Ethereum address', }