-
Notifications
You must be signed in to change notification settings - Fork 10
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 <DualListBox />
component
#1442
Conversation
🦋 Changeset detectedLatest commit: 66882d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for ingred-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
<SelectableList />
component<DualListBox />
component
f0c4815
to
49a401f
Compare
674e6e8
to
60eb2d4
Compare
items?: Item[]; | ||
}; | ||
|
||
export type UnselectedItem = Item & { selected?: boolean }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selected は持たせたくないので剥がす方向で進めようかな
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selected と unselected それぞれの list のみであれこれをしたい
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応した
e891459
7f0401b
to
589c87c
Compare
remove selected state refactor changeset fix: style upgrade snapshot fix style fix fix: divider import toggle remove toggle checked and unchecked text fix: style rename
589c87c
to
d5aa835
Compare
d38e97e
to
dd6f0ab
Compare
dd6f0ab
to
cd047b9
Compare
export type ItemBase = { | ||
id: string; | ||
label: string; | ||
}; | ||
|
||
export type ItemWithInverse = ItemBase & { isInverse: boolean } & { | ||
items?: (ItemBase & { isInverse: boolean })[]; | ||
}; | ||
export type ItemWithoutInverse = ItemBase & { isInverse?: undefined } & { | ||
items?: (ItemBase & { isInverse?: undefined })[]; | ||
}; | ||
|
||
export type Item = ItemWithInverse | ItemWithoutInverse; | ||
|
||
/** | ||
* @memo 内部で状態を保持するための型 | ||
*/ | ||
export type UnselectedItem = Item & { selected?: boolean }; | ||
|
||
type BaseProps = { | ||
onAdd?: (id: string) => void; | ||
onRemove?: (id: string) => void; | ||
}; | ||
|
||
export type DualListBoxProps = | ||
| (BaseProps & { | ||
unselectedItems: ItemWithInverse[]; | ||
selectedItems: ItemWithInverse[]; | ||
onToggleInverse?: (id: string) => void; | ||
}) | ||
| (BaseProps & { | ||
unselectedItems: ItemWithoutInverse[]; | ||
selectedItems: ItemWithoutInverse[]; | ||
onToggleInverse?: undefined; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これを担保するための型定義
- onToggleInverse という prop が渡されたら Item の isInverse というプロパティは必須
- onToggleInverse という prop が渡されなかったら Item の isInverse というプロパティは渡せない
<Accordion | ||
style={{ | ||
borderTop: "none", | ||
borderBottom: "none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bottomの記述はなくてもよさそう?(オーバーライド元に記述がないような気がする
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本当だ、直しますmm
{item.items ? ( | ||
<Styled.AccordionWrapper key={item.id}> | ||
<Accordion | ||
style={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style
だと「一体どこの...?」となるので、〇〇Styleみたいな命名の方が良いのかもね〜
DualListBox起因でオーバーライドするなら、DualListBox側でどうにかする方がよいな〜という気がしている。
Styled.UnselectedItem
のborderを動的に変えるとか。
あるいはAccordion
が存在する場合にはノンカテゴライズなitemを許容しないとか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あんまりいい方法が思いつかなかったのですが、こういうのどうですかね?
- Accordion の border-top は Container で管理する
- UnselectedRenderer(命名変えます)では styled.ts で Accordion コンポーネントを継承して border-top を打ち消す
こんな感じにしておくと、Accordion の挙動は保ったままスタイルの上書きができそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それでもよさそう、どちらかというとStyled.UnselectedItem
側が前のindexの要素をみてスタイルを変える方が良いかなーと思った。(例えば色を変えたりしていると「デザインシステムとしてどうなん?」となるが、今回はborderを消しているだけなので問題なさそう)
6cc169c
to
f628f1f
Compare
export type ItemBase = { | ||
id: string; | ||
label: string; | ||
}; | ||
|
||
export type DualListBoxItemSelectedWithToggle = ItemBase & { checked: boolean }; | ||
export type DualListBoxItemSelectedWithoutToggle = ItemBase & { | ||
checked?: undefined; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedなitemたちってlabelないと困ることあるかな...?
type BaseProps = {
onAdd?: (id: string) => void;
onRemove?: (id: string) => void;
};
型的に更新時はidしかこないので、
DualListBoxItemSelectedWithToggle
型を作るためにlabelを探す必要がある- 何かしらからmapして捜査する
手間があるから、label
ない方が使う側としてはラクかなと思った!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label は表示用なので必要だと思うのですが、そういう意味ではなくてですか?
https://github.com/voyagegroup/ingred-ui/pull/1442/files#diff-af9a79e44ba16f954adf4cbd27213bbdba81410523de65fc30ff3ed96f55fbdfR32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ないほうが使う側として便利じゃないのかなーという話なので、そういう意味じゃないかも!
label自体は<DualListBox />
で見つけ出せるよなーと思った!
こちら側でよしなに管理できる内容のことをユーザー側で意識させたくないかなって
言葉を借りるとこんな感じかな。id
さえあればlabel
も引き当てられるしなぁ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あー、選択候補から探し出せるからってことですかね?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そういうかんじ!
<DualListBox />
内でやらない現状の実装だと、「選択候補から探し出す(labelを探す)」ことをユーザー側でやらなくちゃいけない気がする。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toggleも考慮すると
export type selectedItems = {
id: string;
checked?: boolean;
};
こういう感じかな。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なんかその感じだと選択候補の方に checked は不要ということを想定しているんですかね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
項目によってデフォルトで checked かどうかを選択候補リストから指定することを想定していましたが、それも違う形になりそう...??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なんかその感じだと選択候補の方に checked は不要ということを想定しているんですかね
たしかに。
#1442 (comment)
この辺の論点で「selectedItems
にlabel
いらんやろ」という話をしようとしてただけだけど、風呂敷を広げるとそういう話にもなりそう。
項目によってデフォルトで checked かどうかを選択候補リストから指定することを想定していましたが、それも違う形になりそう...??
そうなりそう。
今の実装だとデフォルトの選択肢を定義する際にcandidateItems
とselectedItems
をよしなにしないといけないから、それはそれで使いづらいかもなと思った。
- 候補リスト -> candidateItems
- 選択情報 -> selectedItems
という棲み分けがシンプルで間違えにくいんじゃないかな...:thinking:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今の実装だとデフォルトの選択肢を定義する際にcandidateItemsとselectedItemsをよしなにしないといけないから、それはそれで使いづらいかもなと思った。
まあ確かに、candidateItems と selectedItems の id と label は一致してる必要があるのでそれは使いづらいとは思いました。そこが仕組みで制御できるわけでもないし。
@@ -7,7 +7,6 @@ import { useTheme } from "../../themes"; | |||
|
|||
export type ItemBase = { | |||
id: string; | |||
label: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label は持たないようにした
fix interface refactor
d464afa
to
2ba313b
Compare
結局型としてはこんな感じ。
|
7a625d0
to
7800d3a
Compare
Co-authored-by: Yutaro Hayashi <yut.hayashi@cartahd.com>
https://www.figma.com/file/fUeoFzCzL4rwRuW7CFW4m0/INGRED-UI?node-id=1714%3A1282&mode=dev