Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove select and modal examples from form control story #1881

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading