-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate
Divider
component with scss (#1861)
<!-- 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 --> - #1733 ## Summary <!-- Please brief explanation of the changes made --> - `Divider` 컴포넌트의 스타일링을 styled-components 에서 scss 으로 변경합니다. - 기존의 조건부 스타일링을 scss기반의 nested한 형태로 구현합니다 ## Details <!-- Please elaborate description of the changes --> - `Divider` 컴포넌트의 인터페이스에 `MarginProps`가 추가됩니다. ### 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 --> - None
- Loading branch information
1 parent
062f8a8
commit e91c4aa
Showing
7 changed files
with
107 additions
and
223 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/bezier-react/src/components/Divider/Divider.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@layer components { | ||
.Divider { | ||
--b-divider-indent-size: 6px; | ||
|
||
border-radius: var(--radius-1); | ||
background-color: var(--bdr-black-light); | ||
|
||
&.horizontal { | ||
width: calc(100% - 2 * var(--b-divider-indent-size)); | ||
height: var(--b-divider-thickness); | ||
margin: var(--b-divider-indent-size); | ||
|
||
&.without-indent { | ||
width: 100%; | ||
margin: 0; | ||
} | ||
&.without-side-indent { | ||
width: 100%; | ||
margin-left: 0; | ||
margin-right: 0; | ||
} | ||
&.without-parallel-indent { | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
&.vertical { | ||
width: var(--b-divider-thickness); | ||
height: calc(100% - 2 * var(--b-divider-indent-size)); | ||
margin: var(--b-divider-indent-size); | ||
|
||
&.without-indent { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
&.without-side-indent { | ||
height: 100%; | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
&.without-parallel-indent { | ||
margin-left: 0; | ||
margin-right: 0; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
packages/bezier-react/src/components/Divider/Divider.styled.ts
This file was deleted.
Oops, something went wrong.
133 changes: 7 additions & 126 deletions
133
packages/bezier-react/src/components/Divider/Divider.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,63 @@ | ||
import React, { forwardRef } from 'react' | ||
import React, { | ||
type CSSProperties, | ||
forwardRef, | ||
} from 'react' | ||
|
||
import * as SeparatorPrimitive from '@radix-ui/react-separator' | ||
import classNames from 'classnames' | ||
|
||
import type DividerProps from './Divider.types' | ||
|
||
import * as Styled from './Divider.styled' | ||
import styles from './Divider.module.scss' | ||
|
||
export const DIVIDER_TEST_ID = 'bezier-react-divider' | ||
|
||
const Divider = forwardRef(( | ||
{ | ||
testId = DIVIDER_TEST_ID, | ||
orientation = 'horizontal', | ||
decorative, | ||
withoutSideIndent = false, | ||
withoutParallelIndent = false, | ||
withoutIndent = false, | ||
...rest | ||
}: DividerProps, | ||
forwardedRef: React.Ref<HTMLElement>, | ||
export const DIVIDER_THICKNESS = 1 | ||
|
||
/** | ||
* `Divider` is a component to visually or semantically separate content. | ||
* | ||
* @example | ||
* | ||
* ```tsx | ||
* <Divider | ||
* withoutSideIndent | ||
* /> | ||
* ``` | ||
*/ | ||
export const Divider = forwardRef<HTMLDivElement, DividerProps>(({ | ||
orientation = 'horizontal', | ||
decorative, | ||
testId = DIVIDER_TEST_ID, | ||
withoutSideIndent = false, | ||
withoutParallelIndent = false, | ||
withoutIndent = false, | ||
style, | ||
className, | ||
...rest | ||
}, forwardedRef, | ||
) => ( | ||
<SeparatorPrimitive.Root | ||
asChild | ||
orientation={orientation} | ||
decorative={decorative} | ||
> | ||
<Styled.Divider | ||
<div | ||
ref={forwardedRef} | ||
data-testid={testId} | ||
orientation={orientation} | ||
decorative={decorative} | ||
withoutSideIndent={withoutSideIndent} | ||
withoutParallelIndent={withoutParallelIndent} | ||
withoutIndent={withoutIndent} | ||
style={{ | ||
'--b-divider-thickness': `${DIVIDER_THICKNESS}px`, | ||
...style, | ||
} as CSSProperties} | ||
className={classNames( | ||
styles.Divider, | ||
styles[orientation], | ||
withoutIndent && styles['without-indent'], | ||
withoutParallelIndent && styles['without-parallel-indent'], | ||
withoutSideIndent && styles['without-side-indent'], | ||
className, | ||
)} | ||
{...rest} | ||
/> | ||
</SeparatorPrimitive.Root> | ||
)) | ||
|
||
export default Divider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.