|
| 1 | +--- |
| 2 | +name: Inputs |
| 3 | +menu: Components |
| 4 | +--- |
| 5 | + |
| 6 | +import { Playground, PropsTable } from 'docz'; |
| 7 | +import { State } from 'react-powerplug'; |
| 8 | + |
| 9 | +import { Heading, Label } from '../Typography'; |
| 10 | +import { Box, Spacing } from '../Layout'; |
| 11 | +import TextInput from './TextInput'; |
| 12 | +import ClearableTextInput from './ClearableTextInput'; |
| 13 | +import TextArea from './TextArea'; |
| 14 | +import PhoneNumberInput from './PhoneNumberInput'; |
| 15 | + |
| 16 | +## TextInput |
| 17 | + |
| 18 | +<Playground> |
| 19 | + <Box marginBottom={24} width={360}> |
| 20 | + <Label size="medium">Medium (default)</Label> |
| 21 | + <TextInput placeholder="With placeholder" /> |
| 22 | + </Box> |
| 23 | + <Box marginBottom={24} width={360}> |
| 24 | + <Label size="medium">Disabled</Label> |
| 25 | + <TextInput value="This is disabled" isDisabled /> |
| 26 | + </Box> |
| 27 | + <Box marginBottom={24} width={360}> |
| 28 | + <Label size="medium">Is Invalid</Label> |
| 29 | + <TextInput isInvalid /> |
| 30 | + </Box> |
| 31 | + <Box marginBottom={24}> |
| 32 | + <Label size="small">Small</Label> |
| 33 | + <TextInput size="small" /> |
| 34 | + </Box> |
| 35 | + <Box marginBottom={24}> |
| 36 | + <Label size="medium">Medium</Label> |
| 37 | + <TextInput size="medium" /> |
| 38 | + </Box> |
| 39 | + <Box marginBottom={24}> |
| 40 | + <Label size="large">Large</Label> |
| 41 | + <TextInput size="large" /> |
| 42 | + </Box> |
| 43 | +</Playground> |
| 44 | + |
| 45 | +## TextArea |
| 46 | + |
| 47 | +<Playground> |
| 48 | + <Box marginBottom={24} width={360}> |
| 49 | + <Label size="medium">Medium (default)</Label> |
| 50 | + <TextArea placeholder="With placeholder" /> |
| 51 | + </Box> |
| 52 | + <Box marginBottom={24} width={360}> |
| 53 | + <Label size="medium">Disabled</Label> |
| 54 | + <TextArea value="This is disabled" isDisabled /> |
| 55 | + </Box> |
| 56 | + <Box marginBottom={24} width={360}> |
| 57 | + <Label size="medium">Is Invalid</Label> |
| 58 | + <TextArea isInvalid /> |
| 59 | + </Box> |
| 60 | + <Box marginBottom={24}> |
| 61 | + <Label size="small">Small</Label> |
| 62 | + <TextArea size="small" /> |
| 63 | + </Box> |
| 64 | + <Box marginBottom={24}> |
| 65 | + <Label size="medium">Medium</Label> |
| 66 | + <TextArea size="medium" /> |
| 67 | + </Box> |
| 68 | + <Box marginBottom={24}> |
| 69 | + <Label size="large">Large</Label> |
| 70 | + <TextArea size="large" /> |
| 71 | + </Box> |
| 72 | +</Playground> |
| 73 | + |
| 74 | +## ClearableTextInput |
| 75 | + |
| 76 | +<Playground> |
| 77 | + <Box marginBottom={24}> |
| 78 | + <State initial={{ value: '' }}> |
| 79 | + {({ state, setState }) => ( |
| 80 | + <ClearableTextInput |
| 81 | + onChangeText={text => setState({ value: text })} |
| 82 | + value={state.value} |
| 83 | + onClear={() => { |
| 84 | + console.log('Cleared!'); |
| 85 | + }} |
| 86 | + placeholder="Clearable text input" |
| 87 | + /> |
| 88 | + )} |
| 89 | + </State> |
| 90 | + </Box> |
| 91 | +</Playground> |
| 92 | + |
| 93 | +## PhoneNumberInput |
| 94 | + |
| 95 | +### Usage |
| 96 | + |
| 97 | +<Playground> |
| 98 | + <State initial={{ countryCode: 'US', phoneNumber: '' }}> |
| 99 | + {({ state, setState }) => ( |
| 100 | + <PhoneNumberInput |
| 101 | + header={ |
| 102 | + <Spacing marginVertical={3} paddingHorizontal={2}> |
| 103 | + <Heading size="xxxlarge">Select your country</Heading> |
| 104 | + </Spacing> |
| 105 | + } |
| 106 | + onChangeCountryCode={countryCode => setState({ countryCode })} |
| 107 | + onChangePhoneNumber={phoneNumber => setState({ phoneNumber })} |
| 108 | + phoneNumber={state.phoneNumber} |
| 109 | + countryCode={state.countryCode} |
| 110 | + placeholder="Enter your phone number" |
| 111 | + /> |
| 112 | + )} |
| 113 | + </State> |
| 114 | +</Playground> |
| 115 | + |
| 116 | +### Props |
| 117 | + |
| 118 | +<PropsTable of={PhoneNumberInput} /> |
0 commit comments