Skip to content

Commit 35a5238

Browse files
authored
Merge pull request #1860 from gluestack/feat/new-examples-with-gluestack
feat: added examples for themed components
2 parents a65c6b8 + b361824 commit 35a5238

File tree

3 files changed

+264
-14
lines changed

3 files changed

+264
-14
lines changed

example/storybook-nativewind/src/components/Input/index.themed.stories.mdx

Lines changed: 145 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@ import { Meta } from '@storybook/addon-docs';
1414

1515
<Meta title="with-gluestack-style/components/Forms/Input" />
1616

17-
import { Input, InputField, InputIcon, InputSlot } from './Input';
1817
import {
18+
Input,
19+
InputField,
20+
InputIcon,
21+
InputSlot,
1922
Button,
2023
ButtonText,
2124
VStack,
2225
Text as GSText,
2326
Center,
2427
Box,
2528
FormControl,
26-
} from '@gluestack-ui/themed';
27-
import { Heading, useState } from '@gluestack-ui/themed';
28-
import { Icon, SearchIcon, EyeIcon, EyeOffIcon } from '@gluestack-ui/themed';
29+
Heading,
30+
Icon,
31+
SearchIcon,
32+
EyeIcon,
33+
EyeOffIcon,
34+
} from '../../components-example/themed';
2935
import { transformedCode } from '../../utils';
3036
import {
3137
AppProvider,
@@ -104,9 +110,7 @@ npm i @gluestack-ui/input
104110
### Step 2: Copy and paste the following code into your project.
105111

106112
<CollapsibleCode>
107-
```jsx
108-
%%-- File: components-example/themed/Input/index.tsx --%%
109-
```
113+
```jsx %%-- File: components-example/themed/Input/index.tsx --%% ```
110114
</CollapsibleCode>
111115

112116
### Step 3: Update the import paths to match your project setup.
@@ -484,3 +488,137 @@ Explore the comprehensive details of the Input in this document, including its i
484488
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Fproto%2FNcXOxqKbdnGsLQNex3H76u%2F%25C2%25A0%25F0%259F%2593%259Agluestack-UI-handbook%3Fpage-id%3D213%253A12091%26type%3Ddesign%26node-id%3D213-12092%26viewport%3D256%252C289%252C0.03%26t%3DYlY4Jjtl91JuXCZS-1%26scaling%3Dscale-down%26starting-point-node-id%3D213%253A12092%26mode%3Ddesign"
485489
allowFullScreen
486490
></iframe>
491+
492+
### Examples
493+
494+
The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.
495+
496+
#### Input type password with FormControl
497+
498+
The Input component integrates with an icon and a button, providing users with a comprehensive login window inside a FormControl component.
499+
500+
<AppProvider>
501+
<CodePreview
502+
_rendererWrapper={{ py: '$8' }}
503+
showComponentRenderer={true}
504+
showArgsController={false}
505+
metaData={{
506+
code: `
507+
function App() {
508+
const [showPassword, setShowPassword] = React.useState(false);
509+
const handleState = () => {
510+
setShowPassword((showState) => {
511+
return !showState;
512+
});
513+
};
514+
return (
515+
<FormControl
516+
p='$4'
517+
borderWidth='$1'
518+
borderRadius='$lg'
519+
borderColor='$borderLight300'
520+
$dark-borderWidth='$1' $dark-borderRadius='$lg' $dark-borderColor='$borderDark800'
521+
>
522+
<VStack space='xl'>
523+
<Heading color='$text900' lineHeight='$md'>
524+
Login
525+
</Heading>
526+
<VStack space='xs'>
527+
<Text color='$text500' lineHeight='$xs'>
528+
Email
529+
</Text>
530+
<Input>
531+
<InputField
532+
type="text"
533+
/>
534+
</Input>
535+
</VStack>
536+
<VStack space='xs'>
537+
<Text color='$text500' lineHeight='$xs'>
538+
Password
539+
</Text>
540+
<Input textAlign='center'>
541+
<InputField
542+
type={showPassword ? 'text' : 'password'}
543+
/>
544+
<InputSlot pr='$3' onPress={handleState}>
545+
{/* EyeIcon, EyeOffIcon are both imported from 'lucide-react-native' */}
546+
<InputIcon as={showPassword ? EyeIcon : EyeOffIcon} color='$darkBlue500'/>
547+
</InputSlot>
548+
</Input>
549+
</VStack>
550+
<Button
551+
ml='auto'
552+
onPress={()=>{
553+
setShowModal(false);
554+
}}
555+
>
556+
<ButtonText color='$white'>
557+
Save
558+
</ButtonText>
559+
</Button>
560+
</VStack>
561+
</FormControl>
562+
);
563+
}
564+
`,
565+
transformCode: (code) => {
566+
return transformedCode(code, 'function', 'App');
567+
},
568+
scope: {
569+
Wrapper,
570+
Input,
571+
InputField,
572+
InputIcon,
573+
Button,
574+
ButtonText,
575+
VStack,
576+
Text: GSText,
577+
Heading,
578+
Icon,
579+
EyeIcon,
580+
EyeOffIcon,
581+
FormControl,
582+
InputSlot,
583+
},
584+
argsType: {},
585+
}}
586+
/>
587+
</AppProvider>
588+
589+
### Input with Icons
590+
591+
The Input with Icons is a variation of the Input component that displays icons next to input field. It's commonly used in apps for a more visual representation of options and easier navigation.
592+
593+
<AppProvider>
594+
<CodePreview
595+
showComponentRenderer={true}
596+
showArgsController={false}
597+
metaData={{
598+
code: `
599+
<Input>
600+
<InputSlot pl='$3'>
601+
<InputIcon as={SearchIcon}/>
602+
</InputSlot>
603+
<InputField
604+
placeholder="Search..."
605+
/>
606+
</Input>
607+
`,
608+
transformCode: (code) => {
609+
return transformedCode(code);
610+
},
611+
scope: {
612+
Wrapper,
613+
Input,
614+
InputField,
615+
InputIcon,
616+
SearchIcon,
617+
Icon,
618+
InputSlot,
619+
},
620+
argsType: {},
621+
}}
622+
/>
623+
624+
</AppProvider>

example/storybook-nativewind/src/components/Link/index.themed.stories.mdx

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@ import { Meta } from '@storybook/addon-docs';
1414

1515
<Meta title="with-gluestack-style/components/Forms/Link" />
1616

17-
import { Link } from './Link';
18-
import { LinkText } from '../../components-example/themed/Link';
19-
import { ArrowUpRightIcon, Icon, HStack, Text } from '@gluestack-ui/themed';
20-
import { transformedCode } from '../../utils';
17+
import {
18+
Link,
19+
LinkText,
20+
ArrowUpRightIcon,
21+
Icon,
22+
HStack,
23+
Text,
24+
} from '../../components-example/themed';
2125
import {
2226
AppProvider,
2327
CodePreview,
2428
Table,
2529
TableContainer,
2630
InlineCode,
2731
} from '@gluestack/design-system';
28-
32+
import { transformedCode } from '../../utils';
2933
import Wrapper from '../../components-example/themed/Wrapper';
3034
import { CollapsibleCode } from '@gluestack/design-system';
3135

@@ -368,3 +372,61 @@ props: {
368372
369373
export default () => <StyledLink />;
370374
``` -->
375+
376+
### Examples
377+
378+
The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.
379+
380+
#### Default
381+
382+
<AppProvider>
383+
<CodePreview
384+
showComponentRenderer={true}
385+
showArgsController={false}
386+
metaData={{
387+
code: `
388+
<HStack>
389+
<Text
390+
size="lg"
391+
>Design inspiration from </Text>
392+
<Link href="https://gluestack.io/" isExternal>
393+
<LinkText size="lg">pinterest.com</LinkText>
394+
</Link>
395+
</HStack>
396+
`,
397+
transformCode: (code) => {
398+
return transformedCode(code);
399+
},
400+
scope: { Link, LinkText, Wrapper, ArrowUpRightIcon, Icon, HStack, Text },
401+
argsType: {},
402+
}}
403+
/>
404+
</AppProvider>
405+
406+
#### Link with icon
407+
408+
<AppProvider>
409+
<CodePreview
410+
showComponentRenderer={true}
411+
showArgsController={false}
412+
metaData={{
413+
code: `
414+
<HStack>
415+
<Text
416+
size="lg">Go to </Text>
417+
<Link href="https://gluestack.io/" isExternal>
418+
<HStack alignItems="center">
419+
<LinkText size="lg">Pinterest</LinkText>
420+
<Icon as={ArrowUpRightIcon} size="lg" color="$info600" mt="$0.5" $dark-color="$info300"/>
421+
</HStack>
422+
</Link>
423+
</HStack>
424+
`,
425+
transformCode: (code) => {
426+
return transformedCode(code);
427+
},
428+
scope: { Link, LinkText, Wrapper, ArrowUpRightIcon, Icon, HStack, Text },
429+
argsType: {},
430+
}}
431+
/>
432+
</AppProvider>

example/storybook-nativewind/src/components/Textarea/index.themed.stories.mdx

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ import { Meta } from '@storybook/addon-docs';
1414

1515
<Meta title="with-gluestack-style/components/Forms/Textarea" />
1616

17-
import { Textarea, TextareaInput } from './Textarea';
1817
import {
1918
FormControl,
2019
FormControlError,
2120
FormControlLabel,
2221
FormControlLabelText,
2322
FormControlHelper,
2423
FormControlHelperText,
25-
} from '@gluestack-ui/themed';
24+
Textarea,
25+
TextareaInput,
26+
} from '../../components-example/themed';
2627
import { transformedCode } from '../../utils';
2728
import {
2829
AppProvider,
@@ -367,3 +368,52 @@ Explore the comprehensive details of the Input in this document, including its i
367368
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Fproto%2FNcXOxqKbdnGsLQNex3H76u%2F%25C2%25A0%25F0%259F%2593%259Agluestack-UI-handbook%3Fpage-id%3D5262%253A23948%26type%3Ddesign%26node-id%3D5262-25827%26viewport%3D713%252C121%252C0.03%26t%3DKYZLJTBIKhIjLoLC-1%26scaling%3Dscale-down%26starting-point-node-id%3D5262%253A25827%26mode%3Ddesign"
368369
allowfullscreen
369370
></iframe>
371+
372+
### Examples
373+
374+
The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.
375+
376+
#### FormControl
377+
378+
The Textarea Component can be incorporated within the FormControl.
379+
380+
<AppProvider>
381+
<CodePreview
382+
showComponentRenderer={true}
383+
showArgsController={false}
384+
metaData={{
385+
code: `
386+
<FormControl>
387+
<FormControlLabel>
388+
<FormControlLabelText>
389+
Write with me
390+
</FormControlLabelText>
391+
</FormControlLabel>
392+
<Textarea>
393+
<TextareaInput placeholder='Once upon a time...'/>
394+
</Textarea>
395+
<FormControlHelper>
396+
<FormControlHelperText>
397+
Start your story
398+
</FormControlHelperText>
399+
</FormControlHelper>
400+
</FormControl>
401+
`,
402+
transformCode: (code) => {
403+
return transformedCode(code);
404+
},
405+
scope: {
406+
Wrapper,
407+
Textarea,
408+
TextareaInput,
409+
FormControl,
410+
FormControlError,
411+
FormControlLabel,
412+
FormControlLabelText,
413+
FormControlHelper,
414+
FormControlHelperText,
415+
},
416+
argsType: {},
417+
}}
418+
/>
419+
</AppProvider>

0 commit comments

Comments
 (0)