Tansy UI: a themeable React component kit
Tansy UI is a React component kit by OpenKhalix, named after the tansy
flower ("golden buttons"). It has two surfaces:
- A landing page built entirely from the kit's own components, with
five featured parts, a palette-switching playground form, and links
into Storybook
- A Storybook workshop with Tansy branding, a Welcome page, palette
toolbar and accessibility checks
Includes 15 components with colocated tokens and stories, seven brand
palettes, a palette-aware logo, a Docker/nginx image, a scripted
cPanel deploy, and a generator that keeps the landing page catalogue
in sync with Storybook.
This commit is contained in:
commit
9d406d6d2a
81 files changed
+14240
No files matched your search
@@ -0,0 +1,143 @@
|
||||
import { useState } from 'react'
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite'
|
||||
import { Input } from './Input'
|
||||
|
||||
const meta = {
|
||||
title: 'Forms/Input',
|
||||
component: Input,
|
||||
tags: ['autodocs'],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
'Plain input with a label above. For a floating label, a built-in password toggle, and a Lucide icon slot, see the **FeaturedInput** story group — both are exported from here.',
|
||||
},
|
||||
},
|
||||
},
|
||||
argTypes: {
|
||||
size: { control: 'select', options: ['sm', 'md', 'lg'] },
|
||||
theme: { control: 'select', options: ['primary', 'secondary', 'success', 'error', 'warning', 'info'] },
|
||||
type: { control: 'select', options: ['text', 'email', 'password', 'number', 'tel', 'url', 'date'] },
|
||||
iconPosition: { control: 'radio', options: ['left', 'right'] },
|
||||
roundedFull: { control: 'boolean' },
|
||||
dashedBorder: { control: 'boolean' },
|
||||
required: { control: 'boolean' },
|
||||
disabled: { control: 'boolean' },
|
||||
label: { control: 'text' },
|
||||
placeholder: { control: 'text' },
|
||||
error: { control: 'text' },
|
||||
},
|
||||
args: {
|
||||
label: 'Legal entity name',
|
||||
placeholder: 'Acme Corporation',
|
||||
type: 'text',
|
||||
size: 'md',
|
||||
theme: 'primary',
|
||||
iconPosition: 'left',
|
||||
roundedFull: false,
|
||||
dashedBorder: false,
|
||||
required: false,
|
||||
disabled: false,
|
||||
error: '',
|
||||
},
|
||||
} satisfies Meta<typeof Input>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
function ControlledInput({
|
||||
initial = '',
|
||||
...args
|
||||
}: React.ComponentProps<typeof Input> & { initial?: string }) {
|
||||
const [value, setValue] = useState(initial)
|
||||
return <Input {...args} value={value} onChange={(e) => setValue(e.target.value)} />
|
||||
}
|
||||
|
||||
export const Playground: Story = {
|
||||
render: (args) => (
|
||||
<div className="max-w-md">
|
||||
<ControlledInput {...args} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Types: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-2xl gap-5 sm:grid-cols-2">
|
||||
<Input label="Full name" placeholder="Jane Doe" />
|
||||
<Input label="Email" type="email" placeholder="[email protected]" />
|
||||
<Input label="Phone" type="tel" placeholder="+91 98450 00000" />
|
||||
<Input label="Annual CTC" type="number" placeholder="1200000" />
|
||||
<Input label="Website" type="url" placeholder="https://example.com" />
|
||||
<Input label="Joining date" type="date" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Sizes: Story = {
|
||||
render: () => (
|
||||
<div className="flex max-w-md flex-col gap-5">
|
||||
{(['sm', 'md', 'lg'] as const).map((size) => (
|
||||
<ControlledInput key={size} size={size} label={`Size ${size}`} placeholder="Enter a value" />
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Themes: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-2xl gap-5 sm:grid-cols-2">
|
||||
{(['primary', 'secondary', 'success', 'warning', 'info'] as const).map((theme) => (
|
||||
<ControlledInput key={theme} theme={theme} label={theme} placeholder="Focus me" />
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const WithError: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input
|
||||
label="PAN number"
|
||||
placeholder="ABCDE1234F"
|
||||
error="Enter a valid PAN number."
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Required: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input label="Entity name" required placeholder="Required field" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const Disabled: Story = {
|
||||
render: () => (
|
||||
<div className="max-w-md">
|
||||
<Input label="Entity ID" value="ENT-000142" disabled onChange={() => {}} />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
export const BorderStyles: Story = {
|
||||
render: () => (
|
||||
<div className="grid max-w-xl gap-5 sm:grid-cols-3">
|
||||
<Input label="Default" placeholder="Solid" />
|
||||
<Input label="Dashed" placeholder="Dashed" dashedBorder />
|
||||
<Input label="Pill" placeholder="Rounded" roundedFull />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
|
||||
/** Requires the Remix Icon font; the `FeaturedInput` group below uses Lucide instead. */
|
||||
export const WithIconClass: Story = {
|
||||
args: { icon: 'ri-mail-line', placeholder: 'Email' },
|
||||
render: (args) => (
|
||||
<div className="max-w-md">
|
||||
<Input {...args} label="Email" />
|
||||
</div>
|
||||
),
|
||||
}
|
||||
Reference in new issue
Block a user