|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +import { useState } from "react"; |
| 5 | + |
| 6 | +import Checkbox from "@cloudscape-design/components/checkbox"; |
| 7 | +import FormField from "@cloudscape-design/components/form-field"; |
| 8 | +import Header from "@cloudscape-design/components/header"; |
| 9 | +import Input from "@cloudscape-design/components/input"; |
| 10 | +import SpaceBetween from "@cloudscape-design/components/space-between"; |
| 11 | + |
| 12 | +import { Avatar } from "../../lib/components"; |
| 13 | + |
| 14 | +export default function AvatarImageAndWidth() { |
| 15 | + const [url, setURL] = useState( |
| 16 | + "https://static1.colliderimages.com/wordpress/wp-content/uploads/2024/08/deadpool-wolverine-hugh-jackman-mask-reveal.jpg", |
| 17 | + ); |
| 18 | + const [width, setWidth] = useState("100"); |
| 19 | + const [initials, setInitials] = useState("SO"); |
| 20 | + const [iconName, setIconName] = useState("search"); |
| 21 | + const [loading, setLoading] = useState(false); |
| 22 | + const [genAI, setGenAI] = useState(false); |
| 23 | + |
| 24 | + return ( |
| 25 | + <SpaceBetween direction="vertical" size="m"> |
| 26 | + <Header>Input an Image URL and custom size.</Header> |
| 27 | + |
| 28 | + <SpaceBetween alignItems="center" direction="horizontal" size="m"> |
| 29 | + <FormField label="Width:"> |
| 30 | + <Input onChange={({ detail }) => setWidth(detail.value)} value={width} inputMode="numeric" type="number" /> |
| 31 | + </FormField> |
| 32 | + |
| 33 | + <FormField label="Image URL"> |
| 34 | + <Input onChange={({ detail }) => setURL(detail.value)} value={url} /> |
| 35 | + </FormField> |
| 36 | + |
| 37 | + <FormField label="Initials"> |
| 38 | + <Input onChange={({ detail }) => setInitials(detail.value)} value={initials} /> |
| 39 | + </FormField> |
| 40 | + |
| 41 | + <FormField label="Icon Name"> |
| 42 | + <Input onChange={({ detail }) => setIconName(detail.value)} value={iconName} /> |
| 43 | + </FormField> |
| 44 | + |
| 45 | + <Checkbox onChange={({ detail }) => setLoading(detail.checked)} checked={loading}> |
| 46 | + Loading |
| 47 | + </Checkbox> |
| 48 | + |
| 49 | + <Checkbox onChange={({ detail }) => setGenAI(detail.checked)} checked={genAI}> |
| 50 | + Gen AI |
| 51 | + </Checkbox> |
| 52 | + </SpaceBetween> |
| 53 | + |
| 54 | + <Avatar |
| 55 | + ariaLabel="Various Avatar permutations" |
| 56 | + color={genAI ? "gen-ai" : "default"} |
| 57 | + iconName={iconName} |
| 58 | + imgUrl={url} |
| 59 | + width={Number(width)} |
| 60 | + initials={initials} |
| 61 | + loading={loading} |
| 62 | + /> |
| 63 | + </SpaceBetween> |
| 64 | + ); |
| 65 | +} |
0 commit comments