1
1
import { useMemo } from 'react' ;
2
2
3
3
import { useColorMode } from '../../hooks' ;
4
- import { type NativeFicusProps , ficus , forwardRef } from '../system' ;
4
+ import { ThemingProps , omitThemingProps } from '../../style-system' ;
5
+ import {
6
+ type NativeFicusProps ,
7
+ ficus ,
8
+ forwardRef ,
9
+ useMultiStyleConfig ,
10
+ } from '../system' ;
5
11
6
12
interface DividerOptions {
7
13
color ?: string ;
@@ -10,49 +16,47 @@ interface DividerOptions {
10
16
11
17
export interface DividerProps
12
18
extends NativeFicusProps < 'View' > ,
13
- DividerOptions { }
19
+ DividerOptions ,
20
+ ThemingProps < 'Divider' > { }
14
21
15
22
/**
16
23
* Layout component used to visually separate content in a list or group.
17
24
* It displays a thin horizontal or vertical line
18
25
*/
19
- export const Divider = forwardRef < DividerProps , 'View' > (
20
- function Divider ( props , ref ) {
21
- const { colorMode } = useColorMode ( ) ;
22
-
23
- const {
24
- orientation = 'horizontal' ,
25
- color = colorMode === 'dark' ? 'white' : 'black' ,
26
- __styles,
27
- ...rest
28
- } = props ;
29
-
30
- const dividerStyles = useMemo ( ( ) => {
31
- const bg = color ;
32
-
33
- return {
34
- vertical : {
35
- w : 1 ,
36
- h : '100%' ,
37
- bg,
38
- } ,
39
- horizontal : {
40
- h : 1 ,
41
- w : '100%' ,
42
- bg,
43
- } ,
44
- } ;
45
- } , [ color ] ) ;
46
-
47
- return (
48
- < ficus . View
49
- ref = { ref }
50
- { ...rest }
51
- __styles = { {
52
- ...dividerStyles [ orientation ] ,
53
- ...__styles ,
54
- } }
55
- />
56
- ) ;
57
- }
58
- ) ;
26
+ export const Divider = forwardRef < DividerProps , 'View' > ( ( props , ref ) => {
27
+ const { colorMode } = useColorMode ( ) ;
28
+ const themingProps = omitThemingProps ( props ) ;
29
+
30
+ const {
31
+ orientation = 'horizontal' ,
32
+ __styles,
33
+ color : colorProp ,
34
+ ...rest
35
+ } = themingProps ;
36
+
37
+ const styles = useMultiStyleConfig ( 'Divider' , props ) ;
38
+
39
+ const color =
40
+ colorProp ??
41
+ ( styles . color as string ) ??
42
+ ( colorMode === 'dark' ? 'white' : 'black' ) ;
43
+
44
+ const dividerStyles = useMemo ( ( ) => {
45
+ const base = { ...styles , bg : color } ;
46
+ return {
47
+ vertical : { w : 1 , h : '100%' , ...base } ,
48
+ horizontal : { h : 1 , w : '100%' , ...base } ,
49
+ } ;
50
+ } , [ color , styles ] ) ;
51
+
52
+ return (
53
+ < ficus . View
54
+ ref = { ref }
55
+ { ...rest }
56
+ __styles = { {
57
+ ...dividerStyles [ orientation ] ,
58
+ ...__styles ,
59
+ } }
60
+ />
61
+ ) ;
62
+ } ) ;
0 commit comments