Skip to content

Commit

Permalink
refactor(divider): use css variable instead of scss variable
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwooseong committed Dec 28, 2023
1 parent e8a2034 commit 431bea4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 8 additions & 9 deletions packages/bezier-react/src/components/Divider/Divider.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
@layer components {
$DIVIDER_THICKNESS: 1;
$DIVIDER_INDENT_SIZE: 6;

.Divider {
--b-divider-indent-size: 6px;

border-radius: var(--radius-1);
background-color: var(--bdr-black-light);

&.horizontal {
width: calc(100% - 2 * #{$DIVIDER_INDENT_SIZE}px);
height: #{$DIVIDER_THICKNESS}px;
margin: #{$DIVIDER_INDENT_SIZE}px;
width: calc(100% - 2 * var(--b-divider-indent-size));
height: var(--b-divider-thickness);
margin: var(--b-divider-indent-size);

&.without-indent {
width: 100%;
Expand All @@ -27,9 +26,9 @@
}

&.vertical {
width: #{$DIVIDER_THICKNESS}px;
height: calc(100% - 2 * #{$DIVIDER_INDENT_SIZE}px);
margin: #{$DIVIDER_INDENT_SIZE}px;
width: var(--b-divider-thickness);
height: calc(100% - 2 * var(--b-divider-indent-size));
margin: var(--b-divider-indent-size);

&.without-indent {
height: 100%;
Expand Down
10 changes: 8 additions & 2 deletions packages/bezier-react/src/components/Divider/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React, { forwardRef } from 'react'
import React, {
type CSSProperties,
forwardRef,
} from 'react'

import * as SeparatorPrimitive from '@radix-ui/react-separator'
import classNames from 'classnames'
Expand Down Expand Up @@ -42,7 +45,10 @@ export const Divider = forwardRef<HTMLDivElement, DividerProps>(({
<div
ref={forwardedRef}
data-testid={testId}
style={style}
style={{
'--b-divider-thickness': `${DIVIDER_THICKNESS}px`,
...style,
} as CSSProperties}
className={classNames(
styles.Divider,
styles[orientation],
Expand Down

0 comments on commit 431bea4

Please sign in to comment.