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
82 changes: 82 additions & 0 deletions css/src/components/persona.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
$persona-font-size-xs: $font-size-9 !default;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
$persona-font-size-sm: $font-size-8 !default;
$persona-font-size-md: $font-size-7 !default;
$persona-font-size-lg: $font-size-6 !default;
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
$persona-font-size-xl: $font-size-5 !default;

$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;

.persona-avatar {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
align-items: center;
justify-content: center;
width: 2.35em;
height: 2.35em;
border-radius: $persona-avatar-border-radius;
background-color: $persona-avatar-background-color;
color: $persona-avatar-font-color;
font-size: $persona-font-size-md;
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 .persona-avatar {
wibjorn marked this conversation as resolved.
Show resolved Hide resolved
font-size: $persona-font-size-xs;
}

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

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

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

&.persona-xl .persona-avatar {
font-size: $persona-font-size-xl;
}
}
136 changes: 136 additions & 0 deletions site/src/components/persona.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
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 |
| ------------------------- | ---------------------- |
| `.persona.persona-<size>` | `xs`, `sm`, `lg`, `xl` |

## 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="Avatar for Jane Doe" />
</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 role="img" aria-label="Avatar for John Doe">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 role="img" aria-label="Avatar for John Doe">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="Avatar for Jane Doe" />
</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: `persona-xs`, `persona-sm`, `persona-lg`, `persona-xl`.

```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="Avatar for Jane Doe" />
</figure>
</div>
<div class="persona persona-sm">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="Avatar for Jane Doe" />
</figure>
</div>
<div class="persona">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="Avatar for Jane Doe" />
</figure>
</div>
<div class="persona persona-lg">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="Avatar for Jane Doe" />
</figure>
</div>
<div class="persona persona-xl">
<figure class="persona-avatar">
<img src="~/src/scaffold/media/avatar.png" alt="Avatar for Jane Doe" />
</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 role="img" aria-label="Avatar for WW">ww</span>
</div>
</div>
<div class="persona persona-sm">
<div class="persona-avatar">
<span role="img" aria-label="Avatar for WW">ww</span>
</div>
</div>
<div class="persona">
<div class="persona-avatar">
<span role="img" aria-label="Avatar for WW">ww</span>
</div>
</div>
<div class="persona persona-lg">
<div class="persona-avatar">
<span role="img" aria-label="Avatar for WW">ww</span>
</div>
</div>
<div class="persona persona-xl">
<div class="persona-avatar">
<span role="img" aria-label="Avatar for WW">ww</span>
</div>
</div>
</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