Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 118 additions & 53 deletions src/components/MUI/Inputs/TextField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const meta: Meta<TFArgs> = {
argTypes: {
variant: {
control: { type: "select" },
options: ["outlined", "filled,", "standard"].map((s) =>
s.replace(",", ""),
),
options: ["outlined", "filled", "standard"],
},
color: {
control: { type: "select" },
Expand Down Expand Up @@ -42,8 +40,8 @@ const meta: Meta<TFArgs> = {
size: "medium",
margin: "none",
type: "text",
label: "Your name",
placeholder: "Type here…",
label: "Sample name",
placeholder: "Enter sample name",
helperText: "",
error: false,
required: false,
Expand All @@ -64,56 +62,98 @@ export const Basic: Story = {
export const Variants: Story = {
render: (args) => (
<Box style={{ display: "grid", gap: 12 }}>
<TextField {...args} variant="outlined" label="Outlined" />
<TextField {...args} variant="filled" label="Filled" />
<TextField {...args} variant="standard" label="Standard" />
<TextField
{...args}
variant="outlined"
label="Outlined"
helperText="Default for forms, planning and configuration"
/>
<TextField
{...args}
variant="filled"
label="Filled"
helperText="Use for live instrument control"
/>
<TextField
{...args}
variant="standard"
label="Standard"
helperText="Use rarely for compact or inline contexts"
/>
</Box>
),
args: { color: "primary", helperText: "" },
args: { color: "primary" },
};

export const SizesAndColors: Story = {
render: (args) => (
<Box style={{ display: "grid", gap: 12 }}>
<Box style={{ display: "flex", gap: 12 }}>
<TextField
{...args}
size="small"
color="primary"
label="Small / primary"
/>
<TextField
{...args}
size="small"
color="secondary"
label="Small / secondary"
/>
</Box>
<Box style={{ display: "flex", gap: 12 }}>
<TextField
{...args}
size="medium"
color="success"
label="Medium / success"
/>
<TextField
{...args}
size="medium"
color="error"
label="Medium / error"
/>
</Box>
export const DefaultInput: Story = {
name: "Default input",
render: () => (
<Box style={{ display: "grid", gap: 12, maxWidth: 420 }}>
<TextField
variant="outlined"
label="Sample name"
placeholder="Enter sample name"
/>
<TextField
variant="outlined"
label="Proposal number"
placeholder="MX12345"
/>
</Box>
),
};

export const LiveInstrumentInput: Story = {
name: "Live instrument input",
render: () => (
<Box style={{ display: "grid", gap: 12, maxWidth: 420 }}>
<TextField
variant="filled"
color="primary"
label="Motor position"
placeholder="0.00"
helperText="Use filled inputs when changes affect a live instrument or running system."
/>
<TextField
variant="filled"
color="primary"
label="Exposure"
placeholder="0.5"
helperText="Filled inputs should be used deliberately in operational contexts."
/>
</Box>
),
args: { variant: "outlined", helperText: "" },
};

export const States: Story = {
render: (args) => (
<Box style={{ display: "grid", gap: 12 }}>
<TextField {...args} required label="Required" helperText="* Required" />
<TextField {...args} error label="Error" helperText="Invalid value" />
<TextField {...args} label="Default" helperText="Ready for input" />

<TextField
{...args}
label="Read-only"
value="Current value"
helperText="Value can be viewed and copied but not edited"
InputProps={{ readOnly: true }}
/>

<TextField
{...args}
required
label="Required"
helperText="Required field"
/>

<TextField
{...args}
error
label="Error"
helperText="Enter a valid value"
/>

<TextField {...args} disabled label="Disabled" placeholder="Disabled" />

<Box style={{ maxWidth: 420 }}>
<TextField
{...args}
Expand All @@ -124,29 +164,48 @@ export const States: Story = {
</Box>
</Box>
),
args: { variant: "outlined", color: "primary" },
args: {
variant: "outlined",
color: "primary",
},
};

export const Validation: Story = {
render: () => (
<Box style={{ display: "grid", gap: 12, maxWidth: 420 }}>
<TextField
variant="outlined"
label="Energy"
placeholder="12.4"
helperText="Enter energy in keV."
/>
<TextField
variant="outlined"
error
label="Energy"
placeholder="12.4"
helperText="Energy must be between 5 and 25 keV."
/>
</Box>
),
};

export const Multiline: Story = {
args: {
multiline: true,
rows: 4,
label: "Message",
placeholder: "Write a few lines…",
label: "Notes",
placeholder: "Add notes for this setup…",
helperText:
"Use multiline fields for comments, notes, or longer descriptions.",
},
render: (args) => <TextField {...args} />,
};

export const InputTypes: Story = {
render: (args) => (
<Box style={{ display: "grid", gap: 12 }}>
<Box style={{ display: "grid", gap: 12, maxWidth: 420 }}>
<TextField {...args} type="text" label="Text" placeholder="Text…" />
<TextField
{...args}
type="password"
label="Password"
placeholder="••••••••"
/>
<TextField {...args} type="number" label="Number" placeholder="0" />
<TextField
{...args}
Expand All @@ -155,6 +214,12 @@ export const InputTypes: Story = {
placeholder="name@example.com"
/>
<TextField {...args} type="search" label="Search" placeholder="Find…" />
<TextField
{...args}
type="password"
label="Password"
placeholder="••••••••"
/>
</Box>
),
args: { variant: "outlined", helperText: "" },
Expand Down
Loading
Loading