|
| 1 | +import React, { PropTypes } from 'react'; |
| 2 | +import Layer from 'grommet-udacity/components/Layer'; |
| 3 | +import Form from 'grommet-udacity/components/Form'; |
| 4 | +import FormFields from 'grommet-udacity/components/FormFields'; |
| 5 | +import FormField from 'grommet-udacity/components/FormField'; |
| 6 | +import Box from 'grommet-udacity/components/Box'; |
| 7 | +import Heading from 'grommet-udacity/components/Heading'; |
| 8 | +import Button from 'grommet-udacity/components/Button'; |
| 9 | +import Footer from 'grommet-udacity/components/Footer'; |
| 10 | +import { Divider } from 'components'; |
| 11 | +import error from './utils/error'; |
| 12 | + |
| 13 | +const WelcomeModal = ({ |
| 14 | + onClose, |
| 15 | + isVisible, |
| 16 | + nameInput, |
| 17 | + onSubmit, |
| 18 | +}) => ( |
| 19 | + <Layer |
| 20 | + align="center" |
| 21 | + closer |
| 22 | + hidden={!isVisible} |
| 23 | + onClose={onClose} |
| 24 | + > |
| 25 | + <Box align="center" justify="center" pad="large"> |
| 26 | + <Heading align="center"> |
| 27 | + What should we call you? |
| 28 | + </Heading> |
| 29 | + <Divider /> |
| 30 | + <Form> |
| 31 | + <FormFields> |
| 32 | + <FormField |
| 33 | + help="What should we call you?" |
| 34 | + error={error(nameInput)} |
| 35 | + label="Enter your name" |
| 36 | + htmlFor="nameInput" |
| 37 | + > |
| 38 | + <input |
| 39 | + {...nameInput} |
| 40 | + required |
| 41 | + autoFocus |
| 42 | + placeholder="Ryan Collins" |
| 43 | + id="nameInput" |
| 44 | + autoComplete="on" |
| 45 | + name="name" |
| 46 | + type="text" |
| 47 | + aria-invalid={nameInput.error} |
| 48 | + aria-required |
| 49 | + className="input" |
| 50 | + /> |
| 51 | + </FormField> |
| 52 | + </FormFields> |
| 53 | + </Form> |
| 54 | + <Footer align="center" justify="center" pad="large"> |
| 55 | + <Button primary label="Submit" onClick={onSubmit} /> |
| 56 | + </Footer> |
| 57 | + </Box> |
| 58 | + </Layer> |
| 59 | +); |
| 60 | + |
| 61 | +WelcomeModal.propTypes = { |
| 62 | + onClose: PropTypes.func.isRequired, |
| 63 | + nameInput: PropTypes.object.isRequired, |
| 64 | + isVisible: PropTypes.bool.isRequired, |
| 65 | + onSubmit: PropTypes.func.isRequired, |
| 66 | +}; |
| 67 | + |
| 68 | +export default WelcomeModal; |
0 commit comments