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

feat(avatar): migrate s2 avatar #3355

Merged
merged 2 commits into from
Nov 8, 2024
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/friendly-dolls-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/avatar": major
---

Adds support for new avatar-size tokens (avatar-size-800 to avatar-size-1500). Updates avatar component story to support new sizes. Adds support for avatar-border-color and avatar-border-thickness.
172 changes: 108 additions & 64 deletions components/avatar/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,121 +11,165 @@ governing permissions and limitations under the License.
*/

.spectrum-Avatar {
--spectrum-avatar-color-opacity: 1;
--spectrum-avatar-color-opacity: 1;

--spectrum-avatar-inline-size: var(--spectrum-avatar-size-100);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-100);
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-100);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-100);

--spectrum-avatar-border-radius: var(--spectrum-avatar-block-size);
--spectrum-avatar-border-radius: var(--spectrum-avatar-block-size);
--spectrum-avatar-border-thickness: var(--spectrum-avatar-border-width);
--spectrum-avatar-border-color-default: var(--spectrum-avatar-border-color);

--spectrum-avatar-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness);
--spectrum-avatar-focus-indicator-gap: var(--spectrum-focus-indicator-gap);
--spectrum-avatar-focus-indicator-color: var(--spectrum-focus-indicator-color);
--spectrum-avatar-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness);
--spectrum-avatar-focus-indicator-gap: var(--spectrum-focus-indicator-gap);
--spectrum-avatar-focus-indicator-color: var(--spectrum-focus-indicator-color);

--spectrum-avatar-color-opacity-disabled: var(--spectrum-avatar-opacity-disabled);
--spectrum-avatar-color-opacity-disabled: var(--spectrum-avatar-opacity-disabled);
}

.spectrum-Avatar--size50 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-50);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-50)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-50);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-50);
}

.spectrum-Avatar--size75 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-75);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-75)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-75);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-75);
}

.spectrum-Avatar--size100 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-100);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-100)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-100);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-100);
}

.spectrum-Avatar--size200 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-200);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-200)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-200);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-200);
}

.spectrum-Avatar--size300 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-300);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-300)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-300);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-300);
}

.spectrum-Avatar--size400 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-400);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-400)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-400);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-400);
}

.spectrum-Avatar--size500 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-500);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-500)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-500);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-500);
}

.spectrum-Avatar--size600 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-600);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-600)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-600);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-600);
}

.spectrum-Avatar--size700 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-700);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-700)
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-700);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-700);
}

.spectrum-Avatar--size800 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-800);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-800);
}

.spectrum-Avatar--size900 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-900);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-900);
}

.spectrum-Avatar--size1000 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1000);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1000);
}

.spectrum-Avatar--size1100 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1100);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1100);
}

.spectrum-Avatar--size1200 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1200);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1200);
}

.spectrum-Avatar--size1300 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1300);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1300);
}

.spectrum-Avatar--size1400 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1400);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1400);
}

.spectrum-Avatar--size1500 {
--spectrum-avatar-inline-size: var(--spectrum-avatar-size-1500);
--spectrum-avatar-block-size: var(--spectrum-avatar-size-1500);
}

@media (forced-colors: active) {
.spectrum-Avatar {
--highcontrast-avatar-focus-indicator-color: CanvasText;
}
.spectrum-Avatar {
--highcontrast-avatar-focus-indicator-color: CanvasText;
}
}

.spectrum-Avatar {
display: inline-block;
position: relative;
inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size));
block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size));
display: inline-block;
position: relative;
inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size));
block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size));

border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
border-width: 0;
border-style: solid;
border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
border-width: var(--spectrum-avatar-border-thickness);
border-color: var(--spectrum-avatar-border-color-default);

outline: none;
outline: none;

-webkit-user-drag: none;
user-select: none;
-webkit-user-drag: none;
user-select: none;

overflow: visible;
overflow: visible;

opacity: var(--mod-avatar-color-opacity, var(--spectrum-avatar-color-opacity));
opacity: var(--mod-avatar-color-opacity, var(--spectrum-avatar-color-opacity));

&.is-disabled {
opacity: var(--highcontrast-avatar-color-opacity-disabled, var(--mod-avatar-color-opacity-disabled, var(--spectrum-avatar-color-opacity-disabled)));
}
&.is-disabled {
opacity: var(--highcontrast-avatar-color-opacity-disabled, var(--mod-avatar-color-opacity-disabled, var(--spectrum-avatar-color-opacity-disabled)));
}
}

.spectrum-Avatar:not(.is-disabled) .spectrum-Avatar-link:focus-visible {
&::after {
pointer-events: none;
content: "";
position: absolute;
inset-block-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1);
inset-inline-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1);

inline-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2));
block-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2));

border-style: solid;
border-width: var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness));
border-color: var(--highcontrast-avatar-focus-indicator-color, var(--mod-avatar-focus-indicator-color, var(--spectrum-avatar-focus-indicator-color)));
border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
}
&::after {
pointer-events: none;
content: "";
position: absolute;
inset-block-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1);
inset-inline-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1);

inline-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2));
block-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2));

border-style: solid;
border-width: var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness));
border-color: var(--highcontrast-avatar-focus-indicator-color, var(--mod-avatar-focus-indicator-color, var(--spectrum-avatar-focus-indicator-color)));
border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
}
}

.spectrum-Avatar-link {
outline: none;
outline-color: transparent;
outline-style: solid;
outline: none;
outline-color: transparent;
outline-style: solid;
}

.spectrum-Avatar-image {
inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size));
block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size));
inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size));
block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size));

border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius));
}
2 changes: 1 addition & 1 deletion components/avatar/stories/avatar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
type: { summary: "string" },
category: "Component",
},
options: ["50", "75", "100", "200", "300", "400", "500", "600", "700"],
options: ["50", "75", "100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "1100", "1200", "1300", "1400", "1500"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

ooo! Would you please make a card to add these new sizes to the table we have on the docs page on main? I was going to ask you to add them, and then realized the docs page on this branch is totally different than what's on main! We should make sure we reference the new sizes on that page eventually, once the big merge happens.

Screenshot 2024-11-06 at 11 59 32 AM

control: "select",
},
image: {
Expand Down
Loading