@@ -2,23 +2,13 @@ import {
2
2
FormErrorMessage ,
3
3
FormLabel ,
4
4
Box ,
5
- Touchable ,
6
- Text ,
7
5
TouchableRef ,
6
+ RadioButton ,
8
7
} from '@baca/design-system/components'
9
- import { forwardRef , useCallback , useMemo } from 'react'
8
+ import { forwardRef , useMemo } from 'react'
10
9
11
10
import { FieldRadioProps } from './types'
12
11
13
- const radioSizes = {
14
- sm : {
15
- boxSize : 4 ,
16
- } ,
17
- md : {
18
- boxSize : 5 ,
19
- } ,
20
- } as const
21
-
22
12
export const Radio = forwardRef < TouchableRef , FieldRadioProps > (
23
13
(
24
14
{
@@ -27,60 +17,32 @@ export const Radio = forwardRef<TouchableRef, FieldRadioProps>(
27
17
radioOptions,
28
18
errorMessage,
29
19
isError,
30
- size = 'sm ' ,
20
+ size = 'md ' ,
31
21
onChange,
32
22
label,
33
23
labelStyle,
34
24
isDisabled,
35
25
} ,
36
26
ref
37
27
) => {
38
- const checkboxSize = useMemo ( ( ) => radioSizes [ size ] , [ size ] )
39
-
40
- const getBorderColor = useCallback (
41
- ( isSelected : boolean ) : ColorNames | undefined => {
42
- if ( isDisabled ) {
43
- return 'border.disabled'
44
- }
45
- if ( isError ) {
46
- return 'border.error'
47
- }
48
-
49
- if ( isSelected ) {
50
- return 'bg.brand.solid'
51
- }
52
-
53
- return 'border.primary'
54
- } ,
55
- [ isDisabled , isError ]
56
- )
57
-
58
28
const renderRadioButtons = useMemo (
59
29
( ) =>
60
30
radioOptions ?. map ( ( item : string , index : number ) => {
61
31
return (
62
- < Touchable
32
+ < RadioButton
63
33
ref = { ref }
64
34
key = { index }
65
- onPress = { ( ) => onChange ( item ) }
66
- alignItems = "center"
67
- flexDirection = "row"
68
- height = { 8 }
69
- >
70
- < Box
71
- alignItems = "center"
72
- borderRadius = { 50 }
73
- height = { checkboxSize . boxSize }
74
- width = { checkboxSize . boxSize }
75
- justifyContent = "center"
76
- borderColor = { getBorderColor ( item === value ) }
77
- borderWidth = { item === value ? 5 : 1 }
78
- />
79
- < Text ml = { 4 } > { item } </ Text >
80
- </ Touchable >
35
+ isDisabled = { isDisabled }
36
+ isError = { isError }
37
+ isSelected = { item === value }
38
+ onChange = { ( ) => onChange ( item ) }
39
+ pb = { 2 }
40
+ label = { item }
41
+ size = { size }
42
+ />
81
43
)
82
44
} ) ,
83
- [ radioOptions , ref , checkboxSize . boxSize , getBorderColor , value , onChange ]
45
+ [ radioOptions , ref , isDisabled , isError , value , size , onChange ]
84
46
)
85
47
86
48
return (
0 commit comments