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
10 changes: 10 additions & 0 deletions .changeset/moody-banks-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@stackoverflow/stacks": patch
"@stackoverflow/stacks-svelte": patch
---

**Avatar Updates:**

- **Stacks Classic**: Made avatar border squared. Introduced `.s-avatar--indicator` class for positioning an activity indicator element in relation to the avatar.

- **Stacks Svelte**: Introduced a new `status` prop. When set to `online` it will show an activity indicator on the avatar.
15 changes: 15 additions & 0 deletions packages/stacks-classic/lib/components/avatar/avatar.a11y.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ const getChild = (child?: string): string => {
aria-hidden="true">
S
</div>${srEl}`;
case "indicator":
return `<img
class="s-avatar--image"
src="https://picsum.photos/id/1/48"
alt="team logo"
/>${srEl}
<div
class="s-avatar--indicator s-activity-indicator s-activity-indicator__sm s-activity-indicator__success"
>
<div class="v-visible-sr">Online</div>
</div>`;
default:
return srEl;
}
Expand All @@ -29,7 +40,11 @@ describe("avatar", () => {
default: getChild(),
image: getChild("image"),
letter: getChild("letter"),
indicator: getChild("indicator"),
},
excludedTestids: [
/^s-avatar-(?=.*(32|48|64|96|128)).*-indicator.*$/, // s-avatar with indicator and 32 48 64 96 128 sizes not supported
],
tag: "span",
});
});
20 changes: 9 additions & 11 deletions packages/stacks-classic/lib/components/avatar/avatar.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.s-avatar {
--_av-size: var(--su-static16);
--_av-bg: var(--_white-static); // Force a white background color for when we have transparent avatars
--_av-br: var(--br-sm);
--_av-fs-letter: calc(var(--su-static12) - var(--su-static1));
--_av-scale-badge: 1;

Expand All @@ -18,14 +17,8 @@

// MODIFIERS
// Sizes
&&__32,
&&__48 {
--_av-br: var(--br-md);
}

&&__96,
&&__128 {
--_av-br: calc(var(--br-lg) + var(--br-sm));
--_av-scale-badge: 3;
}

Expand All @@ -49,7 +42,6 @@

&&__64 {
--_av-size: var(--su-static64);
--_av-br: var(--br-lg);
--_av-fs-letter: calc(var(--su-static48) - var(--su-static4));
--_av-scale-badge: 2.4;
}
Expand All @@ -74,7 +66,6 @@
}

& &--image {
border-radius: var(--_av-br);
display: block;
height: var(--_av-size);
width: var(--_av-size);
Expand All @@ -95,8 +86,15 @@
user-select: none;
}

background-color: var(--_av-bg);
border-radius: var(--_av-br);
& &--indicator {
box-shadow: 0 0 0 var(--su-static2) var(--white);
bottom: 100%;
left: 100%;
position: absolute;
transform: translate(-50%, 60%);
}

background-color: var(--_av-bg);
height: var(--_av-size);
width: var(--_av-size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ const getChild = (child?: string): string => {
aria-hidden="true">
S
</div>${srEl}`;
case "indicator":
return `<img
class="s-avatar--image"
src="${base64Image}"
alt="team logo"
/>${srEl}
<div
class="s-avatar--indicator s-activity-indicator s-activity-indicator__sm s-activity-indicator__success"
>
<div class="v-visible-sr">Online</div>
</div>`;
default:
return srEl;
}
Expand All @@ -33,11 +44,15 @@ describe("avatar", () => {
default: getChild(),
image: getChild("image"),
letter: getChild("letter"),
indicator: getChild("indicator"),
},
attributes: {
href: "#",
},
tag: "a",
excludedTestids: [
/^s-avatar-(?=.*(32|48|64|96|128)).*-indicator.*$/, // s-avatar with indicator and 32 48 64 96 128 sizes not supported
],
template: ({ component, testid }) => html`
<div
data-testid="${testid}"
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading