Skip to content

feat(chat-container): add default Gravity mascot - #272

Merged
ananas7 merged 4 commits into
mainfrom
feat/default-gravity-mascot
Oct 13, 2026
Merged

ananas7 merged 4 commits into
mainfrom
feat/default-gravity-mascot

Conversation

@ananas7

@ananas7 ananas7 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

ChatContainer now supports showMascot to display the bundled animated Gravity mascot on the welcome screen and in chat. Custom mascotConfig SVGs and renderers retain priority and continue to work without the new prop. The mascot remains disabled by default.

Standalone SVG files are the source of truth. Their generated React components are committed, and CI runs the read-only generate:mascot:check command to detect missing, changed, or stale output. The renderer loads through a dynamic import when needed. Inline rendering preserves unique gradient/clip IDs per instance and reduced-motion support.

The four public --g-aikit-mascot-* color variables are documented in the README and demonstrated by Storybook's MascotColors controls. The existing 8rem/4rem sizes are preserved. The neutral TestMascot fixture and unrelated MessageList/EmptyContainer tests are restored; Gravity examples remain scoped to ChatContainer. Redundant SVG accessibility attributes are removed because the mascot wrapper is decorative.

Validation:

  • Lint, type checking, formatting, and CJS/ESM/server builds passed; existing lint warnings remain.
  • 31 unit suites / 324 tests passed, including filesystem integration checks for mascot generation.
  • Six affected Playwright scenarios passed through Podman without snapshot updates.
  • Generated-asset consistency and git diff --check passed.
  • Verified that all 12 SVG variants stay outside the initial dependency graph when the consumer enables code splitting.

Previews:

@gravity-ui

gravity-ui Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Prerelease version published!

Install this PR version:

npm i --save-dev @gravity-ui/aikit@2.22.2-beta.b0b1ed7909c8f4f7159871617bdc2a12356930ac.0

@gravity-ui-bot

Copy link
Copy Markdown

Preview is ready.

@gravity-ui

gravity-ui Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

@ananas7
ananas7 marked this pull request as ready for review October 12, 2026 14:26
artemzn
artemzn previously approved these changes Oct 12, 2026
artemzn
artemzn previously approved these changes Oct 12, 2026

| Variable | Default | Description |
| ---------------------------- | --------- | -------------------------------------- |
| `--zk-b1` | `#FFFF00` | Center color of the body gradient |

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.

issue: The CSS variables use the internal prefix zk: --zk-b1, --zk-b2, --zk-eye, --zk-pup. The SVG classes and keyframes use g-aikit-zk-*. These names do not follow the --g-aikit-* convention. A rename after the release is a breaking change. Please use names like --g-aikit-mascot-body-center-color, --g-aikit-mascot-body-edge-color, --g-aikit-mascot-eye-color and --g-aikit-mascot-pupil-color.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have prepared a fix using --g-aikit-mascot-body-center-color, --g-aikit-mascot-body-edge-color, --g-aikit-mascot-eye-color, and --g-aikit-mascot-pupil-color. The SVG classes/keyframes, Storybook controls, and documentation use the same namespace. The default colors are unchanged.

Comment thread package.json Outdated
"homepage": "https://github.com/gravity-ui/aikit#readme",
"scripts": {
"prepare": "husky",
"prepare": "npm run generate:mascot && husky",

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.

suggestion: The mascot generation needs six hooks: prepare, pretypecheck, prelint:js, prebuild, prestart and preplaywright. test:unit has no hook. Jest finds the generated files only because npm ci ran prepare before it. The repo already has a simpler pattern: generate:exports and generate:exports:check. Please commit the generated files and check them in CI the same way. Then the hooks and the .gitignore entry are not necessary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The fix includes the generated TSX files, removes the six generation hooks and the ignore entry, and adds generate:mascot:check to CI. The check reports missing, changed, and stale output without rewriting files. SVG files remain the source of truth; regeneration is an explicit command.


const b = block('chat-container');
const LazyGravityMascotRenderer = lazy(() =>
import('./GravityMascotRenderer.js').then(({GravityMascotRenderer}) => ({

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.

suggestion: The lazy import solves the bundle size issue, thanks. This is the only import in src with a .js extension. Storybook needs a new extensionAlias only for this import. Please use import('./GravityMascotRenderer') like the other imports, if the build allows it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I checked the extensionless import against the CJS build configuration. It fails with TS2835 because this build uses module and moduleResolution: nodenext, which preserve native dynamic imports and require an explicit file extension. The current emitted CJS and ESM files both use import("./GravityMascotRenderer.js"). I would keep the .js extension and the Storybook alias unless we also extend the build transformer to handle dynamic imports.

Comment thread src/demo/TestMascot/TestMascot.tsx Outdated
@@ -1,68 +1,33 @@
import type {CSSProperties} from 'react';

import {GravityMascot} from '../../components/pages/ChatContainer/GravityMascot';

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.

suggestion: This change is outside the scope of the PR. TestMascot was a neutral fixture. Now it renders the real GravityMascot, and the latest commit added a view prop for it. The MessageList and EmptyContainer tests now check mascot internals, for example svg.g-aikit-zk-heroIdle. The two new screenshots in MessageList.visual.spec.tsx check the footer layout, not the mascot. Please revert TestMascot, these test changes and the two screenshots.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. I have prepared a revert of the TestMascot, MessageList, and EmptyContainer fixture/test changes, including the two new MessageList screenshots. The Gravity mascot examples remain in ChatContainer, including the color controls and mobile playground.

viewBox="-10 -10 141 80"
width="141"
height="80"
role="img"

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.

nitpick: The root <svg> in all 12 files has role="img" and an English aria-label. The wrapper in GravityMascot has aria-hidden="true", so screen readers ignore these attributes. Please remove them from the SVG sources.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The local fix removes role and aria-label from all 12 SVG sources and regenerates their TSX components. The decorative aria-hidden wrapper is preserved.

@ananas7
ananas7 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 99c47d2 Oct 13, 2026
9 checks passed
@ananas7
ananas7 deleted the feat/default-gravity-mascot branch October 13, 2026 09:27
@gravity-ui gravity-ui Bot mentioned this pull request Oct 13, 2026
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.

4 participants