|
| 1 | +import { GoabCheckbox, GoabFormItem } from "@abgov/react-components"; |
| 2 | +import { Sandbox } from "@components/sandbox"; |
| 3 | +import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx"; |
| 4 | +import { useContext } from "react"; |
| 5 | +import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; |
| 6 | + |
| 7 | +export default function CheckboxDescriptionExample () { |
| 8 | + const {version} = useContext(LanguageVersionContext); |
| 9 | + return ( |
| 10 | + <> |
| 11 | + <Sandbox fullWidth skipRender> |
| 12 | + {/*Angular*/} |
| 13 | + |
| 14 | + {version === "old" && <CodeSnippet |
| 15 | + lang="typescript" |
| 16 | + tags="angular" |
| 17 | + allowCopy={true} |
| 18 | + code={` |
| 19 | + <goa-form-item label="How would you like to be contacted?"> |
| 20 | + <goa-checkbox checked="true" name="optionOne" text="Email"> |
| 21 | + <span slot="description">Help text with a <a href="#">link</a>.</span> |
| 22 | + </goa-checkbox> |
| 23 | + <goa-checkbox checked="false" name="optionTwo" text="Phone" /> |
| 24 | + <goa-checkbox checked="false" name="optionThree" text="Text message" /> |
| 25 | + </goa-form-item> |
| 26 | + `} |
| 27 | + />} |
| 28 | + |
| 29 | + {version === "new" && <CodeSnippet |
| 30 | + lang="typescript" |
| 31 | + tags="angular" |
| 32 | + allowCopy={true} |
| 33 | + code={` |
| 34 | + <goab-form-item label="How would you like to be contacted?"> |
| 35 | + <goab-checkbox [checked]="true" name="optionOne" text="Email" [description]="descriptionTemplate"> |
| 36 | + <ng-template #descriptionTemplate> |
| 37 | + <span>Help text with a <a href="#">link</a>.</span> |
| 38 | + </ng-template> |
| 39 | + </goab-checkbox> |
| 40 | + <goab-checkbox [checked]="false" name="optionTwo" text="Phone" /> |
| 41 | + <goab-checkbox [checked]="false" name="optionThree" text="Text message" /> |
| 42 | + </goab-form-item> |
| 43 | + `} |
| 44 | + />} |
| 45 | + |
| 46 | + {/*React*/} |
| 47 | + {version === "old" && <CodeSnippet |
| 48 | + lang="typescript" |
| 49 | + tags="react" |
| 50 | + allowCopy={true} |
| 51 | + code={` |
| 52 | + <GoAFormItem label="How would you like to be contacted?"> |
| 53 | + <GoACheckbox |
| 54 | + checked={true} |
| 55 | + name="optionOne" |
| 56 | + text="Email" |
| 57 | + description={<span>Help text with a <a href="#">link</a>.</span>} |
| 58 | + /> |
| 59 | + <GoACheckbox checked={false} name="optionTwo" text="Phone" /> |
| 60 | + <GoACheckbox checked={false} name="optionThree" text="Text message" /> |
| 61 | + </GoAFormItem> |
| 62 | + `} |
| 63 | + />} |
| 64 | + |
| 65 | + {version === "new" && <CodeSnippet |
| 66 | + lang="typescript" |
| 67 | + tags="react" |
| 68 | + allowCopy={true} |
| 69 | + code={` |
| 70 | + <GoabFormItem label="How would you like to be contacted?"> |
| 71 | + <GoabCheckbox |
| 72 | + checked={true} |
| 73 | + name="optionOne" |
| 74 | + text="Email" |
| 75 | + description={<span>Help text with a <a href="#">link</a>.</span>} |
| 76 | + /> |
| 77 | + <GoabCheckbox checked={false} name="optionTwo" text="Phone" /> |
| 78 | + <GoabCheckbox checked={false} name="optionThree" text="Text message" /> |
| 79 | + </GoabFormItem> |
| 80 | + `} |
| 81 | + />} |
| 82 | + |
| 83 | + <GoabFormItem label="How would you like to be contacted?"> |
| 84 | + <GoabCheckbox |
| 85 | + checked={true} |
| 86 | + name="optionOne" |
| 87 | + text="Email" |
| 88 | + description={<span>Help text with a <a href="#">link</a>.</span>} |
| 89 | + /> |
| 90 | + <GoabCheckbox checked={false} name="optionTwo" text="Phone" /> |
| 91 | + <GoabCheckbox checked={false} name="optionThree" text="Text message" /> |
| 92 | + </GoabFormItem> |
| 93 | + </Sandbox> |
| 94 | + </> |
| 95 | + ); |
| 96 | +} |
0 commit comments