diff --git a/.npmignore b/.npmignore index 386abe8..ec52032 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,6 @@ * !package.json !dist/**/* -!src/**/* !LICENSE !README.md !*tailwind.config.ts diff --git a/package.json b/package.json index 929b97b..ee4c0e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@e-krebs/react-library", - "version": "0.0.39", + "version": "0.0.40", "description": "A collection of components to be reused across personal projects", "repository": "github.com/e-krebs/react-library", "author": "Emmanuel Krebs ", diff --git a/src/Inputs/NumberInput.tsx b/src/Inputs/NumberInput.tsx index 23723d5..519fca7 100644 --- a/src/Inputs/NumberInput.tsx +++ b/src/Inputs/NumberInput.tsx @@ -10,7 +10,7 @@ import { Text, } from 'react-aria-components'; -import { InputBorder, InputFlow } from '../types'; +import type { InputBorder, InputFlow, InputWidth } from '../types'; import { Icon } from '../assets/Icon'; interface NumberInputProps extends NumberFieldProps, RefAttributes { @@ -20,6 +20,7 @@ interface NumberInputProps extends NumberFieldProps, RefAttributes {label} @@ -34,6 +37,11 @@ export const TextInput: FC = ({ // rounded-none is necessary for iPad className=" bg-th-light p-1 + group-data-[width=xs]:w-12 + group-data-[width=s]:w-20 + group-data-[width=m]:w-28 + group-data-[width=l]:w-44 + group-data-[width=xl]:w-60 disabled:cursor-not-allowed disabled:opacity-disabled group-data-[border=rounded]:border group-data-[border=bottom]:border-b diff --git a/src/Inputs/inputs-uncontrolled.stories.tsx b/src/Inputs/inputs-uncontrolled.stories.tsx index 894fc40..6acdb31 100644 --- a/src/Inputs/inputs-uncontrolled.stories.tsx +++ b/src/Inputs/inputs-uncontrolled.stories.tsx @@ -2,7 +2,7 @@ import type { Story } from '@ladle/react'; import { Section } from 'utils'; import { TextInput } from './TextInput'; -import type { InputBorder, InputFlow } from '../types'; +import type { InputBorder, InputFlow, InputWidth } from '../types'; export default { title: 'Components > Text Input', @@ -15,6 +15,7 @@ interface StoryParams { error?: string; border?: InputBorder; flow?: InputFlow; + width?: InputWidth; } export const CheckboxStory: Story = ({ @@ -24,6 +25,7 @@ export const CheckboxStory: Story = ({ error, border, flow, + width, }) => (
= ({ errorMessage={error} border={border} flow={flow} + width={width} />
); @@ -54,4 +57,9 @@ CheckboxStory.argTypes = { control: { type: 'radio' }, defaultValue: 'col', }, + width: { + options: ['xs', 's', 'm', 'l', 'xl', undefined], + control: { type: 'select' }, + defaultValue: undefined, + }, }; diff --git a/src/Inputs/number-input-uncontrolled.stories.tsx b/src/Inputs/number-input-uncontrolled.stories.tsx index 30ed006..6bea2f3 100644 --- a/src/Inputs/number-input-uncontrolled.stories.tsx +++ b/src/Inputs/number-input-uncontrolled.stories.tsx @@ -2,7 +2,7 @@ import type { Story } from '@ladle/react'; import { Section } from 'utils'; import { NumberInput } from './NumberInput'; -import type { InputBorder, InputFlow } from '../types'; +import type { InputBorder, InputFlow, InputWidth } from '../types'; export default { title: 'Components > Number Input', @@ -15,9 +15,18 @@ interface StoryParams { border?: InputBorder; flow?: InputFlow; step?: string; + width?: InputWidth; } -export const CheckboxStory: Story = ({ label, description, error, border, flow, step }) => ( +export const CheckboxStory: Story = ({ + label, + description, + error, + border, + flow, + step, + width, +}) => (
= ({ label, description, error, b border={border} flow={flow} step={parseInt(step ?? '1')} + width={width} aria-label="fallback label" defaultValue={0} /> @@ -54,4 +64,9 @@ CheckboxStory.argTypes = { control: { type: 'select' }, defaultValue: '1', }, + width: { + options: ['xs', 's', 'm', 'l', 'xl', undefined], + control: { type: 'select' }, + defaultValue: undefined, + }, }; diff --git a/src/types.ts b/src/types.ts index 117f4e2..4d380c6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,5 +2,6 @@ import { FC, SVGAttributes } from 'react'; export type InputBorder = 'none' | 'bottom' | 'rounded'; export type InputFlow = 'col' | 'row'; +export type InputWidth = 'xs' | 's' | 'm' | 'l' | 'xl'; export type IconComponent = FC>;