Skip to content

Commit

Permalink
Merge pull request #1881 from gluestack/fix/form-control
Browse files Browse the repository at this point in the history
fix: remove select and modal examples from form control story
  • Loading branch information
surajahmed authored Mar 11, 2024
2 parents 3ed9dc3 + 6e503d9 commit cf37b8b
Showing 1 changed file with 0 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -672,240 +672,6 @@ The Textarea Component can be incorporated within the FormControl.
/>
</AppProvider>

#### Form Control with Inline Form

Inline forms can utilize FormControl for seamless integration and enhanced functionality.

<AppProvider>
<CodePreview
showComponentRenderer={true}
showArgsController={false}
metaData={{
code: `
<HStack space='md'>
<FormControl>
<Input>
<InputField
placeholder="Username"
/>
</Input>
</FormControl>
<FormControl>
<Select>
<SelectTrigger>
<SelectInput placeholder="Country"/>
<SelectIcon className='mr-3'>
<Icon as={ChevronDownIcon} />
</SelectIcon>
</SelectTrigger>
<SelectPortal>
<SelectBackdrop />
<SelectContent>
<SelectDragIndicatorWrapper>
<SelectDragIndicator />
</SelectDragIndicatorWrapper>
<SelectItem label="India" value="India" />
<SelectItem label="Sri Lanka" value="Sri Lanka" />
<SelectItem label="Uganda" value="Uganda" />
<SelectItem label="Japan" value="Japan" />
</SelectContent>
</SelectPortal>
</Select>
</FormControl>
<FormControl>
<Button className='bg-blue-600'>
<ButtonText className='font-medium text-sm' >
Next
</ButtonText>
</Button>
</FormControl>
</HStack>
`,
transformCode: (code) => {
return transformedCode(code);
},
scope: {
Wrapper,
FormControl,
FormControlLabel,
FormControlLabelText,
FormControlHelper,
FormControlHelperText,
FormControlError,
FormControlErrorIcon,
FormControlErrorText,
Icon,
HStack,
ChevronDownIcon,
Input,
InputField,
Select,
SelectTrigger,
SelectInput,
SelectIcon,
SelectPortal,
SelectBackdrop,
SelectContent,
SelectDragIndicatorWrapper,
SelectDragIndicator,
SelectItem,
Button,
ButtonText,
},
argsType: {},
}}
/>
</AppProvider>

#### Form Control with Form in Modal

Modal or other Overlay components can utilize FormControl for state management and error control.

<AppProvider>
<CodePreview
showComponentRenderer={true}
showArgsController={false}
metaData={{
code: `
function App() {
const [showModal, setShowModal] = useState(false);
return(
<Center className='h-[500px]'>
<Button
className='bg-blue-600 py-2.5 px-3'
onPress={()=>{
setShowModal(true);
}}
>
<ButtonText>
Change Settings
</ButtonText>
</Button>
<Modal
isOpen={showModal}
onClose={() => {
setShowModal(false)
}}
className='bg-white'
>
<ModalBackdrop/>
<ModalContent className='max-w-96'>
<ModalBody className='p-5'>
<VStack space='xs' className='mb-4'>
<Heading>
Change Settings
</Heading>
<Text size='sm'>
Make modifications to the settings with ease.
</Text>
</VStack>
<VStack className='py-2' space='xl'>
<FormControl>
<FormControlLabel>
<FormControlLabelText>
Name
</FormControlLabelText>
</FormControlLabel>
<Input>
<InputField
value='Wade Warren'
/>
</Input>
</FormControl>
<FormControl>
<FormControlLabel>
<FormControlLabelText>
Email
</FormControlLabelText>
</FormControlLabel>
<Input>
<InputField
value='[email protected]'
/>
</Input>
</FormControl>
<FormControl>
<FormControlLabel>
<FormControlLabelText>
Volume
</FormControlLabelText>
</FormControlLabel>
<Slider defaultValue={60} sliderTrackHeight={4}>
<SliderTrack>
<SliderFilledTrack/>
</SliderTrack>
<SliderThumb
/>
</Slider>
</FormControl>
<FormControl>
<HStack space='sm'>
<Switch size='sm'/>
<FormControlLabelText>
Dark Mode
</FormControlLabelText>
</HStack>
</FormControl>
</VStack>
<Button
className='mt-4'
onPress={()=>{
setShowModal(false);
}}
>
<ButtonText>
Save Changes
</ButtonText>
</Button>
</ModalBody>
</ModalContent>
</Modal>
</Center>
);
}
`,
transformCode: (code) => {
return transformedCode(code, 'function', 'App');
},
scope: {
Wrapper,
useState,
Box,
Center,
FormControl,
FormControlLabel,
FormControlLabelText,
FormControlHelper,
FormControlHelperText,
FormControlError,
FormControlErrorIcon,
FormControlErrorText,
Input,
InputField,
Button,
ButtonText,
Slider,
SliderTrack,
SliderFilledTrack,
SliderThumb,
Switch,
Modal,
ModalBackdrop,
ModalContent,
ModalHeader,
ModalCloseButton,
ModalBody,
ModalFooter,
Text: FormControlText,
Heading,
VStack,
HStack,
},
argsType: {},
}}
/>
</AppProvider>

#### Form Control with Error

Error messages can be displayed using FormControl.
Expand Down

0 comments on commit cf37b8b

Please sign in to comment.