11'use client' ;
22
3- import React from "react" ;
4- import { useDesign } from "../providers/design-provider" ;
3+ import React from 'react' ;
4+ import * as SeparatorPrimitive from '@radix-ui/react-separator' ;
5+ import styled from 'styled-components' ;
6+ import { useDesign } from '..' ;
57
6- export type DividerProps = { direction ?: 'horizontal' | 'vertical' } & React . HTMLProps < HTMLHRElement > ;
8+ export type DividerProps = React . ComponentProps < typeof SeparatorPrimitive . Root > ;
79
8- const Divider = React . forwardRef < HTMLHRElement , DividerProps > (
9- ( { direction= 'horizontal' } , ref ) => {
10- const { colors } = useDesign ( ) ;
11- return < hr
12- ref = { ref }
13- style = { {
14- width : direction === 'horizontal' ? undefined : '1px' ,
15- height : direction === 'horizontal' ? '1px' : undefined ,
16- border : 'none' ,
17- backgroundColor : colors . neutralColor ,
18- margin : 0 ,
19- padding : 0 ,
20- } } /> ;
21- }
22- ) ;
23- Divider . displayName = 'Divider' ;
10+ const StyledDivider = styled ( SeparatorPrimitive . Root ) < {
11+ $orientation : string ,
12+ $color : string ,
13+ } > `
14+ flex-shrink: 0;
15+ background-color: ${ props => props . $color } ;
16+
17+ ${ ( props ) =>
18+ props . $orientation === 'horizontal'
19+ ? 'height: 1px; width: 100%;'
20+ : 'height: 100%; width: 1px;' }
21+ ` ;
2422
25- export default Divider ;
23+ const Divider = React . forwardRef <
24+ React . ElementRef < typeof SeparatorPrimitive . Root > ,
25+ React . ComponentPropsWithoutRef < typeof SeparatorPrimitive . Root >
26+ > ( ( { orientation = 'horizontal' , decorative = true , ...props } , ref ) => {
27+ const { colors } = useDesign ( ) ;
28+
29+ return < StyledDivider
30+ ref = { ref }
31+ decorative = { decorative }
32+ $orientation = { orientation }
33+ $color = { colors . neutralColor }
34+ { ...props }
35+ /> ;
36+ } ) ;
37+
38+ Divider . displayName = 'Separator' ;
39+
40+ export default Divider ;
0 commit comments