Skip to content

Commit 71512e4

Browse files
nkrantzgloriliale
andauthored
docs(avatar): add icon variant (#1339)
* feat: added LivePreview for icon avatar * feat: added LivePreview for responsive sizing * chore: tab fix * chore: add to anatomy chart, fix callout and guidance Co-authored-by: Glorili Alejandro <[email protected]>
1 parent fd8cbb8 commit 71512e4

File tree

1 file changed

+57
-18
lines changed
  • packages/paste-website/src/pages/components/avatar

1 file changed

+57
-18
lines changed

packages/paste-website/src/pages/components/avatar/index.mdx

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Avatar
33
package: '@twilio-paste/avatar'
4-
description: The Avatar is a pictorial representation of a user or object 👩‍🎤. It can display the initials of that entity or an image.
4+
description: The Avatar is a pictorial representation of a user or object 👩‍🎤. It can display the initials of that entity, an image or a Paste Icon.
55
slug: /components/avatar/
66
---
77

@@ -14,6 +14,7 @@ import {Avatar} from '@twilio-paste/avatar';
1414
import Changelog from '@twilio-paste/avatar/CHANGELOG.md';
1515
import {Callout, CalloutTitle, CalloutText} from '../../../components/callout';
1616
import {SidebarCategoryRoutes} from '../../../constants';
17+
import {UserIcon} from '@twilio-paste/icons/esm/UserIcon';
1718

1819
export const pageQuery = graphql`
1920
{
@@ -61,10 +62,10 @@ export const pageQuery = graphql`
6162
<CalloutTitle>Using alpha components in your product</CalloutTitle>
6263
<CalloutText>
6364
Alpha components are ready for you to use in production. Components such as Avatar are likely to not see any API
64-
changes. This is only an alpha due to the lack of documentation and a matching Sketch symbol. Feel free to share
65+
changes. This is only an alpha due to the lack of documentation and a matching Figma component. Feel free to share
6566
your experience using this component by{' '}
6667
<Anchor href="https://github.com/twilio-labs/paste/discussions/new">starting a discussion on GitHub</Anchor>. We are
67-
also looking for a contributor to symbolize this component in Sketch. Interested? Reach out!
68+
also looking for a contributor to symbolize this component in Figma. Interested? Reach out!
6869
</CalloutText>
6970
</Callout>
7071

@@ -74,7 +75,7 @@ export const pageQuery = graphql`
7475

7576
<p>
7677
{props.pageContext.frontmatter.description} The Avatar can be sized in the same way as the{' '}
77-
<a href="/icons">Paste Icon</a>.
78+
<a href="/icons/usage-guidelines/#resizing-icons">Paste Icon</a>.
7879
</p>
7980

8081
## Examples
@@ -112,7 +113,7 @@ Provide the Avatar with a `name` and the component will render the initials as t
112113

113114
### Representing an entity via an image
114115

115-
Provide the Avatar with a source path via the `src` prop to render the Avatar as an image. The `src` prop acts just like an `img` tag. You **must** still provide the name of the entity.
116+
Provide the Avatar with a source path via the `src` prop to render the Avatar as an image. The `src` prop acts just like an `img` tag. You **must** still provide a `name` prop.
116117

117118
<LivePreview
118119
scope={{
@@ -133,6 +134,30 @@ Provide the Avatar with a source path via the `src` prop to render the Avatar as
133134
</Stack>`}
134135
</LivePreview>
135136

137+
### Representing an entity via an icon
138+
139+
Provide the Avatar with an `icon` prop to display an icon. You must import the icon before passing it to the `icon` prop. You **must** still provide a `name` prop. The icon must be a <a href="https://paste.twilio.design/icons/">Paste Icon</a>.
140+
141+
<LivePreview
142+
scope={{
143+
Avatar,
144+
Stack,
145+
UserIcon,
146+
}}
147+
>
148+
{`<Stack orientation="horizontal" spacing="space40">
149+
<Avatar size="sizeIcon30" name="avatar example" icon={UserIcon} />
150+
<Avatar size="sizeIcon40" name="avatar example" icon={UserIcon} />
151+
<Avatar size="sizeIcon50" name="avatar example" icon={UserIcon} />
152+
<Avatar size="sizeIcon60" name="avatar example" icon={UserIcon} />
153+
<Avatar size="sizeIcon70" name="avatar example" icon={UserIcon} />
154+
<Avatar size="sizeIcon80" name="avatar example" icon={UserIcon} />
155+
<Avatar size="sizeIcon90" name="avatar example" icon={UserIcon} />
156+
<Avatar size="sizeIcon100" name="avatar example" icon={UserIcon} />
157+
<Avatar size="sizeIcon110" name="avatar example" icon={UserIcon} />
158+
</Stack>`}
159+
</LivePreview>
160+
136161
### Responsive sizing
137162

138163
The Avatar `size` can be set as a responsive array of sizes.
@@ -141,6 +166,7 @@ The Avatar `size` can be set as a responsive array of sizes.
141166
scope={{
142167
Avatar,
143168
Stack,
169+
UserIcon,
144170
}}
145171
>
146172
{`<Stack orientation="horizontal" spacing="space40">
@@ -153,6 +179,11 @@ The Avatar `size` can be set as a responsive array of sizes.
153179
name="avatar example"
154180
src="/images/avatars/avatar4.png"
155181
/>
182+
<Avatar
183+
size={["sizeIcon20", "sizeIcon70", "sizeIcon110"]}
184+
name="avatar example"
185+
icon={UserIcon}
186+
/>
156187
</Stack>`}
157188
</LivePreview>
158189

@@ -164,19 +195,21 @@ The Avatar `size` can be set as a responsive array of sizes.
164195
| background-color | color-background-user | No |
165196
| font-weight | font-weight-bold | No |
166197

167-
| Size | Font Size | Line Height |
168-
| ------------- | ------------ | --------------- |
169-
| size-icon-10 | font-size-10 | line-height-10 |
170-
| size-icon-20 | font-size-10 | line-height-20 |
171-
| size-icon-30 | font-size-10 | line-height-30 |
172-
| size-icon-40 | font-size-10 | line-height-40 |
173-
| size-icon-50 | font-size-10 | line-height-50 |
174-
| size-icon-60 | font-size-10 | line-height-60 |
175-
| size-icon-70 | font-size-20 | line-height-70 |
176-
| size-icon-80 | font-size-30 | line-height-80 |
177-
| size-icon-90 | font-size-40 | line-height-90 |
178-
| size-icon-100 | font-size-60 | line-height-100 |
179-
| size-icon-110 | font-size-70 | line-height-110 |
198+
#### Size Token Mapping
199+
200+
| Size | Font Size | Line Height | Icon Size |
201+
| ------------- | ------------ | --------------- | ------------ |
202+
| size-icon-10 | font-size-10 | line-height-10 | size-icon-10 |
203+
| size-icon-20 | font-size-10 | line-height-20 | size-icon-10 |
204+
| size-icon-30 | font-size-10 | line-height-30 | size-icon-10 |
205+
| size-icon-40 | font-size-10 | line-height-40 | size-icon-10 |
206+
| size-icon-50 | font-size-10 | line-height-50 | size-icon-20 |
207+
| size-icon-60 | font-size-10 | line-height-60 | size-icon-20 |
208+
| size-icon-70 | font-size-20 | line-height-70 | size-icon-30 |
209+
| size-icon-80 | font-size-30 | line-height-80 | size-icon-40 |
210+
| size-icon-90 | font-size-40 | line-height-90 | size-icon-50 |
211+
| size-icon-100 | font-size-60 | line-height-100 | size-icon-70 |
212+
| size-icon-110 | font-size-70 | line-height-110 | size-icon-80 |
180213

181214
---
182215

@@ -200,6 +233,8 @@ const AvatarExample = () => {
200233
};
201234
```
202235

236+
**Note:** The Avatar component will display the `icon` if both the `icon` and `src` props are passed.
237+
203238
#### Props
204239

205240
##### `name` string
@@ -214,6 +249,10 @@ Responsive size property that takes IconSize token names.
214249

215250
Used to set the image `src` attribute when setting an image as the Avatar.
216251

252+
##### `icon` Paste Icon
253+
254+
Specify a Paste Icon to be displayed in the Avatar.
255+
217256
<ChangelogRevealer>
218257
<Changelog />
219258
</ChangelogRevealer>

0 commit comments

Comments
 (0)