Skip to content

Commit bfc5462

Browse files
authored
Merge pull request #114 from goodpatch/fix/select
Selectの修正
2 parents 20a4912 + d575a6c commit bfc5462

5 files changed

Lines changed: 192 additions & 81 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Sparkle Design のバッジは、コンポーネントが Sparkle Design を使
213213

214214
現在のコンポーネントの実装状況は以下の表を参照してください。
215215

216-
| コンポーネント | 実装 | Storybook | レジストリ | Figma Code Connect | A11y チェック |
216+
| コンポーネント | 実装 | Storybook | レジストリ | Figma Code Connect | A11y チェック |
217217
| ----------------- | ---- | --------- | ---------- | ------------------ | ------------- |
218218
| Avatar ||||||
219219
| Badge ||||||
@@ -248,7 +248,7 @@ Sparkle Design のバッジは、コンポーネントが Sparkle Design を使
248248
| Popover ||||||
249249
| Radio ||||||
250250
| Segmented Control ||||||
251-
| Select |||| ||
251+
| Select |||| ||
252252
| Side Navigation ||||||
253253
| Skeleton ||||||
254254
| Slider ||||||
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from "react";
2+
import figma from "@figma/code-connect";
3+
import {
4+
Select,
5+
SelectContent,
6+
SelectItem,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "./index";
10+
11+
/**
12+
* -- This file was auto-generated by Code Connect --
13+
* `props` includes a mapping from your code props to Figma properties.
14+
* You should check this is correct, and update the `example` function
15+
* to return the code example you'd like to see in Figma
16+
*/
17+
18+
figma.connect(
19+
SelectTrigger,
20+
"https://www.figma.com/design/7alBZXZf65YgcII41TWT0r/Sparkle-Design?node-id=139%3A22300",
21+
{
22+
props: {
23+
// These props were automatically mapped based on your linked code:
24+
size: figma.enum("size", {
25+
sm: "sm",
26+
md: "md",
27+
lg: "lg",
28+
}),
29+
isInvalid: figma.enum("isInvalid", {
30+
false: false,
31+
true: true,
32+
}),
33+
disabled: figma.enum("state", {
34+
disabled: true,
35+
}),
36+
// No matching props could be found for these Figma properties:
37+
// "isFocused": figma.boolean('isFocused'),
38+
value: figma.string("value"),
39+
},
40+
example: props => (
41+
<Select>
42+
<SelectTrigger
43+
size={props.size}
44+
isInvalid={props.isInvalid}
45+
disabled={props.disabled}
46+
>
47+
<SelectValue placeholder={props.value} />
48+
</SelectTrigger>
49+
<SelectContent>
50+
<SelectItem value="option1">Option 1</SelectItem>
51+
<SelectItem value="option2">Option 2</SelectItem>
52+
<SelectItem value="option3">Option 3</SelectItem>
53+
</SelectContent>
54+
</Select>
55+
),
56+
}
57+
);

src/components/ui/select/index.stories.tsx

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,62 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import {
33
Select,
4-
SelectContent,
54
SelectGroup,
6-
SelectItem,
7-
SelectLabel,
8-
SelectTrigger,
95
SelectValue,
6+
SelectTrigger,
7+
SelectContent,
8+
SelectLabel,
9+
SelectItem,
1010
SelectSeparator,
11+
SelectScrollUpButton,
12+
SelectScrollDownButton,
13+
SelectTriggerProps,
1114
} from "./index";
1215

1316
const meta = {
1417
title: "Form/Select",
15-
component: SelectTrigger,
18+
component: Select,
19+
subcomponents: {
20+
SelectGroup,
21+
SelectValue,
22+
SelectTrigger,
23+
SelectContent,
24+
SelectLabel,
25+
SelectItem,
26+
SelectSeparator,
27+
SelectScrollUpButton,
28+
SelectScrollDownButton,
29+
},
1630
parameters: {
1731
layout: "centered",
1832
},
1933
tags: ["autodocs"],
20-
argTypes: {
21-
disabled: {
22-
control: "boolean",
23-
description: "セレクトを無効化します",
24-
defaultValue: false,
25-
},
26-
size: {
27-
control: { type: "radio" },
28-
options: ["sm", "md", "lg"],
29-
description: "セレクトのサイズを指定します",
30-
defaultValue: "md",
31-
},
32-
isInvalid: {
33-
control: "boolean",
34-
description: "エラー状態を指定します",
35-
defaultValue: false,
36-
},
37-
},
38-
} satisfies Meta<typeof SelectTrigger>;
34+
argTypes: {},
35+
} satisfies Meta<typeof Select>;
3936

4037
export default meta;
41-
type Story = StoryObj<typeof SelectTrigger>;
38+
type Story = StoryObj<SelectTriggerProps>;
39+
const argTypes: Story["argTypes"] = {
40+
disabled: {
41+
control: "boolean",
42+
defaultValue: false,
43+
},
44+
size: {
45+
control: { type: "radio" },
46+
options: ["sm", "md", "lg"],
47+
defaultValue: "md",
48+
},
49+
isInvalid: {
50+
control: "boolean",
51+
defaultValue: false,
52+
},
53+
};
4254

4355
export const Default: Story = {
56+
argTypes: argTypes,
4457
render: args => (
4558
<Select>
46-
<SelectTrigger className="w-[280px]" {...args}>
59+
<SelectTrigger className="w-[480px]" {...args}>
4760
<SelectValue placeholder="Select a timezone" />
4861
</SelectTrigger>
4962
<SelectContent>
@@ -111,6 +124,7 @@ export const Small: Story = {
111124
args: {
112125
size: "sm",
113126
},
127+
argTypes: argTypes,
114128
render: args => (
115129
<Select>
116130
<SelectTrigger className="w-[240px]" {...args}>
@@ -129,6 +143,7 @@ export const Medium: Story = {
129143
args: {
130144
size: "md",
131145
},
146+
argTypes: argTypes,
132147
render: args => (
133148
<Select>
134149
<SelectTrigger className="w-[240px]" {...args}>
@@ -147,6 +162,7 @@ export const Large: Story = {
147162
args: {
148163
size: "lg",
149164
},
165+
argTypes: argTypes,
150166
render: args => (
151167
<Select>
152168
<SelectTrigger className="w-[240px]" {...args}>
@@ -162,6 +178,7 @@ export const Large: Story = {
162178
};
163179

164180
export const Invalid: Story = {
181+
argTypes: argTypes,
165182
render: args => (
166183
<Select>
167184
<SelectTrigger className="w-[240px]" isInvalid {...args}>
@@ -177,6 +194,7 @@ export const Invalid: Story = {
177194
};
178195

179196
export const Disabled: Story = {
197+
argTypes: argTypes,
180198
render: args => (
181199
<Select>
182200
<SelectTrigger className="w-[240px]" disabled {...args}>
@@ -192,6 +210,7 @@ export const Disabled: Story = {
192210
};
193211

194212
export const DisabledWithInvalidState: Story = {
213+
argTypes: argTypes,
195214
render: args => (
196215
<Select>
197216
<SelectTrigger className="w-[240px]" disabled isInvalid {...args}>

0 commit comments

Comments
 (0)