Skip to content

Commit 0d0eda0

Browse files
Viraj Ajay JoshiViraj Ajay Joshi
authored andcommitted
Merge branch 'patch' of github.com:gluestack/gluestack-ui into patch
2 parents e8a1713 + d3e5ada commit 0d0eda0

File tree

5 files changed

+626
-175
lines changed

5 files changed

+626
-175
lines changed

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

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cssInterop(UIButton.Spinner, { className: 'style' });
3737
cssInterop(UIButton.Icon, { className: 'style' });
3838

3939
const buttonStyle = tva({
40-
base: 'group/button rounded-lg bg-primary-500 flex-row items-center justify-center data-[focus=true]:web:outline-none data-[focus-visible=true]:web:ring-2 ',
40+
base: 'group/button rounded-lg bg-primary-500 flex-row items-center justify-center data-[focus=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[disabled=true]:opacity-40',
4141
variants: {
4242
action: {
4343
primary:
@@ -160,6 +160,62 @@ const buttonTextStyle = tva({
160160
],
161161
});
162162

163+
const buttonIconStyle = tva({
164+
base: 'text-typography-0',
165+
parentVariants: {
166+
action: {
167+
primary:
168+
'text-primary-600 group-hover/button:text-primary-600 group-active/button:text-primary-700',
169+
secondary:
170+
'text-secondary-600 group-hover/button:text-secondary-600 group-active/button:text-secondary-700',
171+
positive:
172+
'text-success-600 group-hover/button:text-success-600 group-active/button:text-success-700',
173+
negative:
174+
'text-error-600 group-hover/button:text-error-600 group-active/button:text-error-700',
175+
},
176+
variant: {
177+
link: 'group-hover/button:underline group-active/button:underline',
178+
outline: '',
179+
solid:
180+
'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0',
181+
},
182+
size: {
183+
'2xs': 'h-3 w-3',
184+
'xs': 'h-3.5 w-3.5',
185+
'sm': 'h-4 w-4',
186+
'md': 'h-[18px] w-[18px]',
187+
'lg': 'h-5 w-5',
188+
'xl': 'h-6 w-6',
189+
},
190+
},
191+
parentCompoundVariants: [
192+
{
193+
variant: 'solid',
194+
action: 'primary',
195+
class:
196+
'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0',
197+
},
198+
{
199+
variant: 'solid',
200+
action: 'secondary',
201+
class:
202+
'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0',
203+
},
204+
{
205+
variant: 'solid',
206+
action: 'positive',
207+
class:
208+
'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0',
209+
},
210+
{
211+
variant: 'solid',
212+
action: 'negative',
213+
class:
214+
'text-typography-0 group-hover/button:text-typography-0 group-active/button:text-typography-0',
215+
},
216+
],
217+
});
218+
163219
type IButtonProps = React.ComponentProps<typeof UIButton> &
164220
VariantProps<typeof buttonStyle>;
165221

@@ -234,12 +290,43 @@ const ButtonSpinner = UIButton.Spinner;
234290
const ButtonIcon = ({
235291
className,
236292
as: AsComp,
293+
size,
237294
...props
238295
}: IButtonIcon & { className?: any }) => {
296+
const {
297+
variant: parentVariant,
298+
size: parentSize,
299+
action: parentAction,
300+
} = useStyleContext();
301+
239302
if (AsComp) {
240-
return <AsComp className={className} {...props} />;
303+
return (
304+
<AsComp
305+
{...props}
306+
className={buttonIconStyle({
307+
parentVariants: {
308+
size: parentSize,
309+
variant: parentVariant,
310+
action: parentAction,
311+
},
312+
size,
313+
class: className,
314+
})}
315+
/>
316+
);
241317
}
242-
return <UIButton.Icon className={className} {...props} />;
318+
return (
319+
<UIButton.Icon
320+
{...props}
321+
className={buttonIconStyle({
322+
parentVariants: {
323+
size: parentSize,
324+
},
325+
size,
326+
class: className,
327+
})}
328+
/>
329+
);
243330
};
244331
Button.displayName = 'Button';
245332
ButtonText.displayName = 'ButtonText';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const UIIcon = createIcon({
88
});
99

1010
const iconStyle = tva({
11-
base: 'color-background-800 fill-none',
11+
base: 'text-background-800 fill-none',
1212
variants: {
1313
size: {
1414
'2xs': 'h-3 w-3',
Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
import React from 'react';
2-
import { Button, ButtonText } from '@/components/ui/Button';
2+
import {
3+
Button,
4+
ButtonText,
5+
ButtonIcon,
6+
ButtonSpinner,
7+
} from '@/components/ui/Button';
8+
import { EditIcon, ArrowLeftIcon } from 'lucide-react-native';
9+
import {
10+
Icon,
11+
ArrowUpIcon,
12+
AddIcon,
13+
InfoIcon,
14+
ThreeDotsIcon,
15+
} from '@/components/ui/Icon';
16+
import { Input, InputField } from '@/components/ui/Input';
17+
import { HStack } from '@/components/ui/HStack';
18+
import { VStack } from '@/components/ui/VStack';
19+
import { Text } from '@/components/ui/Text';
20+
import { Heading } from '@/components/ui/Heading';
21+
import { Box } from '@/components/ui/Box';
22+
import { Center } from '@/components/ui/Center';
323

424
export const ButtonBasic = (props: any) => {
525
return (
6-
<>
7-
<Button {...props}>
8-
<ButtonText>Hello World 22</ButtonText>
9-
</Button>
10-
</>
26+
<Button {...props}>
27+
<ButtonText>Hello World 22</ButtonText>
28+
</Button>
1129
);
1230
};
1331

@@ -16,4 +34,24 @@ ButtonBasic.description =
1634

1735
export default ButtonBasic;
1836

19-
export { Button, ButtonText };
37+
export {
38+
Button,
39+
ButtonText,
40+
ButtonIcon,
41+
ButtonSpinner,
42+
EditIcon,
43+
ArrowLeftIcon,
44+
Icon,
45+
ArrowUpIcon,
46+
AddIcon,
47+
InfoIcon,
48+
ThreeDotsIcon,
49+
Input,
50+
InputField,
51+
HStack,
52+
VStack,
53+
Text,
54+
Heading,
55+
Box,
56+
Center,
57+
};

0 commit comments

Comments
 (0)