@gravity-ui/aikit 2.23.0 → 2.23.1-beta.2a8d4fab43196b53447acf9714ce4618c72c29ff.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/components/atoms/MessageBalloon/MessageBalloon.css +5 -1
- package/build/cjs/package.json +1 -1
- package/build/cjs/themes/dark.css +1 -0
- package/build/cjs/themes/light.css +1 -0
- package/build/docs/INDEX.md +2 -1
- package/build/docs/components/atoms/MessageBalloon.md +7 -5
- package/build/docs/guides/README.md +1 -0
- package/build/docs/guides/THEMER.md +63 -0
- package/build/docs/guides/THEMING.md +3 -1
- package/build/esm/components/atoms/MessageBalloon/MessageBalloon.css +5 -1
- package/build/esm/package.json +1 -1
- package/build/esm/themes/dark.css +1 -0
- package/build/esm/themes/light.css +1 -0
- package/docs/README.md +1 -0
- package/docs/THEMER.md +63 -0
- package/docs/THEMING.md +3 -1
- package/llms-full.txt +70 -1
- package/llms.txt +1 -0
- package/package.json +10 -5
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
.g-aikit-message-balloon {
|
|
2
2
|
display: inline-block;
|
|
3
|
-
background-color: var(--g-color-base-info-light);
|
|
3
|
+
background-color: var(--g-aikit-message-balloon-background, var(--g-color-base-info-light));
|
|
4
|
+
color: var(--g-aikit-message-balloon-color, inherit);
|
|
4
5
|
padding: var(--g-spacing-2) var(--g-spacing-3);
|
|
5
6
|
border-radius: var(--g-spacing-3) 0 var(--g-spacing-3) var(--g-spacing-3);
|
|
6
7
|
max-width: 100%;
|
|
8
|
+
}
|
|
9
|
+
.g-aikit-message-balloon .g-aikit-markdown-renderer {
|
|
10
|
+
color: var(--g-aikit-message-balloon-color, var(--g-color-text-primary));
|
|
7
11
|
}
|
package/build/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.23.0","type":"commonjs","sideEffects":["*.css","*.scss"]}
|
|
1
|
+
{"version":"2.23.1-beta.2a8d4fab43196b53447acf9714ce4618c72c29ff.0","type":"commonjs","sideEffects":["*.css","*.scss"]}
|
package/build/docs/INDEX.md
CHANGED
|
@@ -71,6 +71,7 @@ function App() {
|
|
|
71
71
|
- [Adding a New Component](./guides/guidelines/new-component.md) — A checklist for everything that must be wired up when creating a new component inside src/components/<level>/<Name>/. Missing any of these makes the component invisible to consumers, breaks tree-shaking, or fails CI.
|
|
72
72
|
- [AIKit Library Architecture](./guides/ARCHITECTURE.md)
|
|
73
73
|
- [AIKit Project Structure](./guides/PROJECT_STRUCTURE.md) — This document describes the layout of the @gravity-ui/aikit source tree.
|
|
74
|
+
- [AIKit Themer](./guides/THEMER.md) — Open Theming → Themer → Playground in AIKit Storybook to edit a theme alongside a live AIKit chat. The editor uses the same @gravity-ui/uikit-themer generator as Gravity Themer and UIKit's current Storybook theme importer, with UIKit controls and chroma-js color validation.
|
|
74
75
|
- [Code Style and Language Requirements](./guides/guidelines/code-style.md) — CRITICAL: All code documentation, comments, and JSDoc must be written in English.
|
|
75
76
|
- [Components](./guides/COMPONENTS.md) — 49 components organized by Atomic Design level. Each component lives in src/components/<level>/<Name>/ and ships with its own README and Storybook stories.
|
|
76
77
|
- [Documentation](./guides/README.md) — This directory contains all @gravity-ui/aikit documentation.
|
|
@@ -84,7 +85,7 @@ function App() {
|
|
|
84
85
|
- [Storybook Files Creation](./guides/guidelines/storybook.md) — All components should have Storybook stories for documentation and testing purposes. Stories are located in the __stories__ directory within each component folder.
|
|
85
86
|
- [Testing Guide](./guides/TESTING.md) — This project uses Playwright Component Testing for visual regression testing and component validation.
|
|
86
87
|
- [Testing Guidelines](./guides/guidelines/testing.md) — Tests should be created based on Storybook stories to ensure consistency between documentation and functionality. We use Playwright Component Testing for visual regression testing and interaction testing.
|
|
87
|
-
- [Theming](./guides/THEMING.md) —
|
|
88
|
+
- [Theming](./guides/THEMING.md) — Use the AIKit Themer in Storybook to edit shared Gravity tokens and AIKit settings with a live chat preview, then export CSS or JSON.
|
|
88
89
|
- [Troubleshooting](./guides/TROUBLESHOOTING.md) — Common issues when integrating @gravity-ui/aikit.
|
|
89
90
|
- [Using AIKit with AI Agents (Claude Code / Cursor)](./guides/AI_AGENTS.md) — When you install @gravity-ui/aikit in a downstream project, you can teach Claude Code and Cursor about it so they write correct code without you spelling out the API every time.
|
|
90
91
|
|
|
@@ -29,8 +29,10 @@ import {MessageBalloon} from '@/components/atoms/MessageBalloon';
|
|
|
29
29
|
|
|
30
30
|
The component uses CSS variables for theming:
|
|
31
31
|
|
|
32
|
-
| Variable
|
|
33
|
-
|
|
|
34
|
-
| `--g-
|
|
35
|
-
| `--g-
|
|
36
|
-
| `--g-
|
|
32
|
+
| Variable | Description |
|
|
33
|
+
| -------------------------------------- | -------------------------------------------------------------- |
|
|
34
|
+
| `--g-aikit-message-balloon-background` | Background color; defaults to `var(--g-color-base-info-light)` |
|
|
35
|
+
| `--g-aikit-message-balloon-color` | Text color; defaults to `inherit` |
|
|
36
|
+
| `--g-color-base-info-light` | Default background color of the message balloon |
|
|
37
|
+
| `--g-spacing-2` | Vertical padding |
|
|
38
|
+
| `--g-spacing-3` | Horizontal padding and border radius |
|
|
@@ -10,6 +10,7 @@ Start here if you're integrating AIKit into your application.
|
|
|
10
10
|
- [**COMPONENTS.md**](./COMPONENTS.md) — catalog of all 49 components with one-line descriptions
|
|
11
11
|
- [**HOOKS.md**](./HOOKS.md) — public hooks reference
|
|
12
12
|
- [**THEMING.md**](./THEMING.md) — CSS variables, light/dark themes
|
|
13
|
+
- [**THEMER.md**](./THEMER.md) — visual theme editor with a live chat preview and CSS/JSON import and export
|
|
13
14
|
- [**I18N.md**](./I18N.md) — per-component localization (en, ru)
|
|
14
15
|
- [**EXAMPLES.md**](./EXAMPLES.md) — streaming, file upload, custom message types, OpenAI integration
|
|
15
16
|
- [**TROUBLESHOOTING.md**](./TROUBLESHOOTING.md) — peer-deps, theming, markdown rendering FAQs
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AIKit Themer
|
|
2
|
+
|
|
3
|
+
Open **Theming → Themer → Playground** in [AIKit Storybook](https://preview.gravity-ui.com/aikit/) to edit a theme alongside a live AIKit chat. The editor uses the same `@gravity-ui/uikit-themer` generator as Gravity Themer and UIKit's current Storybook theme importer, with UIKit controls and `chroma-js` color validation.
|
|
4
|
+
|
|
5
|
+
## Run locally
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm ci
|
|
9
|
+
npm start -- --port 6006 --no-open
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Open [the editor](http://localhost:6006/?path=/story/theming-themer--playground), or choose its entry from the Storybook sidebar. The editor is a development tool and is not included in AIKit's runtime exports.
|
|
13
|
+
|
|
14
|
+
## Edit a theme
|
|
15
|
+
|
|
16
|
+
- **Colors** changes brand and semantic palettes. Palette updates regenerate private shades through the Gravity generator. Brand updates connect the palette to button, selection, focus, and link tokens, and choose a contrasting button text color. Presets replace the current theme; individual colors can be edited independently for light and dark modes.
|
|
17
|
+
- **Typography** changes interface and monospace font families and common text sizes. Fonts must be available to your application. These settings are shared between both modes. AIKit's mobile typography overrides remain independent.
|
|
18
|
+
- **Radius** changes UIKit radius tokens used by inputs and attachments. The directional message bubble retains its spacing-based corners.
|
|
19
|
+
- **AIKit** changes user message colors, chat surfaces, mascot colors and sizes, Shimmer, and padding. An empty field inherits the existing default. Color fields also accept a simple reference such as `var(--g-color-base-brand)`.
|
|
20
|
+
|
|
21
|
+
Choose the editing variant separately from the preview mode. The preview supports light, dark, or both; desktop and mobile; and welcome, conversation, streaming, and error scenarios. You can send local sample messages, start a new chat, and open history to inspect components and portal content. No model service is contacted.
|
|
22
|
+
|
|
23
|
+
Preview CSS is restricted to the preview roots, including nested portal roots, so edits do not recolor the editor. Settings are saved in local browser storage. Use **Reset** to restore Gravity defaults, or download a theme to keep it outside the browser.
|
|
24
|
+
|
|
25
|
+
## Import and export
|
|
26
|
+
|
|
27
|
+
**Import** accepts pasted or uploaded Gravity theme CSS or JSON, as well as themes exported by this editor. CSS must use the generator's `.g-root`, `.g-root_theme_light`, and `.g-root_theme_dark` rules. Unsupported selectors or variables produce an error and leave the active theme unchanged. The source is limited to 500,000 characters.
|
|
28
|
+
|
|
29
|
+
AIKit variables are preserved separately from the Gravity generator. This includes imported `--g-aikit-*` variables without a dedicated editor control. Light-only or dark-only overrides remain specific to their mode. CSS font imports are preserved; JSON exports carry them in optional `$aikit` metadata alongside the ordinary Gravity token entries.
|
|
30
|
+
|
|
31
|
+
**Export theme** displays the generated CSS or JSON and supports copying or downloading it. JSON preserves the editable token values and references. The extended JSON includes AIKit tokens that the upstream Gravity editor does not support; use this editor to retain them when importing again. For an upstream-only theme, use the shared Gravity tokens without the AIKit entries or metadata.
|
|
32
|
+
|
|
33
|
+
Load exported CSS after the default styles:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import '@gravity-ui/uikit/styles/styles.css';
|
|
37
|
+
import '@gravity-ui/aikit/styles';
|
|
38
|
+
import './aikit-theme.css';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Continue using UIKit's `ThemeProvider` to switch modes:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {ThemeProvider} from '@gravity-ui/uikit';
|
|
45
|
+
import {ChatContainer} from '@gravity-ui/aikit';
|
|
46
|
+
|
|
47
|
+
<ThemeProvider theme="dark">
|
|
48
|
+
<ChatContainer onSendMessage={handleSendMessage} />
|
|
49
|
+
</ThemeProvider>;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
AIKit's theme styles recognize UIKit's light/dark classes and retain the existing `data-theme` selectors for compatibility. A nested scoped provider can use a different mode from the surrounding application.
|
|
53
|
+
|
|
54
|
+
## Checks
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm run typecheck
|
|
58
|
+
npm run test:themer
|
|
59
|
+
npm run lint
|
|
60
|
+
npm run build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The theme exchange checks exercise the real Gravity generator and parser with independent mode overrides, palette-to-semantic references, radii, malformed imports, preview scoping, and CSS/JSON round trips. They do not render UI components.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Theming
|
|
2
2
|
|
|
3
|
+
Use the [AIKit Themer](./THEMER.md) in Storybook to edit shared Gravity tokens and AIKit settings with a live chat preview, then export CSS or JSON.
|
|
4
|
+
|
|
3
5
|
AIKit uses CSS variables for theming, in the `--g-aikit-*` namespace. Values fall back to Gravity UI's `--g-color-*` system so AIKit picks up your existing uikit theme automatically.
|
|
4
6
|
|
|
5
7
|
## CSS Setup
|
|
@@ -11,7 +13,7 @@ import '@gravity-ui/aikit/themes/common';
|
|
|
11
13
|
import '@gravity-ui/aikit/themes/light'; // or '/dark'
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which
|
|
16
|
+
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which applies `.g-root_theme_light` or `.g-root_theme_dark` to the theme root. AIKit recognizes these classes and also retains its `data-theme` selectors for compatibility:
|
|
15
17
|
|
|
16
18
|
```tsx
|
|
17
19
|
import {ThemeProvider} from '@gravity-ui/uikit';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
.g-aikit-message-balloon {
|
|
2
2
|
display: inline-block;
|
|
3
|
-
background-color: var(--g-color-base-info-light);
|
|
3
|
+
background-color: var(--g-aikit-message-balloon-background, var(--g-color-base-info-light));
|
|
4
|
+
color: var(--g-aikit-message-balloon-color, inherit);
|
|
4
5
|
padding: var(--g-spacing-2) var(--g-spacing-3);
|
|
5
6
|
border-radius: var(--g-spacing-3) 0 var(--g-spacing-3) var(--g-spacing-3);
|
|
6
7
|
max-width: 100%;
|
|
8
|
+
}
|
|
9
|
+
.g-aikit-message-balloon .g-aikit-markdown-renderer {
|
|
10
|
+
color: var(--g-aikit-message-balloon-color, var(--g-color-text-primary));
|
|
7
11
|
}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.23.0","type":"module","sideEffects":["*.css","*.scss"]}
|
|
1
|
+
{"version":"2.23.1-beta.2a8d4fab43196b53447acf9714ce4618c72c29ff.0","type":"module","sideEffects":["*.css","*.scss"]}
|
package/docs/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Start here if you're integrating AIKit into your application.
|
|
|
10
10
|
- [**COMPONENTS.md**](./COMPONENTS.md) — catalog of all 49 components with one-line descriptions
|
|
11
11
|
- [**HOOKS.md**](./HOOKS.md) — public hooks reference
|
|
12
12
|
- [**THEMING.md**](./THEMING.md) — CSS variables, light/dark themes
|
|
13
|
+
- [**THEMER.md**](./THEMER.md) — visual theme editor with a live chat preview and CSS/JSON import and export
|
|
13
14
|
- [**I18N.md**](./I18N.md) — per-component localization (en, ru)
|
|
14
15
|
- [**EXAMPLES.md**](./EXAMPLES.md) — streaming, file upload, custom message types, OpenAI integration
|
|
15
16
|
- [**TROUBLESHOOTING.md**](./TROUBLESHOOTING.md) — peer-deps, theming, markdown rendering FAQs
|
package/docs/THEMER.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AIKit Themer
|
|
2
|
+
|
|
3
|
+
Open **Theming → Themer → Playground** in [AIKit Storybook](https://preview.gravity-ui.com/aikit/) to edit a theme alongside a live AIKit chat. The editor uses the same `@gravity-ui/uikit-themer` generator as Gravity Themer and UIKit's current Storybook theme importer, with UIKit controls and `chroma-js` color validation.
|
|
4
|
+
|
|
5
|
+
## Run locally
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm ci
|
|
9
|
+
npm start -- --port 6006 --no-open
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Open [the editor](http://localhost:6006/?path=/story/theming-themer--playground), or choose its entry from the Storybook sidebar. The editor is a development tool and is not included in AIKit's runtime exports.
|
|
13
|
+
|
|
14
|
+
## Edit a theme
|
|
15
|
+
|
|
16
|
+
- **Colors** changes brand and semantic palettes. Palette updates regenerate private shades through the Gravity generator. Brand updates connect the palette to button, selection, focus, and link tokens, and choose a contrasting button text color. Presets replace the current theme; individual colors can be edited independently for light and dark modes.
|
|
17
|
+
- **Typography** changes interface and monospace font families and common text sizes. Fonts must be available to your application. These settings are shared between both modes. AIKit's mobile typography overrides remain independent.
|
|
18
|
+
- **Radius** changes UIKit radius tokens used by inputs and attachments. The directional message bubble retains its spacing-based corners.
|
|
19
|
+
- **AIKit** changes user message colors, chat surfaces, mascot colors and sizes, Shimmer, and padding. An empty field inherits the existing default. Color fields also accept a simple reference such as `var(--g-color-base-brand)`.
|
|
20
|
+
|
|
21
|
+
Choose the editing variant separately from the preview mode. The preview supports light, dark, or both; desktop and mobile; and welcome, conversation, streaming, and error scenarios. You can send local sample messages, start a new chat, and open history to inspect components and portal content. No model service is contacted.
|
|
22
|
+
|
|
23
|
+
Preview CSS is restricted to the preview roots, including nested portal roots, so edits do not recolor the editor. Settings are saved in local browser storage. Use **Reset** to restore Gravity defaults, or download a theme to keep it outside the browser.
|
|
24
|
+
|
|
25
|
+
## Import and export
|
|
26
|
+
|
|
27
|
+
**Import** accepts pasted or uploaded Gravity theme CSS or JSON, as well as themes exported by this editor. CSS must use the generator's `.g-root`, `.g-root_theme_light`, and `.g-root_theme_dark` rules. Unsupported selectors or variables produce an error and leave the active theme unchanged. The source is limited to 500,000 characters.
|
|
28
|
+
|
|
29
|
+
AIKit variables are preserved separately from the Gravity generator. This includes imported `--g-aikit-*` variables without a dedicated editor control. Light-only or dark-only overrides remain specific to their mode. CSS font imports are preserved; JSON exports carry them in optional `$aikit` metadata alongside the ordinary Gravity token entries.
|
|
30
|
+
|
|
31
|
+
**Export theme** displays the generated CSS or JSON and supports copying or downloading it. JSON preserves the editable token values and references. The extended JSON includes AIKit tokens that the upstream Gravity editor does not support; use this editor to retain them when importing again. For an upstream-only theme, use the shared Gravity tokens without the AIKit entries or metadata.
|
|
32
|
+
|
|
33
|
+
Load exported CSS after the default styles:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import '@gravity-ui/uikit/styles/styles.css';
|
|
37
|
+
import '@gravity-ui/aikit/styles';
|
|
38
|
+
import './aikit-theme.css';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Continue using UIKit's `ThemeProvider` to switch modes:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {ThemeProvider} from '@gravity-ui/uikit';
|
|
45
|
+
import {ChatContainer} from '@gravity-ui/aikit';
|
|
46
|
+
|
|
47
|
+
<ThemeProvider theme="dark">
|
|
48
|
+
<ChatContainer onSendMessage={handleSendMessage} />
|
|
49
|
+
</ThemeProvider>;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
AIKit's theme styles recognize UIKit's light/dark classes and retain the existing `data-theme` selectors for compatibility. A nested scoped provider can use a different mode from the surrounding application.
|
|
53
|
+
|
|
54
|
+
## Checks
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm run typecheck
|
|
58
|
+
npm run test:themer
|
|
59
|
+
npm run lint
|
|
60
|
+
npm run build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The theme exchange checks exercise the real Gravity generator and parser with independent mode overrides, palette-to-semantic references, radii, malformed imports, preview scoping, and CSS/JSON round trips. They do not render UI components.
|
package/docs/THEMING.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Theming
|
|
2
2
|
|
|
3
|
+
Use the [AIKit Themer](./THEMER.md) in Storybook to edit shared Gravity tokens and AIKit settings with a live chat preview, then export CSS or JSON.
|
|
4
|
+
|
|
3
5
|
AIKit uses CSS variables for theming, in the `--g-aikit-*` namespace. Values fall back to Gravity UI's `--g-color-*` system so AIKit picks up your existing uikit theme automatically.
|
|
4
6
|
|
|
5
7
|
## CSS Setup
|
|
@@ -11,7 +13,7 @@ import '@gravity-ui/aikit/themes/common';
|
|
|
11
13
|
import '@gravity-ui/aikit/themes/light'; // or '/dark'
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which
|
|
16
|
+
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which applies `.g-root_theme_light` or `.g-root_theme_dark` to the theme root. AIKit recognizes these classes and also retains its `data-theme` selectors for compatibility:
|
|
15
17
|
|
|
16
18
|
```tsx
|
|
17
19
|
import {ThemeProvider} from '@gravity-ui/uikit';
|
package/llms-full.txt
CHANGED
|
@@ -845,6 +845,8 @@ Each component also has a dedicated subpath export for tree-shaking — `import
|
|
|
845
845
|
|
|
846
846
|
# Theming
|
|
847
847
|
|
|
848
|
+
Use the [AIKit Themer](./THEMER.md) in Storybook to edit shared Gravity tokens and AIKit settings with a live chat preview, then export CSS or JSON.
|
|
849
|
+
|
|
848
850
|
AIKit uses CSS variables for theming, in the `--g-aikit-*` namespace. Values fall back to Gravity UI's `--g-color-*` system so AIKit picks up your existing uikit theme automatically.
|
|
849
851
|
|
|
850
852
|
## CSS Setup
|
|
@@ -856,7 +858,7 @@ import '@gravity-ui/aikit/themes/common';
|
|
|
856
858
|
import '@gravity-ui/aikit/themes/light'; // or '/dark'
|
|
857
859
|
```
|
|
858
860
|
|
|
859
|
-
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which
|
|
861
|
+
Switching between themes is done via `@gravity-ui/uikit`'s `<ThemeProvider>`, which applies `.g-root_theme_light` or `.g-root_theme_dark` to the theme root. AIKit recognizes these classes and also retains its `data-theme` selectors for compatibility:
|
|
860
862
|
|
|
861
863
|
```tsx
|
|
862
864
|
import {ThemeProvider} from '@gravity-ui/uikit';
|
|
@@ -1099,6 +1101,73 @@ Each `--g-aikit-color-*` variable falls back to a `--g-aikit-*` "raw" variable,
|
|
|
1099
1101
|
This means: if you already set `--g-color-base-float` via `@gravity-ui/uikit`'s theming, AIKit picks it up automatically.
|
|
1100
1102
|
|
|
1101
1103
|
|
|
1104
|
+
--- file: docs/THEMER.md ---
|
|
1105
|
+
|
|
1106
|
+
# AIKit Themer
|
|
1107
|
+
|
|
1108
|
+
Open **Theming → Themer → Playground** in [AIKit Storybook](https://preview.gravity-ui.com/aikit/) to edit a theme alongside a live AIKit chat. The editor uses the same `@gravity-ui/uikit-themer` generator as Gravity Themer and UIKit's current Storybook theme importer, with UIKit controls and `chroma-js` color validation.
|
|
1109
|
+
|
|
1110
|
+
## Run locally
|
|
1111
|
+
|
|
1112
|
+
```sh
|
|
1113
|
+
npm ci
|
|
1114
|
+
npm start -- --port 6006 --no-open
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
Open [the editor](http://localhost:6006/?path=/story/theming-themer--playground), or choose its entry from the Storybook sidebar. The editor is a development tool and is not included in AIKit's runtime exports.
|
|
1118
|
+
|
|
1119
|
+
## Edit a theme
|
|
1120
|
+
|
|
1121
|
+
- **Colors** changes brand and semantic palettes. Palette updates regenerate private shades through the Gravity generator. Brand updates connect the palette to button, selection, focus, and link tokens, and choose a contrasting button text color. Presets replace the current theme; individual colors can be edited independently for light and dark modes.
|
|
1122
|
+
- **Typography** changes interface and monospace font families and common text sizes. Fonts must be available to your application. These settings are shared between both modes. AIKit's mobile typography overrides remain independent.
|
|
1123
|
+
- **Radius** changes UIKit radius tokens used by inputs and attachments. The directional message bubble retains its spacing-based corners.
|
|
1124
|
+
- **AIKit** changes user message colors, chat surfaces, mascot colors and sizes, Shimmer, and padding. An empty field inherits the existing default. Color fields also accept a simple reference such as `var(--g-color-base-brand)`.
|
|
1125
|
+
|
|
1126
|
+
Choose the editing variant separately from the preview mode. The preview supports light, dark, or both; desktop and mobile; and welcome, conversation, streaming, and error scenarios. You can send local sample messages, start a new chat, and open history to inspect components and portal content. No model service is contacted.
|
|
1127
|
+
|
|
1128
|
+
Preview CSS is restricted to the preview roots, including nested portal roots, so edits do not recolor the editor. Settings are saved in local browser storage. Use **Reset** to restore Gravity defaults, or download a theme to keep it outside the browser.
|
|
1129
|
+
|
|
1130
|
+
## Import and export
|
|
1131
|
+
|
|
1132
|
+
**Import** accepts pasted or uploaded Gravity theme CSS or JSON, as well as themes exported by this editor. CSS must use the generator's `.g-root`, `.g-root_theme_light`, and `.g-root_theme_dark` rules. Unsupported selectors or variables produce an error and leave the active theme unchanged. The source is limited to 500,000 characters.
|
|
1133
|
+
|
|
1134
|
+
AIKit variables are preserved separately from the Gravity generator. This includes imported `--g-aikit-*` variables without a dedicated editor control. Light-only or dark-only overrides remain specific to their mode. CSS font imports are preserved; JSON exports carry them in optional `$aikit` metadata alongside the ordinary Gravity token entries.
|
|
1135
|
+
|
|
1136
|
+
**Export theme** displays the generated CSS or JSON and supports copying or downloading it. JSON preserves the editable token values and references. The extended JSON includes AIKit tokens that the upstream Gravity editor does not support; use this editor to retain them when importing again. For an upstream-only theme, use the shared Gravity tokens without the AIKit entries or metadata.
|
|
1137
|
+
|
|
1138
|
+
Load exported CSS after the default styles:
|
|
1139
|
+
|
|
1140
|
+
```tsx
|
|
1141
|
+
import '@gravity-ui/uikit/styles/styles.css';
|
|
1142
|
+
import '@gravity-ui/aikit/styles';
|
|
1143
|
+
import './aikit-theme.css';
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
Continue using UIKit's `ThemeProvider` to switch modes:
|
|
1147
|
+
|
|
1148
|
+
```tsx
|
|
1149
|
+
import {ThemeProvider} from '@gravity-ui/uikit';
|
|
1150
|
+
import {ChatContainer} from '@gravity-ui/aikit';
|
|
1151
|
+
|
|
1152
|
+
<ThemeProvider theme="dark">
|
|
1153
|
+
<ChatContainer onSendMessage={handleSendMessage} />
|
|
1154
|
+
</ThemeProvider>;
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
AIKit's theme styles recognize UIKit's light/dark classes and retain the existing `data-theme` selectors for compatibility. A nested scoped provider can use a different mode from the surrounding application.
|
|
1158
|
+
|
|
1159
|
+
## Checks
|
|
1160
|
+
|
|
1161
|
+
```sh
|
|
1162
|
+
npm run typecheck
|
|
1163
|
+
npm run test:themer
|
|
1164
|
+
npm run lint
|
|
1165
|
+
npm run build
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
The theme exchange checks exercise the real Gravity generator and parser with independent mode overrides, palette-to-semantic references, radii, malformed imports, preview scoping, and CSS/JSON round trips. They do not render UI components.
|
|
1169
|
+
|
|
1170
|
+
|
|
1102
1171
|
--- file: docs/HOOKS.md ---
|
|
1103
1172
|
|
|
1104
1173
|
# Hooks
|
package/llms.txt
CHANGED
|
@@ -93,6 +93,7 @@ Tree-shaken imports: `@gravity-ui/aikit/PromptInput`, `/Header`, `/MessageList`,
|
|
|
93
93
|
## Theming & i18n
|
|
94
94
|
|
|
95
95
|
- [Theming Guide](https://github.com/gravity-ui/aikit/blob/main/docs/THEMING.md): `--g-aikit-*` CSS variables, light/dark themes, fallback chain to `--g-color-*`
|
|
96
|
+
- [AIKit Themer](https://github.com/gravity-ui/aikit/blob/main/docs/THEMER.md): Visual theme editor, live AIKit preview, CSS and JSON import and export.
|
|
96
97
|
- [I18N](https://github.com/gravity-ui/aikit/blob/main/docs/I18N.md): per-component localization (en, ru) via `@gravity-ui/i18n`
|
|
97
98
|
|
|
98
99
|
## Troubleshooting
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/aikit",
|
|
3
|
-
"version": "2.23.0",
|
|
3
|
+
"version": "2.23.1-beta.2a8d4fab43196b53447acf9714ce4618c72c29ff.0",
|
|
4
4
|
"description": "Gravity UI base kit for building ai assistant chats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -704,7 +704,7 @@
|
|
|
704
704
|
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx .",
|
|
705
705
|
"lint:styles": "stylelint 'src/**/*.scss'",
|
|
706
706
|
"lint": "run-p lint:js lint:styles lint:prettier typecheck",
|
|
707
|
-
"typecheck": "tsc --noEmit",
|
|
707
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p src/demo/Themer/tsconfig.json",
|
|
708
708
|
"lint:fix": "run-s lint:js:fix lint:styles:fix lint:prettier:fix typecheck",
|
|
709
709
|
"lint:js:fix": "eslint '**/*.{js,jsx,ts,tsx}' --max-warnings=0 --quiet --fix",
|
|
710
710
|
"lint:styles:fix": "stylelint **/*.scss --fix",
|
|
@@ -720,7 +720,7 @@
|
|
|
720
720
|
"build:server": "tsc -p src/server/tsconfig.esm.json && tsc -p src/server/tsconfig.cjs.json",
|
|
721
721
|
"start": "TS_NODE_PROJECT=.storybook/tsconfig.json storybook dev",
|
|
722
722
|
"prepublishOnly": "npm run build",
|
|
723
|
-
"test:unit": "jest --passWithNoTests --testPathIgnorePatterns=src/server",
|
|
723
|
+
"test:unit": "jest --passWithNoTests --testPathIgnorePatterns=src/server && npm run test:themer",
|
|
724
724
|
"test:server:unit": "jest --config=src/server/jest.config.js",
|
|
725
725
|
"playwright:install": "playwright install chromium webkit --with-deps",
|
|
726
726
|
"playwright": "playwright test --config=playwright-ct.config.ts",
|
|
@@ -730,7 +730,8 @@
|
|
|
730
730
|
"playwright:docker:update": "./playwright/run-docker-command.sh npm run playwright:update --",
|
|
731
731
|
"playwright:docker:clear-cache": "./playwright/run-docker-command.sh clear-cache",
|
|
732
732
|
"generate:mascot": "node scripts/generate-mascot-assets.js",
|
|
733
|
-
"generate:mascot:check": "node scripts/generate-mascot-assets.js --check"
|
|
733
|
+
"generate:mascot:check": "node scripts/generate-mascot-assets.js --check",
|
|
734
|
+
"test:themer": "jest --config=src/demo/Themer/jest.config.js"
|
|
734
735
|
},
|
|
735
736
|
"devDependencies": {
|
|
736
737
|
"@babel/preset-env": "^7.28.5",
|
|
@@ -747,7 +748,8 @@
|
|
|
747
748
|
"@gravity-ui/readme-validator": "^1.3.0",
|
|
748
749
|
"@gravity-ui/stylelint-config": "^4.0.1",
|
|
749
750
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
750
|
-
"@gravity-ui/uikit": "^7.
|
|
751
|
+
"@gravity-ui/uikit": "^7.51.1",
|
|
752
|
+
"@gravity-ui/uikit-themer": "^2.0.0",
|
|
751
753
|
"@playwright/experimental-ct-react": "^1.56.1",
|
|
752
754
|
"@playwright/test": "^1.56.1",
|
|
753
755
|
"@storybook/addon-docs": "^9.0.5",
|
|
@@ -760,11 +762,13 @@
|
|
|
760
762
|
"@testing-library/dom": "^10.4.1",
|
|
761
763
|
"@testing-library/jest-dom": "^6.9.1",
|
|
762
764
|
"@testing-library/react": "^16.3.0",
|
|
765
|
+
"@types/chroma-js": "^3.1.2",
|
|
763
766
|
"@types/jest": "^29.5.14",
|
|
764
767
|
"@types/react": "^18.2.64",
|
|
765
768
|
"@types/react-dom": "^18.2.21",
|
|
766
769
|
"@types/sanitize-html": "^2.16.1",
|
|
767
770
|
"@types/uuid": "^11.0.0",
|
|
771
|
+
"chroma-js": "^3.2.0",
|
|
768
772
|
"eslint": "^8.57.0",
|
|
769
773
|
"eslint-plugin-storybook": "^9.0.5",
|
|
770
774
|
"gulp": "^5.0.1",
|
|
@@ -777,6 +781,7 @@
|
|
|
777
781
|
"jest-environment-jsdom": "^30.2.0",
|
|
778
782
|
"nano-staged": "^0.8.0",
|
|
779
783
|
"npm-run-all": "^4.1.5",
|
|
784
|
+
"postcss": "^8.5.30",
|
|
780
785
|
"prettier": "^3.2.5",
|
|
781
786
|
"process": "^0.11.10",
|
|
782
787
|
"react": "^18.2.0",
|