Skip to content

Ai avatar#1959

Merged
HerrTopi merged 2 commits into
masterfrom
ai-avatar
May 15, 2025
Merged

Ai avatar#1959
HerrTopi merged 2 commits into
masterfrom
ai-avatar

Conversation

@HerrTopi

@HerrTopi HerrTopi commented May 5, 2025

Copy link
Copy Markdown
Contributor

TEST_PLAN:
Check out the ticket and its design. Also check out the new avatar docs.

INSTUI-4538

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an "ai avatar" variant by adding new theme tokens, color primitives, and component styling changes that enable special styling and behavior for AI-generated avatars.

  • Adds new high contrast and canvas colors to support the AI variant.
  • Updates the Avatar component to use a new 'ai' variant with a fallback icon and gradient background.
  • Enhances theme types and documentation to reflect the new variant.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/ui-themes/src/themes/canvasHighContrast/colors.ts Added violet and sea color contrasts for the canvasHighContrast theme.
packages/ui-themes/src/themes/canvas/colors.ts Added violet and sea color contrasts for the canvas theme.
packages/ui-themes/src/sharedThemeTokens/colors/primitives.ts Introduced new sea and violet primitives.
packages/ui-avatar/src/Avatar/theme.ts Extended the theme with AI-specific gradient colors.
packages/ui-avatar/src/Avatar/styles.ts Updated styling logic with a new scaling function and variant styles for the 'ai' variant.
packages/ui-avatar/src/Avatar/props.ts Added the variant prop to control avatar behavior.
packages/ui-avatar/src/Avatar/index.tsx Implemented conditional rendering for the 'ai' variant with a fallback icon.
packages/ui-avatar/src/Avatar/README.md Added documentation for the new variant (note a typo in the variant title).
packages/shared-types/src/ComponentThemeVariables.ts Updated type definitions to use string for several color-related properties.
packages/shared-types/src/Colors.ts Updated contrast types to include the new color variants.
Comments suppressed due to low confidence (2)

packages/ui-avatar/src/Avatar/index.tsx:128

  • Add tests for the 'ai' avatar variant to ensure that the fallback IconAiSolid is rendered correctly when no renderIcon is provided.
const calcedRenderIcon = variant === 'ai' ? <IconAiSolid /> : renderIcon

packages/ui-avatar/src/Avatar/styles.ts:66

  • Ensure that the new calcNewScaler function is adequately tested across different avatar sizes and shapes to verify that the scaling is calculated correctly.
const calcNewScaler = (originalFontSize: number, newFontSize: number, originalScaler: number) => {

Comment thread packages/ui-avatar/src/Avatar/README.md Outdated
@HerrTopi HerrTopi self-assigned this May 5, 2025
@github-actions

github-actions Bot commented May 5, 2025

Copy link
Copy Markdown
PR Preview Action v1.6.1
Preview removed because the pull request was closed.
2025-05-15 10:47 UTC

Comment thread packages/ui-avatar/src/Avatar/styles.ts
Comment thread packages/ui-avatar/src/Avatar/README.md Outdated

Avatar has a variant prop, which currently only toggles it between `ai` and `default` behavior. `ai` is a preset where you can only change the `size` and `margin` visual props, all others are preset. In the following example, there are the `ai` variants.

### ai

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd capitalize this title to AI

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and also change the order. so default is first, but this is not that important

Comment thread packages/ui-avatar/src/Avatar/README.md Outdated
---
<div>
<View display="block" padding="small medium">
<Avatar variant="ai" size="xx-small" margin="0 small 0 0" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use the new spacing tokens, small is deprecated and will be removed

@matyasf matyasf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This code does not render the AI icon:

<Avatar variant="ai" size="xx-large" src={avatarSquare}/>

This code renders it in a weird shape:

<Avatar variant="ai" size="xx-large" shape/>

it would be nice to fix these if its not hard

@balzss balzss self-requested a review May 14, 2025 17:32
@HerrTopi HerrTopi requested a review from joyenjoyer May 15, 2025 09:19
@HerrTopi HerrTopi requested review from joyenjoyer and matyasf and removed request for matyasf May 15, 2025 10:46
@HerrTopi HerrTopi merged commit 52545d1 into master May 15, 2025
8 checks passed
@HerrTopi HerrTopi deleted the ai-avatar branch May 15, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants