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,145 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { TextInput } from 'react-native';
3
+ import { YStack } from '../stack';
4
+ import { StyledText } from '../text';
5
+ import { StyledSpacer } from '../spacer';
6
+ import { theme } from '../theme';
7
+ import { styled } from '../styled';
8
+ import { isValidColor, isValidNumber, isValidString } from '../utils';
9
+
10
+ const StyledInputText = styled(TextInput, {
11
+ base: {
12
+ borderColor: theme.colors.gray[800],
13
+ borderWidth: 1,
14
+ borderRadius: 30,
15
+ backgroundColor: theme.fontWeight.normal[1],
16
+ width: '100%',
17
+ color: theme.colors.gray[800],
18
+ paddingHorizontal: 16,
19
+ paddingVertical: 8,
20
+ fontSize: theme.fontSize.normal,
21
+ placeholderTextColor: theme.colors.gray[1],
22
+ },
23
+ variants : {
24
+ fontWeight: (size = theme.fontWeight.normal) => {
25
+ if (!isValidString(size)) {
26
+ throw new Error('Invalid fontWeight value');
27
+ }
28
+ return { fontWeight: size };
29
+ },
30
+ color: (color = theme.colors.gray[800]) => {
31
+ if (!isValidColor(color)) {
32
+ throw new Error('Invalid color value');
33
+ }
34
+ return { color: color };
35
+ },
36
+ fontSize: (size = theme.fontSize.normal) => {
37
+ if (!isValidNumber(size)) {
38
+ throw new Error('Invalid fontSize value');
39
+ }
40
+ return { fontSize: size };
41
+ },
42
+ fontFamily: font => {
43
+ if (!font) return
44
+ return {
45
+ fontFamily: font
46
+ }
47
+ },
48
+ textAlign: (align = 'left') => {
49
+ const validAlignments = ['auto', 'left', 'right', 'center', 'justify'];
50
+ if (!validAlignments.includes(align)) {
51
+ throw new Error('Invalid textAlign value');
52
+ }
53
+ return { textAlign: align };
54
+ },
55
+ borderRadius: (value = 16) => {
56
+ if (!isValidNumber(value)) {
57
+ throw new Error('Invalid borderRadius value');
58
+ }
59
+ return { borderRadius: value };
60
+ },
61
+ borderColor: (value = theme.colors.gray[100]) => {
62
+ if (!isValidColor(value)) {
63
+ throw new Error('Invalid borderColor value');
64
+ }
65
+ return { borderColor: value };
66
+ },
67
+ backgroundColor: (value = theme.colors.gray[1]) => {
68
+ if (!isValidColor(value)) {
69
+ throw new Error('Invalid backgroundColor value');
70
+ }
71
+ return { backgroundColor: value };
72
+ },
73
+ noBorder: {
74
+ true: { borderWidth: 0 }
75
+ },
76
+ placeholderTextColor: (value = theme.colors.gray[800]) => {
77
+ if (!isValidColor(value)) {
78
+ throw new Error('Invalid placeholderTextColor value');
79
+ }
80
+ return { placeholderTextColor: value };
81
+ },
82
+ }
83
+ });
84
+
85
+ const StyledInput = forwardRef(({ label, flex = 0, borderColor, errorMessage, error, errorProps, labelProps, ...rest }, ref) => {
86
+ return (
87
+ <YStack width={'100%'}>
88
+ {
89
+ label && (
90
+ <>
91
+ <StyledText paddingHorizontal={8} color={theme.colors.gray[800]} fontSize={theme.fontSize.normal} fontWeight={theme.fontWeight.normal} {...labelProps}>
92
+ {label}
93
+ </StyledText>
94
+ <StyledSpacer marginVertical={4} />
95
+ </>
96
+ )
97
+ }
98
+ <StyledInputText placeholderTextColor={theme.colors.gray[400]} ref={ref} {...rest} borderColor={error ? theme.colors.pink[500] : borderColor} />
99
+ {
100
+ errorMessage && (
101
+ <>
102
+ <StyledSpacer marginVertical={1} />
103
+ <StyledText marginHorizontal={8} fontWeight={theme.fontWeight.bold} fontSize={theme.fontSize.small} color={theme.colors.pink[500]} {...errorProps}>
104
+ {errorMessage}
105
+ </StyledText>
106
+ </>
107
+ )
108
+ }
109
+ </YStack>
110
+ )
111
+ })
112
+
113
+ const StyledMultiInput = ({ label, errorMessage, borderColor, error, errorProps, labelProps, ...rest }) => {
114
+ return (
115
+ <YStack width={'100%'} justifyContent='flex-start' alignItems='flex-start'>
116
+ {
117
+ label && (
118
+ <>
119
+ <StyledSpacer marginVertical={4} />
120
+ <StyledText paddingHorizontal={8} color={theme.colors.gray[800]} fontSize={theme.fontSize.normal} fontWeight={theme.fontWeight.normal} {...labelProps}>
121
+ {label}
122
+ </StyledText>
123
+ <StyledSpacer marginVertical={4} />
124
+ </>
125
+
126
+ )
127
+ }
128
+ <StyledInputText borderRadius={16} textAlignVertical='top' multiline numberOfLines={5} inputMode='text' {...rest} borderColor={error ? theme.colors.pink[500] : borderColor} />
129
+ {
130
+ errorMessage && (
131
+ <>
132
+ <StyledSpacer marginVertical={1} />
133
+ <StyledText marginHorizontal={8} fontWeight={theme.fontWeight.bold} fontSize={theme.fontSize.small} color={theme.colors.pink[500]} {...errorProps}>
134
+ {errorMessage}
135
+ </StyledText>
136
+ </>
137
+ )
138
+ }
139
+
140
+ </YStack>
141
+ )
142
+ }
143
+
144
+ export { StyledInput, StyledMultiInput }
145
+ export default StyledInputText
@@ -0,0 +1,92 @@
1
+ import React from 'react'
2
+ import { View } from 'react-native'
3
+ import { StatusBar } from 'react-native'
4
+ import Icon from 'react-native-vector-icons/MaterialIcons'
5
+ import { theme } from '../theme'
6
+ import { YStack, XStack } from '../stack'
7
+ import { styled } from '../styled'
8
+ import { StyledCycle } from '../cycle'
9
+ import { StyledText } from '../text'
10
+ import { StyledSpacer } from '../spacer'
11
+ import { isValidNumber } from '../utils'
12
+
13
+ const Headers = styled(View, {
14
+ base: {
15
+ width: '100%',
16
+ flexDirection: 'row',
17
+ alignItems: 'center',
18
+ justifyContent: 'flex-start'
19
+ },
20
+ variants: {
21
+ marginTop: size => {
22
+
23
+ if (!isValidNumber(size)) {
24
+ throw new Error('Invalid marginTop value')
25
+ }
26
+ return { marginTop: size }
27
+ }
28
+ }
29
+ })
30
+
31
+ const StyledHeader = ({ statusProps, ...rest }) => {
32
+ return (
33
+ <YStack>
34
+ <StatusBar
35
+ translucent
36
+ backgroundColor={theme.colors.gray[1]}
37
+ barStyle={'dark-content'}
38
+ {...statusProps}
39
+ />
40
+ <Headers {...rest} />
41
+ </YStack>
42
+ )
43
+ }
44
+
45
+ const Title = ({ navigator, title, icon = false, cycleProps, reload = false, screen, ...rest }) => {
46
+
47
+ return (
48
+ <XStack justifyContent='flex-start' alignItems='center' flex={1} paddingHorizontal={8}
49
+ paddingVertical={8} {...rest}>
50
+ {
51
+ icon && (
52
+ <StyledCycle {...cycleProps}>
53
+ <>
54
+ <Icon
55
+ name={'arrow-back'}
56
+ size={30}
57
+ color={theme.colors.gray[700]}
58
+ onPress={() => {
59
+ if (reload && screen && navigator) {
60
+ navigator.replace(screen)
61
+ } else {
62
+ navigator.goBack()
63
+ }
64
+ }}
65
+ />
66
+ <StyledSpacer marginHorizontal={4} />
67
+ </>
68
+ </StyledCycle>
69
+ )
70
+ }
71
+ {title &&
72
+ <StyledText
73
+ color={theme.colors.gray[800]}
74
+ fontWeight={theme.fontWeight.normal}
75
+ fontSize={theme.fontSize.normal}
76
+ >
77
+ {title}
78
+ </StyledText>}
79
+ </XStack>
80
+ )
81
+ }
82
+
83
+ const Full = ({ children }) => {
84
+ return (
85
+ <>{children}</>
86
+ )
87
+ }
88
+
89
+ StyledHeader.Title = Title
90
+ StyledHeader.Full = Full
91
+
92
+ export { StyledHeader }
@@ -0,0 +1,93 @@
1
+ import React from 'react'
2
+ import { Image as SourceImage, ImageBackground as ImageBg } from 'react-native'
3
+ import { styled } from '../styled'
4
+ import { isValidColor, isValidNumber } from '../utils'
5
+
6
+ const base = {
7
+ borderRadius: 8,
8
+ resizeMode: 'cover',
9
+ position: 'relative'
10
+ }
11
+
12
+ const variants = {
13
+ borderRadius: (size = 32) => {
14
+ if (!isValidNumber(size)) {
15
+ throw new Error('Invalid borderRadius value')
16
+ }
17
+ return { borderRadius: size }
18
+ },
19
+ flex: size => {
20
+ if (!isValidNumber(size)) {
21
+ throw new Error('Invalid flex value')
22
+ }
23
+ return { flex: size }
24
+ },
25
+ width: size => {
26
+ if (!size) return
27
+ return { width: size }
28
+ },
29
+ height: size => {
30
+ if (!size) return
31
+ return { height: size }
32
+ },
33
+ borderWidth: size => {
34
+ if (!isValidNumber(size)) {
35
+ throw new Error('Invalid borderWidth value')
36
+ }
37
+ return { borderWidth: size }
38
+ },
39
+ borderColor: color => {
40
+ if (!isValidColor(color)) {
41
+ throw new Error('Invalid color value')
42
+ }
43
+ return { borderColor: color }
44
+ },
45
+ resizeMode: mode => {
46
+ const validModes = ['cover', 'contain', 'stretch', 'repeat', 'center']
47
+ if (!validModes.includes(mode)) {
48
+ throw new Error('Invalid mode value')
49
+ }
50
+ return { resizeMode: mode }
51
+ },
52
+ right: (size = 0) => {
53
+ if (!isValidNumber(size)) {
54
+ throw new Error('Invalid right value')
55
+ }
56
+ return { right: size }
57
+ }
58
+ }
59
+
60
+ const Image = styled(SourceImage, {
61
+ base: { ...base },
62
+ variants: {
63
+ ...variants
64
+ }
65
+ })
66
+
67
+ const ImageBackground = styled(ImageBg, {
68
+ base: { ...base },
69
+ variants: {
70
+ ...variants
71
+ }
72
+ })
73
+
74
+ const StyledImage = ({ imageUrl, local = false, ...rest }) => {
75
+ const url = imageUrl
76
+ ? {
77
+ uri: imageUrl
78
+ }
79
+ : require('../../assets/img/doctor.png')
80
+ return <Image source={local ? imageUrl : url} {...rest} />
81
+ }
82
+
83
+ const StyledBackgroundImage = ({ imageUrl, local = false, ...rest }) => {
84
+ const url = imageUrl
85
+ ? {
86
+ uri: imageUrl
87
+ }
88
+ : require('../../assets/img/doctor.png')
89
+
90
+ return <ImageBackground source={local ? imageUrl : url} {...rest} />
91
+ }
92
+
93
+ export { StyledImage, StyledBackgroundImage }
@@ -0,0 +1,81 @@
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
+ import { isValidColor, isValidNumber, isValidString } from '../utils'
7
+
8
+ const RadioButton = styled(TouchableOpacity, {
9
+ base: {
10
+ width: 24,
11
+ height: 24,
12
+ borderWidth: 2,
13
+ borderRadius: 100,
14
+ borderColor: theme.colors.gray[500],
15
+ justifyContent: 'center',
16
+ alignItems: 'center',
17
+ flexDirection: 'column'
18
+ },
19
+ variants: {
20
+ width: size => {
21
+ if (!size) return
22
+ return { width: size }
23
+ },
24
+ height: size => {
25
+ if (!size) return
26
+ return { height: size }
27
+ },
28
+ disabled: {
29
+ true: {
30
+ backgroundColor: theme.colors.gray[500]
31
+ }
32
+ },
33
+ checked: {
34
+ true: {
35
+ backgroundColor: theme.colors.gray[1]
36
+ }
37
+ },
38
+ checkedColor: color => {
39
+ if (!color) return
40
+ return {
41
+ backgroundColor: color,
42
+ borderColor: color
43
+ }
44
+ }
45
+ }
46
+ })
47
+
48
+ const StyledRadioButton = ({
49
+ onPress,
50
+ disabled = false,
51
+ checkedColor,
52
+ iconProps,
53
+ ...rest
54
+ }) => {
55
+ const [checked, setChecked] = useState(false)
56
+
57
+ const toggleCheckbox = () => {
58
+ setChecked(!checked)
59
+ onPress && onPress(!checked)
60
+ }
61
+
62
+ return (
63
+ <RadioButton
64
+ disabled={disabled}
65
+ checked={checked}
66
+ checkedColor={checked && checkedColor && checkedColor}
67
+ onPress={() => toggleCheckbox()}
68
+ {...rest}
69
+ >
70
+ {checked &&
71
+ <Icon
72
+ name='circle'
73
+ color={theme.colors.gray[700]}
74
+ size={15}
75
+ {...iconProps}
76
+ />}
77
+ </RadioButton>
78
+ )
79
+ }
80
+
81
+ export { StyledRadioButton }
@@ -0,0 +1,12 @@
1
+ import { SafeAreaView } from "react-native";
2
+ import { styled } from "../styled";
3
+
4
+ const StyledSafeAreaView = styled(SafeAreaView, {
5
+ variants : {
6
+ backgroundColor: (color) => ({
7
+ backgroundColor: color
8
+ }),
9
+ }
10
+ })
11
+
12
+ export { StyledSafeAreaView }
@@ -0,0 +1,12 @@
1
+ import { ScrollView } from 'react-native'
2
+ import { styled } from '../styled'
3
+
4
+ const StyledScrollView = styled(ScrollView, {
5
+ variants: {
6
+ backgroundColor: color => ({
7
+ backgroundColor: color
8
+ })
9
+ }
10
+ })
11
+
12
+ export { StyledScrollView }
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { XStack } from '../stack'
3
+ import { theme } from '../theme'
4
+
5
+ const StyledSeparator = ({ left, right, line, lineProps, ...rest }) => {
6
+ if (line) {
7
+ return <XStack borderTopWidth={1} borderTopColor={theme.colors.gray[800]} {...lineProps} />
8
+ }
9
+
10
+ return (
11
+ <XStack justifyContent='space-between' paddingVertical={8} paddingHorizontal={8} alignItems='center' {...rest}>
12
+ {
13
+ left && (
14
+ <>{left}</>
15
+ )
16
+ }
17
+ {
18
+ right && (
19
+ <>{right}</>
20
+ )
21
+ }
22
+ </XStack>
23
+ )
24
+ }
25
+
26
+ export { StyledSeparator }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { styled } from "../styled";
4
+
5
+ const Spacer = styled(View)
6
+
7
+ const StyledSpacer = ({ ...rest }) => {
8
+ return (
9
+ <Spacer {...rest} />
10
+ )
11
+ }
12
+
13
+ export {StyledSpacer}
@@ -0,0 +1,33 @@
1
+ import React from 'react'
2
+ import { ActivityIndicator, StyleSheet } from 'react-native'
3
+ import { styled } from '../styled'
4
+ import { theme } from '../theme'
5
+
6
+ const Spinner = styled(ActivityIndicator, {
7
+ base: {
8
+ color: theme.colors.gray[400]
9
+ },
10
+ variants: {
11
+ overlay: {
12
+ true: {
13
+ ...StyleSheet.absoluteFillObject,
14
+ position: 'absolute',
15
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ flex: 1
19
+ }
20
+ }
21
+ }
22
+ })
23
+
24
+ const StyledSpinner = ({
25
+ size = 120,
26
+ color = theme.colors.gray[400],
27
+ overlay = true,
28
+ ...rest
29
+ }) => {
30
+ return <Spinner size={size} overlay={overlay} color={color} {...rest} />
31
+ }
32
+
33
+ export { StyledSpinner }
@@ -0,0 +1,68 @@
1
+ import { expect, jest } from '@jest/globals';
2
+ import { render } from '@testing-library/react-native'
3
+ import { Stack, XStack, YStack } from '..'
4
+ import { palettes, theme } from '../../theme';
5
+ import { Platform } from 'react-native';
6
+
7
+ describe("Stack", () => {
8
+ it("Should render correctly with base style", () => {
9
+ const { getByTestId } = render(<Stack testID='test-stack-id' />)
10
+
11
+ const stack = getByTestId('test-stack-id')
12
+ expect(stack).toHaveStyle({
13
+ position: 'relative'
14
+ })
15
+ })
16
+
17
+ it("Should render correctly when transparent variant is set to true", () => {
18
+ const { getByTestId } = render(<Stack transparent testID='test-stack-id' />)
19
+
20
+ const stack = getByTestId('test-stack-id')
21
+ expect(stack).toHaveStyle({
22
+ position: 'relative',
23
+ backgroundColor: palettes.transparent
24
+ })
25
+ })
26
+
27
+ it("XStack should render flexDirection to row correctly", () => {
28
+ const { getByTestId } = render(<XStack testID='test-stack-id' />)
29
+
30
+ const stack = getByTestId('test-stack-id')
31
+ expect(stack).toHaveStyle({
32
+ flexDirection: 'row'
33
+ })
34
+ })
35
+ it("XStack should render correctly when transparent variant is set to true", () => {
36
+ const { getByTestId } = render(<XStack transparent testID='test-stack-id' />)
37
+
38
+ const stack = getByTestId('test-stack-id')
39
+ expect(stack).toHaveStyle({
40
+ position: 'relative',
41
+ backgroundColor: palettes.transparent
42
+ })
43
+ })
44
+
45
+ it("YStack should render flexDirection to column correctly", () => {
46
+ const { getByTestId } = render(<YStack testID='test-stack-id' />)
47
+
48
+ const stack = getByTestId('test-stack-id')
49
+ expect(stack).toHaveStyle({
50
+ flexDirection: 'column'
51
+ })
52
+ })
53
+
54
+ it("Should render shadow on stack correctly when shadow variant is set to light on ios", () => {
55
+ jest.spyOn(Platform, 'select').mockImplementation((obj)=>obj.ios)
56
+ const { getByTestId } = render(<Stack shadow='light' transparent testID='test-stack-id' />)
57
+
58
+ const stack = getByTestId('test-stack-id')
59
+ expect(stack).toHaveStyle({
60
+ position: 'relative',
61
+ backgroundColor: palettes.transparent,
62
+ shadowColor: theme.colors.gray[900],
63
+ shadowOffset: { width: 0, height: 1 },
64
+ shadowOpacity: 0.22,
65
+ shadowRadius: 2.22,
66
+ })
67
+ })
68
+ })
@@ -0,0 +1,37 @@
1
+ import { View } from "react-native";
2
+ import { styled } from "../styled";
3
+ import { theme } from "../theme";
4
+
5
+ const YStack = styled(View, {
6
+ base: {
7
+ flexDirection: 'column',
8
+ position: 'relative'
9
+ },
10
+ variants: {
11
+ transparent: {
12
+ true: {
13
+ backgroundColor: theme.colors.transparent,
14
+ }
15
+ }
16
+ }
17
+ })
18
+ const XStack = styled(View, {
19
+ base: {
20
+ flexDirection: 'row',
21
+ position:'relative'
22
+ },
23
+ variants: {
24
+ transparent: {
25
+ true: {
26
+ backgroundColor: theme.colors.transparent,
27
+ }
28
+ }
29
+ },
30
+ position: {
31
+ true: {
32
+ position: 'absolute'
33
+ }
34
+ },
35
+ })
36
+
37
+ export { XStack, YStack }