Skip to content

Commit f86ada7

Browse files
SurajSuraj
authored andcommitted
fix: added components
1 parent a12b16b commit f86ada7

File tree

50 files changed

+10064
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+10064
-0
lines changed
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
import { createAccordion } from '@gluestack-ui/accordion';
2+
import { AsForwarder, styled } from '@gluestack-style/react';
3+
import { View, Pressable, Text, Platform } from 'react-native';
4+
5+
import { H3 } from '@expo/html-elements';
6+
7+
const StyleRoot = styled(
8+
View,
9+
{
10+
width: '$full',
11+
_icon: {
12+
color: '$text900',
13+
},
14+
_titleText: {
15+
color: '$text900',
16+
},
17+
_contentText: {
18+
color: '$text700',
19+
},
20+
21+
variants: {
22+
size: {
23+
sm: {
24+
_titleText: {
25+
fontSize: '$sm',
26+
fontFamily: '$body',
27+
fontWeight: '$bold',
28+
lineHeight: '$sm',
29+
},
30+
_contentText: {
31+
fontSize: '$sm',
32+
fontFamily: '$body',
33+
fontWeight: '$normal',
34+
lineHeight: '$sm',
35+
},
36+
},
37+
md: {
38+
_titleText: {
39+
fontSize: '$md',
40+
fontFamily: '$body',
41+
fontWeight: '$bold',
42+
lineHeight: '$md',
43+
},
44+
_contentText: {
45+
fontSize: '$md',
46+
fontFamily: '$body',
47+
fontWeight: '$normal',
48+
lineHeight: '$md',
49+
},
50+
},
51+
lg: {
52+
_titleText: {
53+
fontSize: '$lg',
54+
fontFamily: '$body',
55+
fontWeight: '$bold',
56+
lineHeight: '$lg',
57+
},
58+
_contentText: {
59+
fontSize: '$lg',
60+
fontFamily: '$body',
61+
fontWeight: '$normal',
62+
lineHeight: '$lg',
63+
},
64+
},
65+
},
66+
variant: {
67+
filled: {
68+
backgroundColor: '$white',
69+
70+
_item: {
71+
backgroundColor: '$background0',
72+
},
73+
74+
shadowColor: '$background900',
75+
76+
shadowOffset: {
77+
width: 0,
78+
height: 3,
79+
},
80+
81+
shadowRadius: 8,
82+
shadowOpacity: 0.2,
83+
elevation: 10,
84+
},
85+
unfilled: {
86+
shadowColor: 'transparent',
87+
88+
shadowOffset: {
89+
width: 0,
90+
height: 0,
91+
},
92+
93+
_item: {
94+
backgroundColor: 'transparent',
95+
},
96+
},
97+
},
98+
},
99+
defaultProps: {
100+
theme: 'light',
101+
size: 'md',
102+
variant: 'filled',
103+
},
104+
},
105+
{
106+
descendantStyle: [
107+
'_item',
108+
'_titleText',
109+
'_button',
110+
'_icon',
111+
'_contentText',
112+
],
113+
}
114+
);
115+
const StyledItem = styled(View, {}, { ancestorStyle: ['_item'] });
116+
// @ts-ignore
117+
const StyledHeader = styled(Platform.OS === 'web' ? H3 : View, {
118+
mx: '$0',
119+
my: '$0',
120+
});
121+
const StyledTrigger = styled(
122+
Pressable,
123+
{
124+
'width': '$full',
125+
'py': '$5',
126+
'px': '$5',
127+
'flexDirection': 'row',
128+
'justifyContent': 'space-between',
129+
'alignItems': 'center',
130+
'_web': {
131+
outlineWidth: 0,
132+
},
133+
':disabled': {
134+
opacity: 0.4,
135+
_web: {
136+
cursor: 'not-allowed',
137+
},
138+
},
139+
':focusVisible': {
140+
bg: '$background50',
141+
},
142+
},
143+
{
144+
descendantStyle: ['_icon', '_titleText', '_contentText'],
145+
ancestorStyle: ['_button'],
146+
}
147+
);
148+
const StyledTitleText = styled(
149+
Text,
150+
{ flex: 1, textAlign: 'left' },
151+
{ ancestorStyle: ['_titleText'] }
152+
);
153+
const StyledContentText = styled(Text, {}, { ancestorStyle: ['_contentText'] });
154+
const StyledIcon = styled(
155+
AsForwarder,
156+
{
157+
color: '$background800',
158+
159+
// defaultProps: {
160+
// size: 'md',
161+
// },
162+
variants: {
163+
size: {
164+
'2xs': {
165+
h: '$3',
166+
w: '$3',
167+
props: {
168+
// @ts-ignore
169+
size: 12,
170+
},
171+
},
172+
'xs': {
173+
h: '$3.5',
174+
w: '$3.5',
175+
props: {
176+
//@ts-ignore
177+
size: 14,
178+
},
179+
},
180+
'sm': {
181+
h: '$4',
182+
w: '$4',
183+
props: {
184+
//@ts-ignore
185+
size: 16,
186+
},
187+
},
188+
'md': {
189+
h: '$4.5',
190+
w: '$4.5',
191+
props: {
192+
//@ts-ignore
193+
size: 18,
194+
},
195+
},
196+
'lg': {
197+
h: '$5',
198+
w: '$5',
199+
props: {
200+
//@ts-ignore
201+
size: 20,
202+
},
203+
},
204+
'xl': {
205+
h: '$6',
206+
w: '$6',
207+
props: {
208+
//@ts-ignore
209+
size: 24,
210+
},
211+
},
212+
},
213+
},
214+
215+
props: {
216+
size: 'md',
217+
},
218+
},
219+
{
220+
resolveProps: ['stroke', 'fill'],
221+
ancestorStyle: ['_icon'],
222+
},
223+
{
224+
propertyTokenMap: {
225+
stroke: 'colors',
226+
fill: 'colors',
227+
},
228+
}
229+
);
230+
const StyledContent = styled(View, { px: '$5', mt: '$2', pb: '$5' });
231+
232+
export const Accordion = createAccordion({
233+
Root: StyleRoot,
234+
Item: StyledItem,
235+
Header: StyledHeader,
236+
Trigger: StyledTrigger,
237+
Icon: StyledIcon,
238+
TitleText: StyledTitleText,
239+
ContentText: StyledContentText,
240+
Content: StyledContent,
241+
});
242+
243+
export const AccordionItem = Accordion.Item;
244+
export const AccordionHeader = Accordion.Header;
245+
export const AccordionTrigger = Accordion.Trigger;
246+
export const AccordionTitleText = Accordion.TitleText;
247+
export const AccordionContentText = Accordion.ContentText;
248+
export const AccordionIcon = Accordion.Icon;
249+
export const AccordionContent = Accordion.Content;

0 commit comments

Comments
 (0)