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

SegmentedControlの概要と使用上の注意を追加 #1141

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

o-kwr
Copy link

@o-kwr o-kwr commented Apr 22, 2024

課題・背景

https://smarthr.atlassian.net/browse/SD-635
https://smarthr.atlassian.net/browse/SD-576

基準充足!

やったこと

  • SegmentedControlの概要とどんなときに使うべきかを追加した

やらなかったこと

動作確認

Previewから確認お願いします!
https://deploy-preview-1141--smarthr-design-system.netlify.app/products/components/segmented-control/

キャプチャ

Before After

Copy link

netlify bot commented Apr 22, 2024

Deploy Preview for smarthr-design-system ready!

Name Link
🔨 Latest commit e94c860
🔍 Latest deploy log https://app.netlify.com/sites/smarthr-design-system/deploys/664b04dfa8a7fe000827c286
😎 Deploy Preview https://deploy-preview-1141--smarthr-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@o-kwr o-kwr marked this pull request as ready for review April 22, 2024 08:34
@o-kwr o-kwr requested review from versionfive, tosiiu and a team as code owners April 22, 2024 08:34
Copy link
Contributor

@versionfive versionfive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントしました!

@@ -5,8 +5,19 @@ description: ''
import { ComponentStory } from '@Components/ComponentStory'
import { ComponentPropsTable } from '@Components/ComponentPropsTable'

2つ以上の異なる状態を切り替えるためのコンポーネントです。[Switch](/products/components/switch/)はオンとオフの単純な2つの状態を切り替えるためのコンポーネントですが、SegmentedControlは任意の異なる状態を3つ以上持つことができます。

振る舞いとしては[RadioButton](/products/components/radio-button/)と同義とも言えますが、選択(状態の切り替え)によってビューに対して影響が発生することが特徴です。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

概要文が大きく、読み切る必要があるので、この一文はRadioButtonとの使い分けになると思うので、使用上の注意に項目をつくってもよいのではと思いました。

Comment on lines 18 to 19
### ビューの関心が切り替わるときには用いない
異なる状態の切り替えによって、扱うオブジェクトごとビューの関心が変わる場合はSegmentedControlではなく[TabBar](/products/components/tab-bar/)を用いるようにしてください。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このドキュメントはSegmentedControlの使い方を示すページなので、「こういうときに用いる」というスタンスで書けるならより適当かと思いました。

誤った使い方が多いから「このときは使わないで」を示す使い方もあると思いますが、SegmentedControlとTabBarに関しては「どっちを使うとよい?」という迷いが出発点なので、「こういうときにSegmentedControlを使ってね」中心に書けると良さそうだと思いました

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SegmentedControl も TabBar も、なんだったら SideNav などをも包括したパターンの可能性もある?

Copy link
Contributor

@oti oti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SegmentControl を使うにふさわしい、同じオブジェクトの状態を切り替えるために用いることがスッとわかる具体例が欲しいと思いました!

Copy link
Contributor

@tosiiu tosiiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既出のコメントと同じく、近しいコンポーネントとの使い分けが迷うポイントだと思うので独立した章としてSwitchのように記載されているといいなと思いました!

Copy link
Member

@MasafumiKabe MasafumiKabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既出のコメントと同じお気持ちです!
類似のコンポーネントとの違いなどについて割と序盤から言及しているので、まずは SegmentedContorol 単品について簡単に説明できていると良いと思いました!

Copy link
Contributor

@oti oti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いくつかコメントしました!

2つ以上の異なる状態を切り替えるためのコンポーネントです。状態を切り替えることによって影響下のビューに対して作用し、主にオブジェクトのフィルタリングやモードの変化を促します。
ビューに存在するオブジェクト自体は変わらないが、フィルタリングや見え方を変えたいときに適しているコンポーネントです。


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```tsx editable codeBlock
<SegmentedControl size="s" options={[
{ value: 'list view', content: 'リスト表示' },
{ value: 'map view', content: 'マップ表示' },
]} value="list view" />

ここに具体例を書くのはだめですか?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComponentStoryがそれを担っている認識

```

### Switch との違い
Switchはオン・オフのどちらか1つの状態を表します。対する概念ではあるが、異なる状態を表す場合はSegmentedControlを使ってください。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このページの主体はSegmentedControlなので主従が逆だと思いました。

e.g)SegmentedControlは〜〜です。〜〜の場合はSwitchを使用してください。

Switchはオン・オフのどちらか1つの状態を表します。対する概念ではあるが、異なる状態を表す場合はSegmentedControlを使ってください。

### RadioButton との違い
振る舞いとしては[RadioButton](/products/components/radio-button/)と同義とも言えますが、選択(状態の切り替え)によって即座にビューに対して影響が発生することが特徴です。絞り込み時にsubmitが発生する場合はRadioButtonの使用も検討してみてください。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

うまく説明できているように感じなかったのと、「絞り込み時に」という言葉が急に出てきたのが引っかかりました。SegmentedControl か Tab か Switch か RadioButton かという話のなかに、絞り込みという認識はないように思います。言いたいことは「表示切替時に〜」なのかな?

Copy link
Contributor

@versionfive versionfive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前提の確認をSlackでしておりますー

## 使用上の注意

### TabBar との違い
ビューに対してフィルタリングしたり見え方を変えたいときに[TabBar](/products/components/tab-bar/)も用いることができますが、TabBarの場合はそれぞれのタブに内包されるオブジェクト自体が異なる場合に使うことが適しています。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ビューに対してフィルタリングしたり見え方を変えたいときに[TabBar](/products/components/tab-bar/)も用いることができますが、TabBarの場合はそれぞれのタブに内包されるオブジェクト自体が異なる場合に使うことが適しています
ビューに対してフィルタリングしたり見え方を変えたいときに[TabBar](/products/components/tab-bar/)を使う場合がありますが、TabBarはそれぞれのタブに内包されるオブジェクト自体が異なる場合に使うことが適しています
一方、SegmentedControlはそれぞれのセグメントに内包されるオブジェクトが同一である場合に使うことが適しています。

書きっぷりはこれでいいのかわかりませんが、SegmentedControlはどうだ、も書いてほしいです。

Copy link
Contributor

@tosiiu tosiiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

切り替えの対象として「状態・フィルタリング・モード・見た目」が挙げられていますが、フィルタリングやモードの変化が何を示すのか明確に分かりませんでした...!何かしら説明があるとより分かりやすいと感じました

```

### Switch との違い
Switchはオン・オフのどちらか1つの状態を表します。対する概念ではあるが、異なる状態を表す場合はSegmentedControlを使ってください。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいですがリンクが欲しいです!

Suggested change
Switchはオン・オフのどちらか1つの状態を表します。対する概念ではあるが、異なる状態を表す場合はSegmentedControlを使ってください。
[Switch](/products/components/switch/)はオン・オフのどちらか1つの状態を表します。対する概念ではあるが、異なる状態を表す場合はSegmentedControlを使ってください。

Comment on lines +8 to +9
2つ以上の異なる状態を切り替えるためのコンポーネントです。状態を切り替えることによって影響下のビューに対して作用し、主にオブジェクトのフィルタリングやモードの変化を促します。
ビューに存在するオブジェクト自体は変わらないが、フィルタリングや見え方を変えたいときに適しているコンポーネントです。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMOですが、概要としては2つ以上の異なる状態を切り替えるコンポーネントであることと主な用途が説明されていれば十分に感じました!オブジェクトの変更には使わないことは「TabBarとの違い」で言及できると十分そうです!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants