@@ -2,23 +2,13 @@ import {
22 FormErrorMessage ,
33 FormLabel ,
44 Box ,
5- Touchable ,
6- Text ,
75 TouchableRef ,
6+ RadioButton ,
87} from '@baca/design-system/components'
9- import { forwardRef , useCallback , useMemo } from 'react'
8+ import { forwardRef , useMemo } from 'react'
109
1110import { FieldRadioProps } from './types'
1211
13- const radioSizes = {
14- sm : {
15- boxSize : 4 ,
16- } ,
17- md : {
18- boxSize : 5 ,
19- } ,
20- } as const
21-
2212export const Radio = forwardRef < TouchableRef , FieldRadioProps > (
2313 (
2414 {
@@ -27,60 +17,32 @@ export const Radio = forwardRef<TouchableRef, FieldRadioProps>(
2717 radioOptions,
2818 errorMessage,
2919 isError,
30- size = 'sm ' ,
20+ size = 'md ' ,
3121 onChange,
3222 label,
3323 labelStyle,
3424 isDisabled,
3525 } ,
3626 ref
3727 ) => {
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-
5828 const renderRadioButtons = useMemo (
5929 ( ) =>
6030 radioOptions ?. map ( ( item : string , index : number ) => {
6131 return (
62- < Touchable
32+ < RadioButton
6333 ref = { ref }
6434 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+ />
8143 )
8244 } ) ,
83- [ radioOptions , ref , checkboxSize . boxSize , getBorderColor , value , onChange ]
45+ [ radioOptions , ref , isDisabled , isError , value , size , onChange ]
8446 )
8547
8648 return (
0 commit comments