@cloud-ru/ds-ai-icon-giga 1.0.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/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@cloud-ru/ds-ai-icon-giga",
3
+ "version": "1.0.0",
4
+ "description": "Иконка-логотип GigaChat в монохроме и брендовых градиентах для тёмного и светлого фона.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/cloud-ru-tech/snack-v2.git",
8
+ "directory": "packages/ai-icon-giga"
9
+ },
10
+ "homepage": "https://github.com/cloud-ru-tech/snack-v2/tree/master/packages/ai-icon-giga",
11
+ "license": "Apache-2.0",
12
+ "author": "Danil Panov <dapanov@cloud.ru>",
13
+ "type": "module",
14
+ "main": "./dist/cjs/index.js",
15
+ "module": "./dist/esm/index.js",
16
+ "types": "./dist/esm/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "source": "./src/index.ts",
20
+ "types": "./dist/esm/index.d.ts",
21
+ "import": "./dist/esm/index.js",
22
+ "require": "./dist/cjs/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src",
28
+ "./CHANGELOG.md",
29
+ "./LICENSE"
30
+ ],
31
+ "sideEffects": [
32
+ "*.css",
33
+ "**/*.css"
34
+ ],
35
+ "dependencies": {
36
+ "classnames": "^2.5.1",
37
+ "@cloud-ru/ds-utils": "^1.0.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }
@@ -0,0 +1,82 @@
1
+ import { ValueOf, WithSupportProps } from '@cloud-ru/ds-utils';
2
+ import cn from 'classnames';
3
+ import { ComponentPropsWithoutRef, ReactElement, useId } from 'react';
4
+
5
+ import { GIGA_PATH, GRADIENT_PARAMS, LOGO_DARK_STOPS, LOGO_LIGHT_STOPS, TEST_IDS, VARIANT } from './constants';
6
+ import styles from './styles.module.scss';
7
+
8
+ export type AiIconGigaVariant = ValueOf<typeof VARIANT>;
9
+
10
+ const STOPS_BY_VARIANT = {
11
+ [VARIANT.LogoDark]: LOGO_DARK_STOPS,
12
+ [VARIANT.LogoLight]: LOGO_LIGHT_STOPS,
13
+ } as const;
14
+
15
+ export type AiIconGigaOwnProps = {
16
+ /**
17
+ * Вариант логотипа GigaChat:
18
+ * - `neutral` — монохром (`currentColor`, по умолчанию вторичный текстовый токен);
19
+ * - `logoDark` — брендовый градиент для тёмного фона;
20
+ * - `logoLight` — брендовый градиент для светлого фона.
21
+ * По умолчанию `neutral`.
22
+ */
23
+ variant?: AiIconGigaVariant;
24
+ /** Размер иконки в px (квадрат). По умолчанию `80`. */
25
+ size?: number;
26
+ /** Доп. класс корня. */
27
+ className?: string;
28
+ };
29
+
30
+ /**
31
+ * Публичный props компонента `AiIconGiga`.
32
+ *
33
+ * Иконка-логотип GigaChat из набора AI Components для переиспользования в
34
+ * составных компонентах стриминга. Рендерится как `<svg>`.
35
+ *
36
+ * По умолчанию декоративна (`aria-hidden`). Если иконка несёт смысл —
37
+ * переопределите `aria-hidden={false}` и задайте `aria-label`.
38
+ */
39
+ export type AiIconGigaProps = WithSupportProps<
40
+ AiIconGigaOwnProps & Omit<ComponentPropsWithoutRef<'svg'>, keyof AiIconGigaOwnProps | 'children'>
41
+ >;
42
+
43
+ export function AiIconGiga({
44
+ variant = VARIANT.Neutral,
45
+ size = 80,
46
+ className,
47
+ 'aria-hidden': ariaHidden,
48
+ 'data-test-id': dataTestId = TEST_IDS.root,
49
+ ...rest
50
+ }: AiIconGigaProps): ReactElement {
51
+ const gradientId = useId();
52
+ const isBranded = variant === VARIANT.LogoDark || variant === VARIANT.LogoLight;
53
+ const stops = isBranded ? STOPS_BY_VARIANT[variant] : undefined;
54
+
55
+ return (
56
+ <svg
57
+ {...rest}
58
+ width={size}
59
+ height={size}
60
+ viewBox='0 0 80 80'
61
+ fill='none'
62
+ xmlns='http://www.w3.org/2000/svg'
63
+ className={cn(styles.root, className)}
64
+ aria-hidden={ariaHidden ?? true}
65
+ data-variant={variant}
66
+ data-test-id={dataTestId}
67
+ >
68
+ <g transform='translate(10 10)'>
69
+ <path d={GIGA_PATH} fill={isBranded ? `url(#${gradientId})` : 'currentColor'} />
70
+ {stops && (
71
+ <defs>
72
+ <radialGradient id={gradientId} {...GRADIENT_PARAMS}>
73
+ {stops.map(({ offset, stopColor }) => (
74
+ <stop key={offset} offset={offset} stopColor={stopColor} />
75
+ ))}
76
+ </radialGradient>
77
+ </defs>
78
+ )}
79
+ </g>
80
+ </svg>
81
+ );
82
+ }
@@ -0,0 +1,59 @@
1
+ export const TEST_IDS = {
2
+ root: 'ai-icon-giga',
3
+ } as const;
4
+
5
+ export const VARIANT = {
6
+ Neutral: 'neutral',
7
+ LogoDark: 'logoDark',
8
+ LogoLight: 'logoLight',
9
+ } as const;
10
+
11
+ /**
12
+ * Path логотипа GigaChat (viewBox `0 0 60 60`, общий для всех вариантов).
13
+ * Источник — Figma AI-COMPONENTS, node 7404:40178 (экспортированный `d`-атрибут).
14
+ * Это геометрия фигуры (числа и команды path), а не разметка: рендерится через
15
+ * `<path d={...}>`, без `dangerouslySetInnerHTML` — внедрение скриптов невозможно.
16
+ */
17
+ export const GIGA_PATH =
18
+ 'M30 0C13.4301 0 0 13.4323 0 30C0 46.5677 13.4323 60 30 60C46.5677 60 60 46.5677 60 30C60 13.4323 46.5677 0 30 0ZM8.48807 24.5597C8.08633 23.285 8.03248 21.8261 8.32648 20.2327C8.83819 17.6158 10.1646 14.9473 12.162 12.5166L12.1912 12.4807C16.8078 6.3784 24.8403 2.73584 33.6785 2.73584C35.5009 2.73584 37.2941 2.89071 39.0402 3.19593C32.5271 3.79966 25.8121 6.66792 19.0634 11.7311C18.7761 11.9466 18.5921 12.272 18.5584 12.6289C18.5247 12.9857 18.6414 13.3426 18.8838 13.6096C21.0855 16.038 23.2895 18.6931 25.8143 21.9675C26.234 22.5129 27.0038 22.6274 27.5694 22.2256C32.6595 18.5786 37.0764 15.8764 41.3541 13.8049C41.1633 15.9976 38.23 19.3955 35.1642 21.9653C30.2626 25.9782 24.36 30.1504 17.7392 30.6845L17.4811 30.707C16.5071 30.7519 15.459 30.6374 14.3705 30.3681C11.7513 29.697 9.44191 27.41 8.49256 24.562L8.48807 24.5597ZM29.9798 55.9422C23.9695 55.9422 18.4394 53.8909 14.0473 50.4526C14.8867 50.5289 15.7709 50.5671 16.7337 50.5671C17.5395 50.5671 18.4013 50.5401 19.3282 50.4885C24.8044 50.089 30.4646 48.4574 35.6984 45.7754C40.9905 43.062 45.6026 39.3925 49.0432 35.153C51.274 32.3296 53.947 27.9913 54.7056 22.7329C54.7528 22.7979 54.7999 22.8653 54.847 22.9326C55.4979 25.2016 55.848 27.5986 55.848 30.0786C55.848 44.3637 44.2672 55.9445 29.982 55.9445L29.9798 55.9422Z';
19
+
20
+ /**
21
+ * Силуэт логотипа GigaChat как CSS `mask-image` (`url("data:image/svg+xml,…")`).
22
+ * Для эффектов, заливающих форму иконки внешним paint'ом (например, ведущая иконка
23
+ * `AiShimmer`): силуэт получает shimmer-покрытие вместо собственного цвета иконки.
24
+ */
25
+ export const GIGA_MASK_IMAGE = `url("data:image/svg+xml,${encodeURIComponent(
26
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80"><g transform="translate(10 10)"><path d="${GIGA_PATH}"/></g></svg>`,
27
+ )}")`;
28
+
29
+ export const GRADIENT_PARAMS = {
30
+ cx: '0',
31
+ cy: '0',
32
+ r: '1',
33
+ gradientUnits: 'userSpaceOnUse',
34
+ gradientTransform: 'translate(39.525 13.0149) scale(55.5181)',
35
+ } as const;
36
+
37
+ /** Стопы градиента для тёмного фона (`type='logoDark'`). */
38
+ export const LOGO_DARK_STOPS = [
39
+ { offset: '0.08', stopColor: '#7CB5F2' },
40
+ { offset: '0.17', stopColor: '#78B9EC' },
41
+ { offset: '0.28', stopColor: '#70C6DD' },
42
+ { offset: '0.38', stopColor: '#64D8C7' },
43
+ { offset: '0.44', stopColor: '#5FD7C2' },
44
+ { offset: '0.51', stopColor: '#54D5B3' },
45
+ { offset: '0.58', stopColor: '#40D39C' },
46
+ { offset: '0.66', stopColor: '#26D07C' },
47
+ ] as const;
48
+
49
+ /** Стопы градиента для светлого фона (`type='logoLight'`). */
50
+ export const LOGO_LIGHT_STOPS = [
51
+ { offset: '0.08', stopColor: '#58A1EE' },
52
+ { offset: '0.17', stopColor: '#5EACE8' },
53
+ { offset: '0.28', stopColor: '#5ABDD8' },
54
+ { offset: '0.38', stopColor: '#54D4C1' },
55
+ { offset: '0.44', stopColor: '#4BD2BB' },
56
+ { offset: '0.51', stopColor: '#47D2AD' },
57
+ { offset: '0.58', stopColor: '#38D198' },
58
+ { offset: '0.66', stopColor: '#24C676' },
59
+ ] as const;
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { AiIconGiga } from './AiIconGiga';
2
+ export type { AiIconGigaOwnProps, AiIconGigaProps, AiIconGigaVariant } from './AiIconGiga';
3
+ export { GIGA_MASK_IMAGE, TEST_IDS, VARIANT } from './constants';
@@ -0,0 +1,7 @@
1
+ @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
+
3
+ .root {
4
+ display: block;
5
+ flex-shrink: 0;
6
+ color: base.$sn-theme-color-available-version-textTertiary;
7
+ }