Skip to content

Commit 7058b4d

Browse files
authored
Merge branch 'patch' into config-v2
2 parents ec1d00c + 0d0eda0 commit 7058b4d

Some content is hidden

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

49 files changed

+6373
-2554
lines changed

.changeset/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"access": "public",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["@gluestack/ui-storybook", "@gluestack/storybook-nativewind"]
10+
"ignore": [
11+
"@gluestack/ui-storybook",
12+
"@nativewind-gluestack/storybook-nativewind"
13+
]
1114
}

example/storybook-nativewind/.storybook/preview.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,26 @@ export const parameters = {
4545
'Feedback',
4646
['Alert', 'Progress', 'Spinner', 'Toast'],
4747
'Data Display',
48-
['Badge'],
48+
['Badge', 'Card'],
4949
'Forms',
5050
[
5151
'Button',
5252
'Checkbox',
5353
'FormControl',
54+
'Input',
5455
'Link',
5556
'Pressable',
5657
'Radio',
5758
'Slider',
5859
'Switch',
60+
'Textarea',
5961
],
6062
'Overlay',
6163
['AlertDialog', 'Modal', 'Popover', 'Tooltip'],
6264
'Disclosure',
6365
['Actionsheet', 'Accordion'],
6466
'Media And Icons',
65-
['Avatar', 'Image'],
67+
['Avatar', 'Image', 'Icon'],
6668
'Others',
6769
['Fab'],
6870
],

example/storybook-nativewind/src/components-example/nativewind/Accordion/index.tsx

Lines changed: 99 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { createAccordion } from '@gluestack-ui/accordion';
21
import React from 'react';
2+
import { createAccordion } from '@gluestack-ui/accordion';
33
import { View, Pressable, Text, Platform } from 'react-native';
44
import {
55
tva,
66
withStyleContext,
7+
withStyleContextAndStates,
78
useStyleContext,
8-
withStates,
9+
VariantProps,
910
} from '@gluestack-ui/nativewind-utils';
1011

1112
import { H3 } from '@expo/html-elements';
@@ -14,14 +15,13 @@ import { cssInterop } from 'nativewind';
1415
/** Styles */
1516

1617
const accordionStyle = tva({
17-
base: 'w-full shadow-sm',
18+
base: 'w-full',
1819
variants: {
1920
variant: {
2021
filled: 'bg-white',
2122
},
2223
},
2324
});
24-
2525
const accordionItemStyle = tva({
2626
parentVariants: {
2727
variant: {
@@ -30,7 +30,6 @@ const accordionItemStyle = tva({
3030
},
3131
},
3232
});
33-
3433
const accordionTitleTextStyle = tva({
3534
base: 'text-typography-900 font-bold flex-1 text-left',
3635
parentVariants: {
@@ -44,7 +43,6 @@ const accordionTitleTextStyle = tva({
4443
const accordionIconStyle = tva({
4544
base: 'text-typography-900',
4645
});
47-
4846
const accordionContentTextStyle = tva({
4947
base: 'text-typography-700 font-normal',
5048
parentVariants: {
@@ -55,25 +53,28 @@ const accordionContentTextStyle = tva({
5553
},
5654
},
5755
});
58-
5956
const accordionHeaderStyle = tva({
6057
base: 'mx-0 my-0',
6158
});
6259
const accordionContentStyle = tva({
6360
base: 'px-5 mt-2 pb-5',
6461
});
65-
6662
const accordionTriggerStyle = tva({
6763
base: 'w-full py-5 px-5 flex-row justify-between items-center web:outline-none focus:outline-none data-[disabled=true]:opacity-40 data-[disabled=true]:cursor-not-allowed data-[focus-visible=true]:bg-background-50',
6864
});
6965

7066
/** Creator */
7167
const UIAccordion = createAccordion({
72-
Root: withStyleContext(View),
68+
//@ts-ignore
69+
Root:
70+
Platform.OS === 'web'
71+
? withStyleContext(Pressable)
72+
: withStyleContextAndStates(Pressable),
7373
Item: View,
7474
// @ts-ignore
7575
Header: Platform.OS === 'web' ? H3 : View,
76-
Trigger: Platform.OS === 'web' ? Pressable : withStates(Pressable),
76+
//@ts-ignore
77+
Trigger: Pressable,
7778
Icon: View,
7879
TitleText: Text,
7980
ContentText: Text,
@@ -89,33 +90,71 @@ cssInterop(UIAccordion.TitleText, { className: 'style' });
8990
cssInterop(UIAccordion.Content, { className: 'style' });
9091
cssInterop(UIAccordion.ContentText, { className: 'style' });
9192

93+
type IAccordionProps = React.ComponentProps<typeof UIAccordion> &
94+
VariantProps<typeof accordionStyle>;
95+
96+
type IAccordionItemProps = React.ComponentProps<typeof UIAccordion.Item> &
97+
VariantProps<typeof accordionItemStyle>;
98+
99+
type IAccordionContentProps = React.ComponentProps<typeof UIAccordion.Content> &
100+
VariantProps<typeof accordionContentStyle>;
101+
102+
type IAccordionContentTextProps = React.ComponentProps<
103+
typeof UIAccordion.ContentText
104+
> &
105+
VariantProps<typeof accordionContentTextStyle>;
106+
107+
type IAccordionIconProps = React.ComponentProps<typeof UIAccordion.Icon> & {
108+
as?: any;
109+
};
110+
111+
type IAccordionHeaderProps = React.ComponentProps<typeof UIAccordion.Header> &
112+
VariantProps<typeof accordionHeaderStyle>;
113+
114+
type IAccordionTriggerProps = React.ComponentProps<typeof UIAccordion.Trigger> &
115+
VariantProps<typeof accordionTriggerStyle>;
116+
117+
type IAccordionTitleTextProps = React.ComponentProps<
118+
typeof UIAccordion.TitleText
119+
> &
120+
VariantProps<typeof accordionTitleTextStyle>;
121+
92122
/** Components */
93123

94124
const Accordion = React.forwardRef(
95125
(
96-
{ className, variant = 'filled', size = 'md', ...props }: any,
126+
{
127+
className,
128+
variant = 'filled',
129+
//@ts-ignore
130+
size = 'md',
131+
...props
132+
}: { className?: string } & IAccordionProps,
97133
ref?: any
98134
) => {
99135
return (
100136
<UIAccordion
101137
ref={ref}
102138
{...props}
103-
className={accordionStyle({ variant, size, class: className })}
139+
className={accordionStyle({ variant, class: className })}
104140
context={{ variant, size }}
105141
/>
106142
);
107143
}
108144
);
109145

110146
const AccordionItem = React.forwardRef(
111-
({ className, ...props }: any, ref?: any) => {
112-
const { variant, size } = useStyleContext();
147+
(
148+
{ className, ...props }: { className?: string } & IAccordionItemProps,
149+
ref?: any
150+
) => {
151+
const { variant } = useStyleContext();
113152
return (
114153
<UIAccordion.Item
115154
ref={ref}
116155
{...props}
117156
className={accordionItemStyle({
118-
parentVariants: { variant, size },
157+
parentVariants: { variant },
119158
class: className,
120159
})}
121160
/>
@@ -124,7 +163,10 @@ const AccordionItem = React.forwardRef(
124163
);
125164

126165
const AccordionContent = React.forwardRef(
127-
({ className, ...props }: any, ref?: any) => {
166+
(
167+
{ className, ...props }: { className?: string } & IAccordionContentProps,
168+
ref?: any
169+
) => {
128170
return (
129171
<UIAccordion.Content
130172
ref={ref}
@@ -138,36 +180,56 @@ const AccordionContent = React.forwardRef(
138180
);
139181

140182
const AccordionContentText = React.forwardRef(
141-
({ className, ...props }: any, ref?: any) => {
142-
const { variant, size } = useStyleContext();
183+
(
184+
{
185+
className,
186+
...props
187+
}: { className?: string } & IAccordionContentTextProps,
188+
ref?: any
189+
) => {
190+
const { size } = useStyleContext();
143191
return (
144192
<UIAccordion.ContentText
145193
ref={ref}
146194
{...props}
147195
className={accordionContentTextStyle({
148-
parentVariants: { variant, size },
196+
parentVariants: { size },
149197
class: className,
150198
})}
151199
/>
152200
);
153201
}
154202
);
155203

156-
const AccordionIcon = React.forwardRef(
157-
({ className, ...props }: any, ref?: any) => {
204+
const AccordionIcon = ({
205+
className,
206+
as: AsComp,
207+
...props
208+
}: IAccordionIconProps & { className?: any }) => {
209+
if (AsComp) {
158210
return (
159-
<UIAccordion.Icon
160-
ref={ref}
161-
{...props}
211+
<AsComp
162212
className={accordionIconStyle({
163213
class: className,
164214
})}
215+
{...props}
165216
/>
166217
);
167218
}
168-
);
219+
return (
220+
<UIAccordion.Icon
221+
className={accordionIconStyle({
222+
class: className,
223+
})}
224+
{...props}
225+
/>
226+
);
227+
};
169228
const AccordionHeader = React.forwardRef(
170-
({ className, ...props }: any, ref?: any) => {
229+
(
230+
{ className, ...props }: { className?: string } & IAccordionHeaderProps,
231+
ref?: any
232+
) => {
171233
return (
172234
<UIAccordion.Header
173235
ref={ref}
@@ -180,7 +242,10 @@ const AccordionHeader = React.forwardRef(
180242
}
181243
);
182244
const AccordionTrigger = React.forwardRef(
183-
({ className, ...props }: any, ref?: any) => {
245+
(
246+
{ className, ...props }: { className?: string } & IAccordionTriggerProps,
247+
ref?: any
248+
) => {
184249
return (
185250
<UIAccordion.Trigger
186251
ref={ref}
@@ -193,14 +258,17 @@ const AccordionTrigger = React.forwardRef(
193258
}
194259
);
195260
const AccordionTitleText = React.forwardRef(
196-
({ className, ...props }: any, ref?: any) => {
197-
const { variant, size } = useStyleContext();
261+
(
262+
{ className, ...props }: { className?: string } & IAccordionTitleTextProps,
263+
ref?: any
264+
) => {
265+
const { size } = useStyleContext();
198266
return (
199-
<UIAccordion.Header
267+
<UIAccordion.TitleText
200268
ref={ref}
201269
{...props}
202270
className={accordionTitleTextStyle({
203-
parentVariants: { variant, size },
271+
parentVariants: { size },
204272
class: className,
205273
})}
206274
/>

0 commit comments

Comments
 (0)