Skip to content

Commit 92969b0

Browse files
authored
Hide dividers adjacent to selected item in SegmentedControl (#2691)
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English** and added an appropriate **label** to the PR. - [x] I wrote the commit message in **English** and to follow [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] I [added the **changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) about the changes that needed to be released. (or didn't have to) - [x] I wrote or updated **documentation** related to the changes. (or didn't have to) - [x] I wrote or updated **tests** related to the changes. (or didn't have to) - [x] I tested the changes in various browsers. (or didn't have to) - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox ## Related Issue <!-- Please link to issue if one exists --> <!-- Fixes #0000 --> ## Summary <!-- Please brief explanation of the changes made --> Hide dividers adjacent to selected item in `SegmentedControl` ## Details <!-- Please elaborate description of the changes --> 선택된 탭 요소의 양옆 디바이더가 보여지지 않는 기획을 적용합니다. 디바이더 컴포넌트를 분리하고 투명도 및 짧은 트랜지션을 적용했습니다. ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No ## References <!-- Please list any other resources or points the reviewer should be aware of --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - Style - SegmentedControl에서 선택된 항목 양옆의 구분선을 자동으로 숨겨 가독성과 집중도를 높였습니다. 숨김/표시 시 부드러운 불투명도 전환이 적용되며, 선택된 항목과 인접하지 않은 구분선은 기존처럼 표시됩니다. 선택 상태가 없을 때는 기존 동작을 유지합니다. - Chores - 패키지 패치 릴리스를 위한 변경 이력이 추가되었습니다. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1d8a26d commit 92969b0

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

.changeset/rude-cities-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@channel.io/bezier-react': patch
3+
---
4+
5+
Hide dividers adjacent to selected item in `SegmentedControl`.

packages/bezier-react/src/components/SegmentedControl/SegmentedControl.module.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,12 @@
186186
.SegmentedControlItemLabel {
187187
padding: 1px 0;
188188
}
189+
190+
.SegmentedControlDivider {
191+
opacity: 1;
192+
transition: opacity var(--transition-s);
193+
194+
&.hidden {
195+
opacity: 0;
196+
}
197+
}

packages/bezier-react/src/components/SegmentedControl/SegmentedControl.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ const [
6565
'SegmentedControlItemList'
6666
)
6767

68+
function SegmentedControlDivider({
69+
index,
70+
selectedItemIndex,
71+
}: {
72+
index: number
73+
selectedItemIndex: number | null
74+
}) {
75+
const isAdjacentToSelectedItem =
76+
!isNil(selectedItemIndex) &&
77+
(selectedItemIndex + 1 === index || selectedItemIndex === index)
78+
79+
return (
80+
<Divider
81+
className={classNames(
82+
styles.SegmentedControlDivider,
83+
isAdjacentToSelectedItem && styles.hidden
84+
)}
85+
withoutParallelIndent
86+
orientation="vertical"
87+
/>
88+
)
89+
}
90+
6891
function SegmentedControlItemListImpl<
6992
Type extends SegmentedControlType,
7093
Value extends string,
@@ -120,9 +143,9 @@ function SegmentedControlItemListImpl<
120143
{React.Children.map(children, (child, index) => (
121144
<>
122145
{index !== 0 && (
123-
<Divider
124-
withoutParallelIndent
125-
orientation="vertical"
146+
<SegmentedControlDivider
147+
index={index}
148+
selectedItemIndex={selectedItemIndex}
126149
/>
127150
)}
128151
<SegmentedControlItemContextProvider value={index}>

0 commit comments

Comments
 (0)