Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persona component #571

Merged
merged 15 commits into from
Sep 26, 2023
5 changes: 5 additions & 0 deletions .changeset/cold-radios-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@microsoft/atlas-css': minor
---

Adding persona component.
5 changes: 5 additions & 0 deletions .changeset/eleven-seals-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@microsoft/atlas-site': minor
---

Adding documentation page for persona component.
1 change: 1 addition & 0 deletions css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import './notification.scss';
@import './icon.scss';
@import './image.scss';
@import './persona.scss';
@import './popover.scss';
@import './pagination.scss';
@import './table.scss';
Expand Down
203 changes: 203 additions & 0 deletions css/src/components/persona.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
$persona-avatar-xs: 28px !default;
$persona-avatar-sm: 32px !default;
$persona-avatar-md: 36px !default;
$persona-avatar-lg: 42px !default;
$persona-avatar-xl: 48px !default;

$persona-avatar-font-size: 0.45em;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
$persona-avatar-background-color: $alternate-background-medium !default;
$persona-avatar-font-color: $text-invert !default;
$persona-avatar-border-radius: $border-radius-rounded;

$persona-name-font-size: $font-size-7 !default;
$persona-name-font-color: $text !default;

$persona-metadata-font-size: $font-size-9 !default;
$persona-metadata-font-color: $text-subtle !default;

$persona-gap-size: $layout-1 !default;

.persona {
display: flex;
position: relative;
gap: $persona-gap-size;
font-size: $persona-avatar-md;

.persona-avatar {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
align-items: center;
justify-content: center;
width: $persona-avatar-md;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
height: $persona-avatar-md;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
border-radius: $persona-avatar-border-radius;
background-color: $persona-avatar-background-color;
color: $persona-avatar-font-color;
font-size: $persona-avatar-font-size;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
line-height: 1;
text-transform: uppercase;

img,
svg {
display: block;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
height: auto;
max-height: 100%;
border-radius: $persona-avatar-border-radius;
}
}

.persona-details {
align-self: center;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
color: $persona-metadata-font-color;
font-size: $persona-metadata-font-size;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved

.persona-name {
font-size: $persona-name-font-size;

&:not(a) {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
color: $persona-name-font-color;
}
}
}

// Sizes

&.persona-xs {
font-size: $persona-avatar-xs;

.persona-avatar {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
width: $persona-avatar-xs;
height: $persona-avatar-xs;
}
}

&.persona-sm {
font-size: $persona-avatar-sm;

.persona-avatar {
width: $persona-avatar-sm;
height: $persona-avatar-sm;
}
}

&.persona-md {
font-size: $persona-avatar-md;

.persona-avatar {
width: $persona-avatar-md;
height: $persona-avatar-md;
}
}

&.persona-lg {
font-size: $persona-avatar-lg;

.persona-avatar {
width: $persona-avatar-lg;
height: $persona-avatar-lg;
}
}

&.persona-xl {
font-size: $persona-avatar-xl;

.persona-avatar {
width: $persona-avatar-xl;
height: $persona-avatar-xl;
}
}

@include tablet {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
&.persona-xs-tablet {
font-size: $persona-avatar-xs;

.persona-avatar {
width: $persona-avatar-xs;
height: $persona-avatar-xs;
}
}

&.persona-sm-tablet {
font-size: $persona-avatar-sm;

.persona-avatar {
width: $persona-avatar-sm;
height: $persona-avatar-sm;
}
}

&.persona-md-tablet {
font-size: $persona-avatar-md;

.persona-avatar {
width: $persona-avatar-md;
height: $persona-avatar-md;
}
}

&.persona-lg-tablet {
font-size: $persona-avatar-lg;

.persona-avatar {
width: $persona-avatar-lg;
height: $persona-avatar-lg;
}
}

&.persona-xl-tablet {
font-size: $persona-avatar-xl;

.persona-avatar {
width: $persona-avatar-xl;
height: $persona-avatar-xl;
}
}
}

@include desktop {
&.persona-xs-desktop {
font-size: $persona-avatar-xs;

.persona-avatar {
width: $persona-avatar-xs;
height: $persona-avatar-xs;
}
}

&.persona-sm-desktop {
font-size: $persona-avatar-sm;

.persona-avatar {
width: $persona-avatar-sm;
height: $persona-avatar-sm;
}
}

&.persona-md-desktop {
font-size: $persona-avatar-md;

.persona-avatar {
width: $persona-avatar-md;
height: $persona-avatar-md;
}
}

&.persona-lg-desktop {
font-size: $persona-avatar-lg;

.persona-avatar {
width: $persona-avatar-lg;
height: $persona-avatar-lg;
}
}

&.persona-xl-desktop {
font-size: $persona-avatar-xl;

.persona-avatar {
width: $persona-avatar-xl;
height: $persona-avatar-xl;
}
}
}
}
156 changes: 156 additions & 0 deletions site/src/components/persona.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
title: Persona
description: Persona component in the Atlas Design System
template: standard
figmaEmbed: https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FuVA2amRR71yJZ0GS6RI6zL%2F%25F0%259F%258C%259E-Atlas-Design-Library%3Ftype%3Ddesign%26node-id%3D1284%253A2163%26mode%3Ddesign%26t%3DklysUJ7ALWgcF1SQ-1 allowfullscreen
classType: Component
classPrefixes:
- persona
---

# Persona

Persona component comes in handy for user's representation. It consists of two parts - user's avatar and details. Details has their name and optional metadata.
ollips marked this conversation as resolved.
Show resolved Hide resolved

| Class pattern | Sizes | screensize |
| ------------------------- | ---------------------------------- | ------------------- |
| `.persona.persona-<size>` | `xs` `sm` `md (default)` `lg` `xl` | `tablet`, `desktop` |
wibjorn marked this conversation as resolved.
Show resolved Hide resolved

## Usage

Below are examples of the most common persona component use-cases - one with an image avatar and another with user's initials.

```html
<div class="persona">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
<div class="persona-details">
<p class="persona-name">Jane Doe</p>
<p>Software Engineer</p>
</div>
</div>

<div class="persona margin-top-md">
<div class="persona-avatar">
<span>JD</span>
</div>
<div class="persona-details">
<p class="persona-name">John Doe</p>
<p>Software Engineer</p>
</div>
</div>
```

Persona's details may contain a link to user's profile, and with help of the [`.stretched-link` component](../components/stretched-link.md) the whole area persona takes becomes clickable:

```html
<div class="persona position-relative">
<div class="persona-avatar">
<span>JD</span>
</div>
<div class="persona-details">
<a class="persona-name justify-self-stretch stretched-link" href="#">John Doe</a>
<p>Software Engineer</p>
</div>
</div>
```

Persona might have both avatar and details parts presented at the same time or just one of them.
wibjorn marked this conversation as resolved.
Show resolved Hide resolved

```html
<div class="persona">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>

<div class="persona margin-top-md">
<div class="persona-details">
<p class="persona-name">John Doe</p>
<p>Software Engineer</p>
</div>
</div>
```

### Sizes

The following classes are available for resizing avatar:

| Class | Avatar's size in px |
| ------------ | ------------------- |
| `persona-xs` | 28px |
| `persona-sm` | 32px |
| `persona-md` | 36px |
| `persona-lg` | 42px |
| `persona-xl` | 48px |

```html
<div class="display-flex flex-wrap-wrap gap-xxs">
<div class="persona persona-xs">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
<div class="persona persona-sm">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
<div class="persona persona-md">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
<div class="persona persona-lg">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
<div class="persona persona-xl">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
</div>

<div class="display-flex flex-wrap-wrap gap-xxs margin-top-md">
<div class="persona persona-xs">
<div class="persona-avatar">
<span>ww</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to support styled-text avatars, we should ensure we demo accessible markup for these:

Could you please add role=img and an aria-label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

</div>
</div>
<div class="persona persona-sm">
<div class="persona-avatar">
<span>ww</span>
</div>
</div>
<div class="persona persona-md">
<div class="persona-avatar">
<span>ww</span>
</div>
</div>
<div class="persona persona-lg">
<div class="persona-avatar">
<span>ww</span>
</div>
</div>
<div class="persona persona-xl">
<div class="persona-avatar">
<span>ww</span>
</div>
</div>
</div>
```

### Responsive sizes

Tablet and desktop versions of all classes are also available. Resize your browser window to see the differences in sizes.

```html
<div class="persona persona-xs persona-md-tablet persona-xl-desktop">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="username" />
</figure>
</div>
```
Binary file added site/src/scaffold/media/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading