/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
packages/react/src/utils/appearance.ts
38 строк
1 KB
George Djabarov
feat(react): create connect chat channel connections (#10711)
15 апр 2026, 11:47
Не верифицирован
15 апр 2026, 11:47
242a772
Код
Авторство
О чём код?
import type { AllAppearance, AllIconKey, AllIconOverrides } from '@novu/js/ui'; import { MountedElement } from '../context/RendererContext'; import type { ReactAllAppearance, ReactIconRenderer, ReactInboxAppearance, ReactSubscriptionAppearance } from './types'; export function adaptAppearanceForJs( appearance: ReactInboxAppearance | ReactSubscriptionAppearance | ReactAllAppearance, mountElement: (el: HTMLElement, mountedElement: MountedElement) => () => void ): AllAppearance | undefined { if (!appearance) { return undefined; } const { icons, ...restAppearance } = appearance; const jsAppearance = { ...restAppearance } as AllAppearance; if (icons) { const jsIcons: AllIconOverrides = {}; const iconKeys = Object.keys(icons) as Array<AllIconKey>; for (const iconKey of iconKeys) { // @ts-expect-error: cant easily fix this type error const reactRenderer = icons[iconKey] as ReactIconRenderer; if (reactRenderer) { jsIcons[iconKey] = (el: HTMLDivElement, props: { class?: string }) => { return mountElement(el, reactRenderer(props)); }; } } // JsAppearance also has .icons directly (from JsTheme part of JsAppearance) jsAppearance.icons = jsIcons; } else { // If original didn't have icons, ensure the clone doesn't either delete jsAppearance.icons; } return jsAppearance; }