Skip to content

Commit 9d9c418

Browse files
committed
Update interface and add test page.
1 parent d8a3aaf commit 9d9c418

File tree

3 files changed

+66
-31
lines changed

3 files changed

+66
-31
lines changed

pages/avatar/custom-width.page.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}

pages/avatar/width-and-image.page.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/avatar/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface AvatarProps {
7070
* Defines the width of the avatar.
7171
* This value corresponds to the `width` CSS-property and will center and crop images using `object-fit: cover`.
7272
* If no width is provided the avatar will use the default width value of 28px.
73+
* The height of the avatar will be set to the same value as the width.
7374
*/
7475
width?: number;
7576
}

0 commit comments

Comments
 (0)