|
| 1 | +@gov.au/form |
| 2 | +============ |
| 3 | + |
| 4 | +> The form component contains layout, labelling and inline validations for form fields |
| 5 | +
|
| 6 | + |
| 7 | +## Contents |
| 8 | + |
| 9 | +* [Install](#install) |
| 10 | +* [Dependency graph](#dependency-graph) |
| 11 | +* [Tests](#tests) |
| 12 | +* [Release History](#release-history) |
| 13 | +* [License](#license) |
| 14 | + |
| 15 | + |
| 16 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 17 | + |
| 18 | + |
| 19 | +## Install |
| 20 | + |
| 21 | + |
| 22 | +```shell |
| 23 | +yarn add @gov.au/form |
| 24 | +``` |
| 25 | + |
| 26 | +```shell |
| 27 | +npm install @gov.au/form |
| 28 | +``` |
| 29 | + |
| 30 | + |
| 31 | +**[⬆ back to top](#contents)** |
| 32 | + |
| 33 | + |
| 34 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 35 | + |
| 36 | + |
| 37 | +## Dependency graph |
| 38 | + |
| 39 | +```shell |
| 40 | +form |
| 41 | +└─ core |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +**[⬆ back to top](#contents)** |
| 46 | + |
| 47 | + |
| 48 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 49 | + |
| 50 | + |
| 51 | +## Tests |
| 52 | + |
| 53 | +The visual test: https://auds.service.gov.au/packages/form/tests/site/ |
| 54 | + |
| 55 | + |
| 56 | +**[⬆ back to top](#contents)** |
| 57 | + |
| 58 | + |
| 59 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 60 | + |
| 61 | + |
| 62 | +## Release History |
| 63 | + |
| 64 | +* v0.1.0 - 💥 Initial version |
| 65 | + |
| 66 | + |
| 67 | +**[⬆ back to top](#contents)** |
| 68 | + |
| 69 | + |
| 70 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 71 | + |
| 72 | + |
| 73 | +## License |
| 74 | + |
| 75 | +Copyright (c) Commonwealth of Australia. |
| 76 | +Licensed under [MIT](https://raw.githubusercontent.com/govau/design-system-components/packages/core/master/LICENSE). |
| 77 | + |
| 78 | + |
| 79 | +**[⬆ back to top](#contents)** |
| 80 | + |
| 81 | +# }; |
| 82 | + |
| 83 | + |
| 84 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 85 | + |
| 86 | + |
| 87 | +## Usage |
| 88 | + |
| 89 | + |
| 90 | +* [React](#react) |
| 91 | + |
| 92 | + |
| 93 | +**[⬆ back to top](#contents)** |
| 94 | + |
| 95 | + |
| 96 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 97 | + |
| 98 | +### React |
| 99 | + |
| 100 | +Usage: |
| 101 | + |
| 102 | +```jsx |
| 103 | +import { AUlabel, AUhintText, AUerrorText, AUformGroup, AUfieldset, AUlegend } from '@gov.au/form'; |
| 104 | + |
| 105 | +<AUlabel text="Email" /> |
| 106 | + |
| 107 | +<AUhintText text="We will only use this email to respond to your query." /> |
| 108 | + |
| 109 | +<AUerrorText text="Enter an email address in the correct format, like name@example.com" /> |
| 110 | + |
| 111 | +<AUformGroup> |
| 112 | + // labels, hint text, and form controls here |
| 113 | +</AUformGroup> |
| 114 | + |
| 115 | +<AUfieldset> |
| 116 | + <AUlegend> |
| 117 | + // labels/hint text here |
| 118 | + </AUlegend> |
| 119 | + |
| 120 | + // form controls here |
| 121 | + |
| 122 | +</AUfieldset> |
| 123 | +``` |
| 124 | + |
| 125 | +All props: |
| 126 | + |
| 127 | +```jsx |
| 128 | +<AUlabel |
| 129 | + text="Email" {/* The text of the label */} |
| 130 | + dark={ true } {/* The dark variation of the component */} |
| 131 | + inline={ true } {/* Label inline*/} |
| 132 | +/> |
| 133 | + |
| 134 | +<AUhintText |
| 135 | + text="We will only use this email to respond to your query." {/* The hint text */} |
| 136 | + dark = { true } {/* The dark variation of the component */} |
| 137 | + alt={ false } {/* The alt variation of the component */} |
| 138 | +/> |
| 139 | + |
| 140 | +<AUerrorText |
| 141 | + text="Enter an email in the valid format." {/* The error text */} |
| 142 | + dark={ true } {/* The dark variation of the component */} |
| 143 | + inline={ true } {/* Display the error text inline*/} |
| 144 | +/> |
| 145 | + |
| 146 | +<AUformGroup |
| 147 | + status="invalid" {/* Adds invalid state to form group */} |
| 148 | + dark = { true } {/* The dark variation of the component */} |
| 149 | +/> |
| 150 | + |
| 151 | +<AUfieldset |
| 152 | + dark = { true } {/* The dark variation of the component */} |
| 153 | +/> |
| 154 | +``` |
0 commit comments