Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-wasps-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add small size modifier and design token to Avatar
6 changes: 5 additions & 1 deletion src/components/avatar/avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
}

/**
* Full-width modifier
* Size modifiers
*/

.c-avatar--small {
width: size.$square-avatar-small;
}

.c-avatar--full {
width: size.$square-avatar-full;
}
30 changes: 28 additions & 2 deletions src/components/avatar/avatar.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,35 @@ The size is fixed to the value of [our `sizes.$avatar-medium` token by default](
</Story>
</Canvas>

## Small

The `c-avatar--small` modifier sizes the avatar down to the value of our `sizes.$avatar-small` token. This may be useful when accompanying a single line of text or showing many avatars in a condensed space.

<Canvas>
<Story
name="Small (Empty)"
args={{
size: 'small',
}}
>
{avatarStory.bind({})}
</Story>
<Story
name="Small (With Image)"
args={{
size: 'small',
src: demoImageSmall,
srcset: demoImageSrcset,
sizes: '38px',
}}
>
{avatarStory.bind({})}
</Story>
</Canvas>

## Full Width

The `c-avatar--full` modifier sizes the component to `100%` of its container.
The `c-avatar--full` modifier sizes the component to `100%` of its container width.

<Canvas>
<Story
Expand All @@ -76,7 +102,7 @@ The `c-avatar--full` modifier sizes the component to `100%` of its container.
- `src`: Value for the inner `img` element's `src` attribute. If omitted, no `img` will be output.
- `srcset`: Value for the inner `img` element's `srcset` attribute.

## See Also
## See also…

To display multiple avatars in a visual cluster, see [the Bunch object](/docs/objects-bunch--of-avatars).

Expand Down
1 change: 1 addition & 0 deletions src/tokens/size/sizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = {
},
square: {
avatar: {
small: { value: modularEm(3) },
medium: { value: modularEm(5) },
full: { value: '100%' },
},
Expand Down