Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(admin-ui): Select component #4365

Merged
merged 28 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
376b400
feat: create Select component
leopuleo Oct 29, 2024
15a7d91
feat: add Select component
leopuleo Oct 29, 2024
ac54ff6
wip: trigger variants
leopuleo Oct 30, 2024
0dedbf9
refactor: vm and presenter
leopuleo Nov 4, 2024
c56343b
feat: add SelectOption
leopuleo Nov 4, 2024
51219f3
refactor: change types
leopuleo Nov 4, 2024
91f6273
refactor: handle variants and sizes
leopuleo Nov 4, 2024
f957851
chore: merge
leopuleo Nov 5, 2024
9555fc0
wip: little changes
leopuleo Nov 5, 2024
42bda36
feat: add form variant
leopuleo Nov 5, 2024
2bf7a6a
docs: improve stories
leopuleo Nov 5, 2024
f93641a
refactor: remove form component
leopuleo Nov 6, 2024
3e5a2ff
Merge branch 'feat/new-admin-ui' into leo/feat/ui-select
leopuleo Nov 8, 2024
f4c4f2e
wip: select tw classNames
leopuleo Nov 12, 2024
23b4537
Merge branch 'feat/new-admin-ui' into leo/feat/ui-select
leopuleo Nov 12, 2024
e0cecd3
wip: start and end icon
leopuleo Nov 12, 2024
cba984b
wip: select menu
leopuleo Nov 12, 2024
e6bdddc
Merge branch 'feat/new-admin-ui' into leo/feat/ui-select
leopuleo Nov 13, 2024
cc16f6c
feat: tw classNames
leopuleo Nov 13, 2024
ac98b2f
fix: trigger content size
leopuleo Nov 13, 2024
b1ab07d
fix: selected item
leopuleo Nov 14, 2024
8343693
feat: add onValueReset callback and reset icon
leopuleo Nov 14, 2024
19b3e9c
chore: remove logs
leopuleo Nov 14, 2024
52b4a42
Merge branch 'feat/new-admin-ui' into leo/feat/ui-select
leopuleo Nov 15, 2024
f56f16b
refactor: optimize presenter params
leopuleo Nov 21, 2024
94a6cb3
refactor: rename nested VMs
leopuleo Nov 21, 2024
52270ec
refactor: return presenter with init
leopuleo Nov 21, 2024
74d57f3
Merge branch 'feat/new-admin-ui' into leo/feat/ui-select
leopuleo Nov 21, 2024
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
1 change: 1 addition & 0 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@radix-ui/react-accessible-icon": "^1.1.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slider": "^1.2.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
Expand Down
327 changes: 327 additions & 0 deletions packages/admin-ui/src/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
import React, { useState } from "react";
import type { Meta, StoryObj } from "@storybook/react";
import { ReactComponent as SearchIcon } from "@material-design-icons/svg/outlined/search.svg";
import { ReactComponent as ChevronRight } from "@material-design-icons/svg/outlined/chevron_right.svg";
import { Select } from "./Select";

const meta: Meta<typeof Select> = {
title: "Components/Select",
component: Select,
tags: ["autodocs"],
argTypes: {
onValueChange: { action: "onValueChange" },
onOpenChange: { action: "onOpenChange" },
variant: { control: "select", options: ["primary", "secondary", "ghost"] },
size: { control: "select", options: ["md", "lg", "xl"] },
disabled: { control: "boolean" },
invalid: { control: "boolean" }
},
parameters: {
layout: "fullscreen"
},
decorators: [
Story => (
<div className="w-1/3 h-64 mx-auto flex justify-center items-center">
<Story />
</div>
)
],
render: args => {
const [value, setValue] = useState(args.value);
return <Select {...args} value={value} onValueChange={setValue} />;
}
};

export default meta;

type Story = StoryObj<typeof Select>;

export const Default: Story = {
args: {
options: [
"Eastern Standard Time (EST)",
"Central Standard Time (CST)",
"Pacific Standard Time (PST)",
"Greenwich Mean Time (GMT)",
"Central European Time (CET)",
"Central Africa Time (CAT)",
"India Standard Time (IST)",
"China Standard Time (CST)",
"Japan Standard Time (JST)",
"Australian Western Standard Time (AWST)",
"New Zealand Standard Time (NZST)",
"Fiji Time (FJT)",
"Argentina Time (ART)",
"Bolivia Time (BOT)",
"Brasilia Time (BRT)"
]
}
};

export const MediumSize: Story = {
args: {
...Default.args,
size: "md"
}
};

export const LargeSize: Story = {
args: {
...Default.args,
size: "lg"
}
};

export const ExtraLargeSize: Story = {
args: {
...Default.args,
size: "xl"
}
};

export const WithCustomPlaceholder: Story = {
args: {
...Default.args,
placeholder: "Custom placeholder"
}
};

export const WithStartIcon: Story = {
args: {
...Default.args,
startIcon: <SearchIcon />
}
};

export const WithEndIconIcon: Story = {
args: {
...Default.args,
endIcon: <SearchIcon />
}
};

export const WithStartAndEndIcons: Story = {
args: {
...Default.args,
startIcon: <SearchIcon />,
endIcon: <ChevronRight />
}
};

export const PrimaryVariant: Story = {
args: {
...Default.args,
variant: "primary"
}
};

export const PrimaryVariantDisabled: Story = {
args: {
...PrimaryVariant.args,
disabled: true
}
};

export const PrimaryVariantInvalid: Story = {
args: {
...PrimaryVariant.args,
invalid: true
}
};

export const SecondaryVariant: Story = {
args: {
variant: "secondary",
placeholder: "Custom placeholder"
}
};

export const SecondaryVariantDisabled: Story = {
args: {
...SecondaryVariant.args,
disabled: true
}
};

export const SecondaryVariantInvalid: Story = {
args: {
...SecondaryVariant.args,
invalid: true
}
};

export const GhostVariant: Story = {
args: {
variant: "ghost",
placeholder: "Custom placeholder"
}
};

export const GhostVariantDisabled: Story = {
args: {
...GhostVariant.args,
disabled: true
}
};

export const GhostVariantInvalid: Story = {
args: {
...GhostVariant.args,
invalid: true
}
};

export const WithFormattedOptions: Story = {
args: {
...Default.args,
options: [
{ label: "Eastern Standard Time (EST)", value: "est" },
{ label: "Central Standard Time (CST)", value: "cst" },
{ label: "Pacific Standard Time (PST)", value: "pst" },
{ label: "Greenwich Mean Time (GMT)", value: "gmt" },
{ label: "Central European Time (CET)", value: "cet" },
{ label: "Central Africa Time (CAT)", value: "cat" },
{ label: "India Standard Time (IST)", value: "ist" },
{ label: "China Standard Time (CST)", value: "cst_china" },
{ label: "Japan Standard Time (JST)", value: "jst" },
{ label: "Australian Western Standard Time (AWST)", value: "awst" },
{ label: "New Zealand Standard Time (NZST)", value: "nzst" },
{ label: "Fiji Time (FJT)", value: "fjt" },
{ label: "Argentina Time (ART)", value: "art" },
{ label: "Bolivia Time (BOT)", value: "bot" },
{ label: "Brasilia Time (BRT)", value: "brt" }
]
}
};

export const WithOptionGroups: Story = {
args: {
...Default.args,
options: [
{
label: "North America",
options: [
{ label: "Eastern Standard Time (EST)", value: "est" },
{ label: "Central Standard Time (CST)", value: "cst" },
{ label: "Pacific Standard Time (PST)", value: "pst" }
]
},
{
label: "Europe & Africa",
options: [
{ label: "Greenwich Mean Time (GMT)", value: "gmt" },
{ label: "Central European Time (CET)", value: "cet" },
{ label: "Central Africa Time (CAT)", value: "cat" }
]
},
{
label: "Asia",
options: [
{ label: "India Standard Time (IST)", value: "ist" },
{ label: "China Standard Time (CST)", value: "cst_china" },
{ label: "Japan Standard Time (JST)", value: "jst" }
]
},
{
label: "Australia & Pacific",
options: [
{ label: "Australian Western Standard Time (AWST)", value: "awst" },
{ label: "New Zealand Standard Time (NZST)", value: "nzst" },
{ label: "Fiji Time (FJT)", value: "fjt" }
]
},
{
label: "South America",
options: [
{ label: "Argentina Time (ART)", value: "art" },
{ label: "Bolivia Time (BOT)", value: "bot" },
{ label: "Brasilia Time (BRT)", value: "brt" }
]
}
]
}
};

export const WithSeparators: Story = {
args: {
...Default.args,
options: [
{ label: "Eastern Standard Time (EST)", value: "est" },
{ label: "Central Standard Time (CST)", value: "cst" },
{ label: "Pacific Standard Time (PST)", value: "pst", separator: true },
{ label: "Greenwich Mean Time (GMT)", value: "gmt" },
{ label: "Central European Time (CET)", value: "cet" },
{ label: "Central Africa Time (CAT)", value: "cat", separator: true },
{ label: "India Standard Time (IST)", value: "ist" },
{ label: "China Standard Time (CST)", value: "cst_china" },
{ label: "Japan Standard Time (JST)", value: "jst", separator: true },
{ label: "Australian Western Standard Time (AWST)", value: "awst" },
{ label: "New Zealand Standard Time (NZST)", value: "nzst" },
{ label: "Fiji Time (FJT)", value: "fjt", separator: true },
{ label: "Argentina Time (ART)", value: "art" },
{ label: "Bolivia Time (BOT)", value: "bot" },
{ label: "Brasilia Time (BRT)", value: "brt" }
]
}
};

export const WithDisabledOptions: Story = {
args: {
options: [
{ label: "Eastern Standard Time (EST)", value: "est", disabled: true },
{ label: "Central Standard Time (CST)", value: "cst", disabled: true },
{ label: "Pacific Standard Time (PST)", value: "pst", disabled: true },
{ label: "Greenwich Mean Time (GMT)", value: "gmt" },
{ label: "Central European Time (CET)", value: "cet" },
{ label: "Central Africa Time (CAT)", value: "cat" },
{ label: "India Standard Time (IST)", value: "ist" },
{ label: "China Standard Time (CST)", value: "cst_china" },
{ label: "Japan Standard Time (JST)", value: "jst" },
{ label: "Australian Western Standard Time (AWST)", value: "awst" },
{ label: "New Zealand Standard Time (NZST)", value: "nzst" },
{ label: "Fiji Time (FJT)", value: "fjt" },
{ label: "Argentina Time (ART)", value: "art" },
{ label: "Bolivia Time (BOT)", value: "bot" },
{ label: "Brasilia Time (BRT)", value: "brt" }
]
}
};

export const WithExternalValueControl: Story = {
args: {
...Default.args,
options: [
"Eastern Standard Time (EST)",
"Central Standard Time (CST)",
"Pacific Standard Time (PST)",
"Greenwich Mean Time (GMT)",
"Central European Time (CET)",
"Central Africa Time (CAT)",
"India Standard Time (IST)",
"China Standard Time (CST)",
"Japan Standard Time (JST)",
"Australian Western Standard Time (AWST)",
"New Zealand Standard Time (NZST)",
"Fiji Time (FJT)",
"Argentina Time (ART)",
"Bolivia Time (BOT)",
"Brasilia Time (BRT)"
]
},
render: args => {
const [value, setValue] = useState(args.value);
return (
<div className={"w-full"}>
<div>
<Select {...args} value={value} onValueChange={value => setValue(value)} />
</div>
<div className={"mt-4 text-center"}>
<button onClick={() => setValue("")}>{"Reset"}</button>
</div>
<div className={"mt-4 text-center"}>
Current selected value: <pre>{value}</pre>
</div>
</div>
);
}
};
Loading