From f20cf2812bed3479c22d95210c0786760d859720 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 1 Aug 2025 19:25:57 -0600 Subject: [PATCH] inject css vars --- .../ui/report/ThemeWrapper/ThemeStyles.tsx | 18 ++++++++++----- .../ui/report/ThemeWrapper/ThemeWrapper.tsx | 22 ++++++++++--------- .../ui/report/ThemeWrapper/themes.ts | 5 ++--- .../ui/report/ThemeWrapper/useThemesConfig.ts | 4 ++-- .../components/ui/report/elements/AIMenu.tsx | 17 -------------- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/apps/web/src/components/ui/report/ThemeWrapper/ThemeStyles.tsx b/apps/web/src/components/ui/report/ThemeWrapper/ThemeStyles.tsx index d8cfcc1ac..570219408 100644 --- a/apps/web/src/components/ui/report/ThemeWrapper/ThemeStyles.tsx +++ b/apps/web/src/components/ui/report/ThemeWrapper/ThemeStyles.tsx @@ -2,26 +2,30 @@ import { useMounted } from '@/hooks/useMount'; import { useThemesConfig } from './useThemesConfig'; +import React from 'react'; -export function ThemesStyle() { - const { activeTheme } = useThemesConfig(); +export const ThemesStyle = React.memo(() => { + const { activeTheme, BASE_THEME } = useThemesConfig(); const mounted = useMounted(); if (!activeTheme || !mounted) { return null; } - console.log(activeTheme); - return ( ); -} +}); + +ThemesStyle.displayName = 'ThemesStyle'; diff --git a/apps/web/src/components/ui/report/ThemeWrapper/ThemeWrapper.tsx b/apps/web/src/components/ui/report/ThemeWrapper/ThemeWrapper.tsx index 57a575ac0..1b9862cbf 100644 --- a/apps/web/src/components/ui/report/ThemeWrapper/ThemeWrapper.tsx +++ b/apps/web/src/components/ui/report/ThemeWrapper/ThemeWrapper.tsx @@ -10,16 +10,18 @@ interface ThemeWrapperProps extends React.ComponentProps<'div'> { export function ThemeWrapper({ children, className, defaultTheme }: ThemeWrapperProps) { return ( -
- + <> +
+ {children} +
- {children} -
+ + ); } diff --git a/apps/web/src/components/ui/report/ThemeWrapper/themes.ts b/apps/web/src/components/ui/report/ThemeWrapper/themes.ts index 51a4d1755..0745d127a 100644 --- a/apps/web/src/components/ui/report/ThemeWrapper/themes.ts +++ b/apps/web/src/components/ui/report/ThemeWrapper/themes.ts @@ -1,4 +1,4 @@ -const BASE_THEME = { +export const BASE_THEME = { '--spacing': '0.25rem', '--breakpoint-xl': '80rem', '--breakpoint-2xl': '96rem', @@ -567,7 +567,6 @@ const _THEMES = { Object.entries(_THEMES).forEach(([key, theme]) => { // @ts-expect-error - key is a string _THEMES[key] = { - ...BASE_THEME, ...theme, dark: themeColorsToCssVariables(theme.dark), light: themeColorsToCssVariables(theme.light) @@ -595,7 +594,7 @@ export function themeColorsToCssVariables(colors: Record): Recor // `${cssVars["--primary"]} / ${100 - key * 20}%` // } - return cssVars; + return { ...cssVars, ...BASE_THEME }; } export function themeColorNameToCssVariable(name: string) { diff --git a/apps/web/src/components/ui/report/ThemeWrapper/useThemesConfig.ts b/apps/web/src/components/ui/report/ThemeWrapper/useThemesConfig.ts index 462ad85ca..80ac0661b 100644 --- a/apps/web/src/components/ui/report/ThemeWrapper/useThemesConfig.ts +++ b/apps/web/src/components/ui/report/ThemeWrapper/useThemesConfig.ts @@ -1,5 +1,5 @@ import { create } from 'zustand'; -import { THEMES, type Theme } from './themes'; +import { THEMES, BASE_THEME, type Theme } from './themes'; const useThemesConfigStore = create<{ activeTheme: Theme; @@ -13,5 +13,5 @@ export function useThemesConfig() { const activeTheme = useThemesConfigStore((state) => state.activeTheme); const setActiveTheme = useThemesConfigStore((state) => state.setActiveTheme); - return { activeTheme, setActiveTheme, allThemes: THEMES }; + return { activeTheme, setActiveTheme, allThemes: THEMES, BASE_THEME }; } diff --git a/apps/web/src/components/ui/report/elements/AIMenu.tsx b/apps/web/src/components/ui/report/elements/AIMenu.tsx index 7e54950df..7ed94763a 100644 --- a/apps/web/src/components/ui/report/elements/AIMenu.tsx +++ b/apps/web/src/components/ui/report/elements/AIMenu.tsx @@ -5,23 +5,6 @@ import * as React from 'react'; import { AIChatPlugin, AIPlugin, useEditorChat, useLastAssistantMessage } from '@platejs/ai/react'; import { BlockSelectionPlugin, useIsSelecting } from '@platejs/selection/react'; import { Command as CommandPrimitive } from 'cmdk'; -// import { -// Album, -// BadgeHelp, -// BookOpenCheck, -// Check, -// CornerUpLeft, -// FeatherIcon, -// ListEnd, -// ListMinus, -// ListPlus, -// Loader2Icon, -// PauseIcon, -// PenLine, -// SmileIcon, -// Wand, -// X -// } from 'lucide-react'; import { Album, CircleQuestion,