fluent-styles 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +77 -0
  2. package/lib/commonjs/assets/img/doctor.png +0 -0
  3. package/lib/commonjs/index.js +248 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/package/badge/index.js +159 -0
  6. package/lib/commonjs/package/badge/index.js.map +1 -0
  7. package/lib/commonjs/package/button/index.js +96 -0
  8. package/lib/commonjs/package/button/index.js.map +1 -0
  9. package/lib/commonjs/package/card/index.js +32 -0
  10. package/lib/commonjs/package/card/index.js.map +1 -0
  11. package/lib/commonjs/package/checkBox/index.js +84 -0
  12. package/lib/commonjs/package/checkBox/index.js.map +1 -0
  13. package/lib/commonjs/package/cycle/index.js +28 -0
  14. package/lib/commonjs/package/cycle/index.js.map +1 -0
  15. package/lib/commonjs/package/dialog/index.js +192 -0
  16. package/lib/commonjs/package/dialog/index.js.map +1 -0
  17. package/lib/commonjs/package/dropdown/index.js +116 -0
  18. package/lib/commonjs/package/dropdown/index.js.map +1 -0
  19. package/lib/commonjs/package/form/index.js +184 -0
  20. package/lib/commonjs/package/form/index.js.map +1 -0
  21. package/lib/commonjs/package/header/index.js +89 -0
  22. package/lib/commonjs/package/header/index.js.map +1 -0
  23. package/lib/commonjs/package/image/index.js +123 -0
  24. package/lib/commonjs/package/image/index.js.map +1 -0
  25. package/lib/commonjs/package/radioButton/index.js +84 -0
  26. package/lib/commonjs/package/radioButton/index.js.map +1 -0
  27. package/lib/commonjs/package/safeAreaView/index.js +16 -0
  28. package/lib/commonjs/package/safeAreaView/index.js.map +1 -0
  29. package/lib/commonjs/package/scrollView/index.js +16 -0
  30. package/lib/commonjs/package/scrollView/index.js.map +1 -0
  31. package/lib/commonjs/package/separator/index.js +33 -0
  32. package/lib/commonjs/package/separator/index.js.map +1 -0
  33. package/lib/commonjs/package/spacer/index.js +18 -0
  34. package/lib/commonjs/package/spacer/index.js.map +1 -0
  35. package/lib/commonjs/package/spinner/index.js +43 -0
  36. package/lib/commonjs/package/spinner/index.js.map +1 -0
  37. package/lib/commonjs/package/stack/__test__/index.test.js +91 -0
  38. package/lib/commonjs/package/stack/__test__/index.test.js.map +1 -0
  39. package/lib/commonjs/package/stack/index.js +41 -0
  40. package/lib/commonjs/package/stack/index.js.map +1 -0
  41. package/lib/commonjs/package/styled/__test__/index.test.js +161 -0
  42. package/lib/commonjs/package/styled/__test__/index.test.js.map +1 -0
  43. package/lib/commonjs/package/styled/index.js +42 -0
  44. package/lib/commonjs/package/styled/index.js.map +1 -0
  45. package/lib/commonjs/package/switch/index.js +43 -0
  46. package/lib/commonjs/package/switch/index.js.map +1 -0
  47. package/lib/commonjs/package/text/index.js +73 -0
  48. package/lib/commonjs/package/text/index.js.map +1 -0
  49. package/lib/commonjs/package/theme.js +384 -0
  50. package/lib/commonjs/package/theme.js.map +1 -0
  51. package/lib/commonjs/package/utils/index.js +130 -0
  52. package/lib/commonjs/package/utils/index.js.map +1 -0
  53. package/lib/commonjs/styled.code-workspace +9 -0
  54. package/lib/module/assets/img/doctor.png +0 -0
  55. package/lib/module/index.js +23 -0
  56. package/lib/module/index.js.map +1 -0
  57. package/lib/module/package/badge/index.js +151 -0
  58. package/lib/module/package/badge/index.js.map +1 -0
  59. package/lib/module/package/button/index.js +89 -0
  60. package/lib/module/package/button/index.js.map +1 -0
  61. package/lib/module/package/card/index.js +25 -0
  62. package/lib/module/package/card/index.js.map +1 -0
  63. package/lib/module/package/checkBox/index.js +75 -0
  64. package/lib/module/package/checkBox/index.js.map +1 -0
  65. package/lib/module/package/cycle/index.js +21 -0
  66. package/lib/module/package/cycle/index.js.map +1 -0
  67. package/lib/module/package/dialog/index.js +182 -0
  68. package/lib/module/package/dialog/index.js.map +1 -0
  69. package/lib/module/package/dropdown/index.js +106 -0
  70. package/lib/module/package/dropdown/index.js.map +1 -0
  71. package/lib/module/package/form/index.js +176 -0
  72. package/lib/module/package/form/index.js.map +1 -0
  73. package/lib/module/package/header/index.js +83 -0
  74. package/lib/module/package/header/index.js.map +1 -0
  75. package/lib/module/package/image/index.js +115 -0
  76. package/lib/module/package/image/index.js.map +1 -0
  77. package/lib/module/package/radioButton/index.js +75 -0
  78. package/lib/module/package/radioButton/index.js.map +1 -0
  79. package/lib/module/package/safeAreaView/index.js +11 -0
  80. package/lib/module/package/safeAreaView/index.js.map +1 -0
  81. package/lib/module/package/scrollView/index.js +11 -0
  82. package/lib/module/package/scrollView/index.js.map +1 -0
  83. package/lib/module/package/separator/index.js +26 -0
  84. package/lib/module/package/separator/index.js.map +1 -0
  85. package/lib/module/package/spacer/index.js +11 -0
  86. package/lib/module/package/spacer/index.js.map +1 -0
  87. package/lib/module/package/spinner/index.js +36 -0
  88. package/lib/module/package/spinner/index.js.map +1 -0
  89. package/lib/module/package/stack/__test__/index.test.js +89 -0
  90. package/lib/module/package/stack/__test__/index.test.js.map +1 -0
  91. package/lib/module/package/stack/index.js +36 -0
  92. package/lib/module/package/stack/index.js.map +1 -0
  93. package/lib/module/package/styled/__test__/index.test.js +158 -0
  94. package/lib/module/package/styled/__test__/index.test.js.map +1 -0
  95. package/lib/module/package/styled/index.js +35 -0
  96. package/lib/module/package/styled/index.js.map +1 -0
  97. package/lib/module/package/switch/index.js +36 -0
  98. package/lib/module/package/switch/index.js.map +1 -0
  99. package/lib/module/package/text/index.js +68 -0
  100. package/lib/module/package/text/index.js.map +1 -0
  101. package/lib/module/package/theme.js +379 -0
  102. package/lib/module/package/theme.js.map +1 -0
  103. package/lib/module/package/utils/index.js +120 -0
  104. package/lib/module/package/utils/index.js.map +1 -0
  105. package/lib/module/styled.code-workspace +9 -0
  106. package/package.json +85 -0
  107. package/src/assets/img/doctor.png +0 -0
  108. package/src/index.js +23 -0
  109. package/src/package/badge/index.jsx +133 -0
  110. package/src/package/button/index.jsx +80 -0
  111. package/src/package/card/index.jsx +38 -0
  112. package/src/package/checkBox/index.jsx +80 -0
  113. package/src/package/cycle/index.jsx +23 -0
  114. package/src/package/dialog/index.jsx +214 -0
  115. package/src/package/dropdown/index.jsx +102 -0
  116. package/src/package/form/index.jsx +145 -0
  117. package/src/package/header/index.jsx +92 -0
  118. package/src/package/image/index.jsx +93 -0
  119. package/src/package/radioButton/index.jsx +81 -0
  120. package/src/package/safeAreaView/index.jsx +12 -0
  121. package/src/package/scrollView/index.jsx +12 -0
  122. package/src/package/separator/index.jsx +26 -0
  123. package/src/package/spacer/index.jsx +13 -0
  124. package/src/package/spinner/index.jsx +33 -0
  125. package/src/package/stack/__test__/index.test.js +68 -0
  126. package/src/package/stack/index.jsx +37 -0
  127. package/src/package/styled/__test__/index.test.js +132 -0
  128. package/src/package/styled/index.js +32 -0
  129. package/src/package/switch/index.jsx +33 -0
  130. package/src/package/text/index.jsx +61 -0
  131. package/src/package/theme.js +376 -0
  132. package/src/package/utils/index.js +108 -0
  133. package/src/styled.code-workspace +9 -0
@@ -0,0 +1,133 @@
1
+ // @ts-nocheck
2
+ import React from "react";
3
+ import { Text } from 'react-native';
4
+ import { XStack, YStack } from "../stack";
5
+ import { StyledSpacer } from "../spacer";
6
+ import { styled } from "../styled";
7
+ import { theme } from "../theme";
8
+ import { isValidColor, isValidNumber, isValidString } from '../utils';
9
+
10
+ const Badge = styled(Text, {
11
+ base: {
12
+ borderColor: theme.colors.gray[300],
13
+ borderRadius: 32,
14
+ backgroundColor: theme.colors.gray[1],
15
+ fontSize: theme.fontSize.normal,
16
+ color: theme.colors.gray[900],
17
+ fontWeight: theme.fontWeight.bold,
18
+ position: 'relative',
19
+ textAlign: 'center'
20
+ },
21
+ variants: {
22
+ fontWeight: (size = theme.fontWeight.normal) => {
23
+ if (!isValidString(size)) {
24
+ throw new Error('Invalid fontWeight value')
25
+ }
26
+ return { fontWeight: size }
27
+ },
28
+ color: (color = theme.colors.gray[800]) => {
29
+ if (!isValidColor(color)) {
30
+ throw new Error('Invalid color value')
31
+ }
32
+ return { color: color }
33
+ },
34
+ fontSize: (size = theme.fontSize.normal) => {
35
+ if (!isValidNumber(size)) {
36
+ throw new Error('Invalid fontSize value')
37
+ }
38
+ return { fontSize: size }
39
+ },
40
+ flexWrap: 'wrap',
41
+ absolute: {
42
+ true: {
43
+ position: 'absolute'
44
+ }
45
+ },
46
+ fontFamily: (font) => {
47
+ if (!font) return
48
+ return {
49
+ fontFamily: font
50
+ }
51
+ },
52
+ textAlign: (align = 'left') => {
53
+ const validAlignments = ['auto', 'left', 'right', 'center', 'justify']
54
+ if (!validAlignments.includes(align)) {
55
+ throw new Error('Invalid textAlign value')
56
+ }
57
+ return { textAlign: align }
58
+ },
59
+ borderColor: color => {
60
+ if (!isValidColor(color)) {
61
+ throw new Error('Invalid color value')
62
+ }
63
+ return { borderColor: color }
64
+ },
65
+ borderRadius: (size = 32) => {
66
+ if (!isValidNumber(size)) {
67
+ throw new Error('Invalid borderRadius value')
68
+ }
69
+ return { borderRadius: size }
70
+ },
71
+ backgroundColor: color => {
72
+ if (!isValidColor(color)) {
73
+ throw new Error('Invalid color value')
74
+ }
75
+ return { backgroundColor: color }
76
+ },
77
+ right: (size = 0) => {
78
+ if (!isValidNumber(size)) {
79
+ throw new Error('Invalid right value')
80
+ }
81
+ return { right: size }
82
+ },
83
+ top: (size = 0) => {
84
+ if (!isValidNumber(size)) {
85
+ throw new Error('Invalid top value')
86
+ }
87
+ return { top: size }
88
+ },
89
+ }
90
+ })
91
+
92
+ const StyledBadge = ({ children, ...rest }) => {
93
+ return (
94
+ <Badge {...rest}>
95
+ {children}
96
+ </Badge>
97
+ )
98
+ }
99
+
100
+ const StyledBadgeWithIcon = ({ iconLeft, iconRight, textProps, title, ...rest }) => {
101
+ return (
102
+ <XStack justifyContent='flex-start' alignItems='center' {...rest}>
103
+ {
104
+ iconLeft && (<>
105
+ {iconLeft}
106
+ <StyledSpacer marginHorizontal={2} />
107
+ </>)
108
+ }
109
+ <Badge backgroundColor={theme.colors.transparent} {...textProps}>
110
+ {title}
111
+ </Badge>
112
+ {
113
+ iconRight && (<>
114
+ {iconRight}
115
+ <StyledSpacer marginHorizontal={2} />
116
+ </>)
117
+ }
118
+ </XStack>
119
+ )
120
+ }
121
+
122
+ const StyledBadgeIcon = ({ top = -1, right = 5, icon, charProps, char, ...rest }) => {
123
+ return (
124
+ <YStack justifyContent='center' alignItems='center' {...rest}>
125
+ {icon}
126
+ <Badge absolute top={top} right={right} {...charProps}>
127
+ {char}
128
+ </Badge>
129
+ </YStack>
130
+ )
131
+ }
132
+
133
+ export { StyledBadge, StyledBadgeWithIcon, StyledBadgeIcon }
@@ -0,0 +1,80 @@
1
+ import React from 'react'
2
+ import { TouchableOpacity } from 'react-native'
3
+ import { styled } from '../styled'
4
+ import { theme } from '../theme'
5
+ import { isValidColor, isValidNumber } from '../utils'
6
+
7
+ const Button = styled(TouchableOpacity, {
8
+ base: {
9
+ borderColor: theme.colors.gray[100],
10
+ borderWidth: 1,
11
+ borderRadius: 30,
12
+ backgroundColor: theme.colors.gray[300],
13
+ flexDirection: 'row',
14
+ justifyContent: 'center',
15
+ alignItems: 'center'
16
+ },
17
+ variants: {
18
+ borderColor: color => {
19
+ if (!isValidColor(color)) {
20
+ throw new Error('Invalid color value')
21
+ }
22
+ return { borderColor: color }
23
+ },
24
+ borderRadius: (size = 32) => {
25
+ if (!isValidNumber(size)) {
26
+ throw new Error('Invalid borderRadius value')
27
+ }
28
+ return { borderRadius: size }
29
+ },
30
+ flex: size => {
31
+ if (!isValidNumber(size)) {
32
+ throw new Error('Invalid flex value')
33
+ }
34
+ return { flex: size }
35
+ },
36
+ width: size => {
37
+ if (!size) return
38
+ return { width: size }
39
+ },
40
+ height: size => {
41
+ if (!size) return
42
+ return { height: size }
43
+ },
44
+ backgroundColor: color => {
45
+ if (!isValidColor(color)) {
46
+ throw new Error('Invalid backgroundColor value')
47
+ }
48
+ return { backgroundColor: color }
49
+ },
50
+ link: {
51
+ true: {
52
+ borderColor: theme.colors.transparent,
53
+ borderWidth: 0,
54
+ borderRadius: 0,
55
+ backgroundColor: theme.colors.transparent
56
+ }
57
+ },
58
+ selected: {
59
+ true: {
60
+ borderColor: theme.colors.cyan[500],
61
+ backgroundColor: theme.colors.cyan[500],
62
+ borderWidth: 0
63
+ },
64
+ false: {
65
+ borderColor: theme.colors.gray[300],
66
+ borderWidth: 0
67
+ }
68
+ }
69
+ }
70
+ })
71
+
72
+ const StyledButton = ({ children, ...rest }) => {
73
+ return (
74
+ <Button {...rest}>
75
+ {children}
76
+ </Button>
77
+ )
78
+ }
79
+
80
+ export { StyledButton, Button }
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ import { View, Pressable } from 'react-native'
3
+ import { styled } from '../styled'
4
+ import { shadow } from '../utils'
5
+
6
+ const Card = styled(View, {
7
+ base: {
8
+ flexDirection: 'column'
9
+ },
10
+ variants: {
11
+ shadow: shadow
12
+ }
13
+ })
14
+
15
+ const StyledCard = ({
16
+ pressable = false,
17
+ pressableProps,
18
+ children,
19
+ ...rest
20
+ }) => {
21
+ if (pressable) {
22
+ return (
23
+ <Pressable {...pressableProps}>
24
+ <Card {...rest}>
25
+ {children}
26
+ </Card>
27
+ </Pressable>
28
+ )
29
+ }
30
+
31
+ return (
32
+ <Card {...rest}>
33
+ {children}
34
+ </Card>
35
+ )
36
+ }
37
+
38
+ export { StyledCard }
@@ -0,0 +1,80 @@
1
+ import React, { useState } from 'react'
2
+ import { styled } from '../styled'
3
+ import { TouchableOpacity } from 'react-native'
4
+ import Icon from 'react-native-vector-icons/MaterialIcons'
5
+ import { theme } from '../theme'
6
+
7
+ const CheckBox = styled(TouchableOpacity, {
8
+ base: {
9
+ width: 24,
10
+ height: 24,
11
+ borderWidth: 2,
12
+ borderRadius: 1,
13
+ borderColor: theme.colors.gray[700],
14
+ justifyContent: 'center',
15
+ alignItems: 'center',
16
+ flexDirection: 'column'
17
+ },
18
+ variants: {
19
+ width: size => {
20
+ if (!size) return
21
+ return { width: size }
22
+ },
23
+ height: size => {
24
+ if (!size) return
25
+ return { height: size }
26
+ },
27
+ disabled: {
28
+ true: {
29
+ backgroundColor: theme.colors.gray[500]
30
+ }
31
+ },
32
+ checked: {
33
+ true: {
34
+ backgroundColor: theme.colors.gray[800]
35
+ }
36
+ },
37
+ checkedColor: color => {
38
+ if (!color) return
39
+ return {
40
+ backgroundColor: color,
41
+ borderColor: color
42
+ }
43
+ }
44
+ }
45
+ })
46
+
47
+ const StyledCheckBox = ({
48
+ onPress,
49
+ disabled = false,
50
+ checkedColor,
51
+ iconProps,
52
+ ...rest
53
+ }) => {
54
+ const [checked, setChecked] = useState(false)
55
+
56
+ const toggleCheckbox = () => {
57
+ setChecked(!checked)
58
+ onPress && onPress(!checked)
59
+ }
60
+
61
+ return (
62
+ <CheckBox
63
+ disabled={disabled}
64
+ checked={checked}
65
+ checkedColor={checked && checkedColor && checkedColor}
66
+ onPress={() => toggleCheckbox()}
67
+ {...rest}
68
+ >
69
+ {checked &&
70
+ <Icon
71
+ name='check'
72
+ {...iconProps}
73
+ color={theme.colors.gray[1]}
74
+ size={20}
75
+ />}
76
+ </CheckBox>
77
+ )
78
+ }
79
+
80
+ export { StyledCheckBox }
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import { YStack } from '../stack'
3
+ import { theme } from '../theme'
4
+
5
+ const StyledCycle = ({ children, ...rest }) => {
6
+ return (
7
+ <YStack
8
+ height={48}
9
+ width={48}
10
+ borderRadius={50}
11
+ borderWidth={1}
12
+ borderColor={theme.colors.gray[1]}
13
+ backgroundColor={theme.colors.gray[1]}
14
+ justifyContent='center'
15
+ alignItems='center'
16
+ {...rest}
17
+ >
18
+ {children}
19
+ </YStack>
20
+ )
21
+ }
22
+
23
+ export { StyledCycle }
@@ -0,0 +1,214 @@
1
+ import React, { useState } from 'react'
2
+ import { Modal } from 'react-native'
3
+ import { XStack, YStack } from '../stack'
4
+ import { StyledText } from '../text'
5
+ import { StyledButton } from '../button'
6
+ import { StyledSpacer } from '../spacer'
7
+ import { styled } from '../styled'
8
+ import { theme } from '../theme'
9
+
10
+ const Dialog = styled(Modal, {
11
+ base: {
12
+ backgroundColor: theme.colors.gray[100],
13
+ padding: 20,
14
+ borderRadius: 10
15
+ }
16
+ })
17
+
18
+ const StyledDialog = ({
19
+ children,
20
+ animationType = 'fade',
21
+ transparent = true,
22
+ visible = false,
23
+ ...rest
24
+ }) => {
25
+ return (
26
+ <Dialog
27
+ visible={visible}
28
+ transparent={transparent}
29
+ animationType={animationType}
30
+ {...rest}
31
+ >
32
+ {children}
33
+ </Dialog>
34
+ )
35
+ }
36
+
37
+ const StyledConfirmDialog = ({
38
+ visible = false,
39
+ row,
40
+ animationType = 'fade',
41
+ onCancel,
42
+ onConfirm,
43
+ transparent = true,
44
+ ...rest
45
+ }) => {
46
+ const [show, setShow] = useState(visible)
47
+ const { title, description, cancel = 'Cancel', confirm = 'Confirm' } = rest
48
+
49
+ const handleConfirm = () => {
50
+ setShow(false)
51
+ if (typeof onConfirm === 'function') {
52
+ if (typeof row === 'object' && row !== null) {
53
+ onConfirm(row)
54
+ } else {
55
+ onConfirm()
56
+ }
57
+ }
58
+ }
59
+ const handleCancel = () => {
60
+ setShow(false)
61
+ if (typeof onCancel === 'function') {
62
+ onCancel()
63
+ }
64
+ }
65
+
66
+ return (
67
+ <Dialog
68
+ visible={show}
69
+ transparent={transparent}
70
+ animationType={animationType}
71
+ {...rest}
72
+ >
73
+ <YStack transparent flex={1} justifyContent='center' alignItems='center'>
74
+ <YStack
75
+ width={'90%'}
76
+ borderRadius={8}
77
+ paddingVertical={16}
78
+ paddingHorizontal={16}
79
+ backgroundColor={theme.colors.gray[1]}
80
+ >
81
+ <StyledText
82
+ color={theme.colors.gray[800]}
83
+ fontSize={theme.fontSize.normal}
84
+ fontWeight={theme.fontWeight.bold}
85
+ >
86
+ {title}
87
+ </StyledText>
88
+ <StyledSpacer marginVertical={1} />
89
+ <StyledText
90
+ color={theme.colors.gray[800]}
91
+ fontSize={theme.fontSize.large}
92
+ fontWeight={theme.fontWeight.normal}
93
+ >
94
+ {description}
95
+ </StyledText>
96
+ <StyledSpacer marginVertical={4} />
97
+ <XStack justifyContent='flex-end' alignItems='center'>
98
+ <StyledButton
99
+ backgroundColor={theme.colors.red[400]}
100
+ borderColor={theme.colors.red[400]}
101
+ borderRadius={30}
102
+ onPress={() => handleCancel()}
103
+ >
104
+ <StyledText
105
+ paddingHorizontal={20}
106
+ paddingVertical={4}
107
+ color={theme.colors.gray[1]}
108
+ fontSize={theme.fontSize.large}
109
+ fontWeight={theme.fontWeight.normal}
110
+ >
111
+ {cancel}
112
+ </StyledText>
113
+ </StyledButton>
114
+ <StyledSpacer marginHorizontal={2} />
115
+ <StyledButton
116
+ backgroundColor={theme.colors.green[500]}
117
+ borderColor={theme.colors.green[500]}
118
+ onPress={() => handleConfirm()}
119
+ borderRadius={30}
120
+ >
121
+ <StyledText
122
+ paddingHorizontal={20}
123
+ paddingVertical={4}
124
+ color={theme.colors.gray[1]}
125
+ fontSize={theme.fontSize.large}
126
+ fontWeight={theme.fontWeight.normal}
127
+ >
128
+ {confirm}
129
+ </StyledText>
130
+ </StyledButton>
131
+ </XStack>
132
+ </YStack>
133
+ </YStack>
134
+ </Dialog>
135
+ )
136
+ }
137
+
138
+ const StyledOkDialog = ({
139
+ visible = false,
140
+ animationType = 'fade',
141
+ transparent = true,
142
+ ...rest
143
+ }) => {
144
+ const [show, setShow] = useState(visible)
145
+ const {
146
+ title = "We're sorry, something went wrong.",
147
+ description = 'Please try again later',
148
+ ok = 'Ok',
149
+ onOk
150
+ } = rest
151
+
152
+ const handleOk = () => {
153
+ setShow(false)
154
+ if (typeof onOk === 'function') {
155
+ onOk()
156
+ }
157
+ }
158
+ return (
159
+ <Dialog
160
+ visible={show}
161
+ transparent={transparent}
162
+ animationType={animationType}
163
+ {...rest}
164
+ >
165
+ <YStack transparent flex={1} justifyContent='center' alignItems='center'>
166
+ <YStack
167
+ width={'90%'}
168
+ borderRadius={8}
169
+ paddingVertical={16}
170
+ paddingHorizontal={16}
171
+ backgroundColor={theme.colors.gray[1]}
172
+ >
173
+ <StyledText
174
+ color={theme.colors.gray[800]}
175
+ fontSize={theme.fontSize.normal}
176
+ fontWeight={theme.fontWeight.bold}
177
+ >
178
+ {title}
179
+ </StyledText>
180
+ <StyledSpacer marginVertical={2} />
181
+ <StyledText
182
+ color={theme.colors.gray[800]}
183
+ fontSize={theme.fontSize.normal}
184
+ fontWeight={theme.fontWeight.normal}
185
+ >
186
+ {description}
187
+ </StyledText>
188
+ <StyledSpacer marginVertical={8} />
189
+ <XStack justifyContent='flex-end' alignItems='center'>
190
+ <StyledButton
191
+ flex={1}
192
+ backgroundColor={theme.colors.cyan[500]}
193
+ borderColor={theme.colors.cyan[500]}
194
+ onPress={handleOk}
195
+ borderRadius={30}
196
+ >
197
+ <StyledText
198
+ paddingHorizontal={20}
199
+ paddingVertical={8}
200
+ color={theme.colors.gray[1]}
201
+ fontSize={theme.fontSize.large}
202
+ fontWeight={theme.fontWeight.bold}
203
+ >
204
+ {ok}
205
+ </StyledText>
206
+ </StyledButton>
207
+ </XStack>
208
+ </YStack>
209
+ </YStack>
210
+ </Dialog>
211
+ )
212
+ }
213
+
214
+ export { StyledDialog, StyledConfirmDialog, StyledOkDialog }
@@ -0,0 +1,102 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import { YStack } from '../stack';
3
+ import { StyledText } from '../text';
4
+ import { StyledSpacer } from '../spacer';
5
+ import DropDownPicker from "react-native-dropdown-picker";
6
+ import { theme } from "../theme";
7
+ import { styled } from "../styled";
8
+
9
+ const Dropdown = styled(DropDownPicker, {
10
+ base: {
11
+ borderColor: theme.colors.gray[800],
12
+ borderWidth: 1,
13
+ borderRadius: 30,
14
+ backgroundColor: theme.colors.gray[1],
15
+ width: '100%',
16
+ color: theme.colors.gray[800],
17
+ paddingHorizontal: 16,
18
+ },
19
+ variants: {
20
+ error: {
21
+ true: {
22
+ borderColor: theme.colors.pink[500],
23
+ borderWidth: 1,
24
+ },
25
+ false: {
26
+ borderColor: theme.colors.gray[800],
27
+ }
28
+ },
29
+ }
30
+ })
31
+
32
+ const StyledDropdown = ({ items, label, errorMessage, labelStyles, ...rest }) => {
33
+ const [open, setOpen] = useState(false)
34
+ return (
35
+ <YStack justifyContent='flex-start' alignItems='flex-start'>
36
+ {
37
+ label && (
38
+ <>
39
+ <StyledSpacer marginVertical={4} />
40
+ <StyledText paddingHorizontal={8} color={theme.colors.gray[600]} fontSize={theme.fontSize.normal} fontWeight={theme.fontWeight.normal} {...labelStyles}>
41
+ {label}
42
+ </StyledText>
43
+ <StyledSpacer marginVertical={4} />
44
+ </>
45
+
46
+ )
47
+ }
48
+ <Dropdown open={open} setOpen={setOpen} items={items} {...rest} />
49
+ {
50
+ errorMessage && (
51
+ <>
52
+ <StyledSpacer marginVertical={1} />
53
+ <StyledText marginHorizontal={16} fontWeight={theme.fontWeight.bold} fontSize={theme.fontSize.small} color={theme.colors.pink[500]}>
54
+ {errorMessage}
55
+ </StyledText>
56
+ </>
57
+ )
58
+ }
59
+
60
+ </YStack>
61
+ )
62
+ }
63
+
64
+ const StyledMultiDropdown = ({ items, label, errorMessage, labelStyles, onSelected, ...rest }) => {
65
+ const [selected, setSelected] = useState([])
66
+ const [open, setOpen] = useState(false)
67
+
68
+ useEffect(() => {
69
+ onSelected && onSelected(selected)
70
+ }, [selected])
71
+
72
+ return (
73
+ <YStack justifyContent='flex-start' alignItems='flex-start'>
74
+ {
75
+ label && (
76
+ <>
77
+ <StyledSpacer marginVertical={4} />
78
+ <StyledText paddingHorizontal={8} color={theme.colors.gray[600]} fontSize={theme.fontSize.normal} fontWeight={theme.fontWeight.normal} {...labelStyles}>
79
+ {label}
80
+ </StyledText>
81
+ <StyledSpacer marginVertical={4} />
82
+ </>
83
+
84
+ )
85
+ }
86
+ <Dropdown open={open} setOpen={setOpen} items={items} setValue={setSelected} value={selected} multiple {...rest} />
87
+ {
88
+ errorMessage && (
89
+ <>
90
+ <StyledSpacer marginVertical={1} />
91
+ <StyledText marginHorizontal={16} fontWeight={theme.fontWeight.bold} fontSize={theme.fontSize.small} color={theme.colors.pink[500]}>
92
+ {errorMessage}
93
+ </StyledText>
94
+ </>
95
+ )
96
+ }
97
+
98
+ </YStack>
99
+ )
100
+ }
101
+
102
+ export { StyledDropdown, StyledMultiDropdown }