From ca03d13d2554732249cf64a54c301597283e76be Mon Sep 17 00:00:00 2001 From: yz778 <2322981+yz778@users.noreply.github.com> Date: Tue, 8 Jul 2025 00:20:23 -0700 Subject: [PATCH 1/5] feat: add all themes available --- src/components/OmniBar.tsx | 55 ++++++++++-------------- src/components/ThemeSelector.tsx | 9 ++-- src/core/setting/SettingModel.ts | 9 ++-- tailwind.config.ts | 74 ++++++++++++++++---------------- 4 files changed, 69 insertions(+), 78 deletions(-) diff --git a/src/components/OmniBar.tsx b/src/components/OmniBar.tsx index a22e9aa3..eafc50a8 100644 --- a/src/components/OmniBar.tsx +++ b/src/components/OmniBar.tsx @@ -16,6 +16,7 @@ import { chatStore } from '~/core/chat/ChatStore' import { connectionStore } from '~/core/connection/ConnectionStore' import { messageTable } from '~/core/message/MessageTable' +import themes from 'daisyui/src/theming/themes' const isSelected = ({ parent, id }: ActionImpl) => { if (parent === 'theme') { @@ -87,6 +88,27 @@ export function RenderResults() { } const useRegisterThemeActions = () => { + const themeNames = Object.keys(themes) + + const themeActions = themeNames.map(theme => ({ + id: theme, + name: theme.charAt(0).toUpperCase() + theme.slice(1), + keywords: `${theme} theme`, + section: 'Theme', + perform: async () => settingStore.update({ theme }), + parent: 'theme', + })) + + // Optionally add a "System" theme + themeActions.push({ + id: '_system', + name: 'System', + keywords: 'system theme', + section: 'Theme', + perform: async () => settingStore.update({ theme: '_system' }), + parent: 'theme', + }) + useRegisterActions([ { id: 'theme', @@ -94,38 +116,7 @@ const useRegisterThemeActions = () => { keywords: 'interface color dark light', section: 'Preferences', }, - { - id: 'dark', - name: 'Dark', - keywords: 'dark theme', - section: 'Theme', - perform: async () => settingStore.update({ theme: 'dark' }), - parent: 'theme', - }, - { - id: 'dracula', - name: 'Dracula', - keywords: 'dracula theme', - section: 'Theme', - perform: async () => settingStore.update({ theme: 'dracula' }), - parent: 'theme', - }, - { - id: '_system', - name: 'System', - keywords: 'system theme', - section: 'Theme', - perform: async () => settingStore.update({ theme: '_system' }), - parent: 'theme', - }, - { - id: 'garden', - name: 'Light', - keywords: 'light garden theme', - section: 'Theme', - perform: async () => settingStore.update({ theme: 'garden' }), - parent: 'theme', - }, + ...themeActions, ]) } diff --git a/src/components/ThemeSelector.tsx b/src/components/ThemeSelector.tsx index ac01a554..7ca6fea5 100644 --- a/src/components/ThemeSelector.tsx +++ b/src/components/ThemeSelector.tsx @@ -4,11 +4,14 @@ import { twMerge } from 'tailwind-merge' import { settingStore } from '~/core/setting/SettingStore' import { Select, SelectItem } from '@heroui/react' +import allThemes from 'daisyui/src/theming/themes' + const themes = { _system: 'System theme', - dark: 'Dark', - dracula: 'Dracula', - garden: 'Light', + ...Object.keys(allThemes).reduce>((acc, key) => { + acc[key] = key.charAt(0).toUpperCase() + key.slice(1) + return acc + }, {}), } const ThemeSelector = () => { diff --git a/src/core/setting/SettingModel.ts b/src/core/setting/SettingModel.ts index c3a34386..e4a0a2b7 100644 --- a/src/core/setting/SettingModel.ts +++ b/src/core/setting/SettingModel.ts @@ -1,15 +1,12 @@ import z from 'zod' import moment from 'moment' +import allThemes from 'daisyui/src/theming/themes' export const CURRENT_DB_TIMESTAMP = moment('Oct 28 24', 'MMM DD YY') export const CURRENT_DB_TIMESTAMP_MILLISECONDS = CURRENT_DB_TIMESTAMP.valueOf() -const ThemeOptions = z.union([ - z.literal('_system'), - z.literal('dark'), - z.literal('dracula'), - z.literal('garden'), -]) +const themeKeys = ['_system', ...Object.keys(allThemes)] as const +const ThemeOptions = z.enum(themeKeys) export const SettingModel = z.object({ // setting row will only have one field diff --git a/tailwind.config.ts b/tailwind.config.ts index 3125c150..9bf6cc98 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,54 +1,54 @@ /** @type {import('tailwindcss').Config} */ -import { heroui } from "@heroui/react" +import { heroui } from '@heroui/react' import themes from 'daisyui/src/theming/themes' const errorColor = 'oklch(51% 0.17 22.1)' +const allThemes = Object.entries(themes).map(([name, theme]) => { + if (name === 'garden') { + return { + [name]: { + ...theme, + primary: 'oklch(62.45% 0.1947 3.83636)', + error: errorColor, + }, + } + } + + return { + [name]: { + ...theme, + error: errorColor, + }, + } +}) + module.exports = { - content: [ - 'src/**/*.{js,ts,jsx,tsx}', - "./node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}", - ], + content: ['src/**/*.{js,ts,jsx,tsx}', './node_modules/@heroui/theme/dist/**/*.{js,ts,jsx,tsx}'], theme: { extend: {}, }, darkMode: 'class', - plugins: [require('@tailwindcss/typography'), require('daisyui'), heroui({ - themes: { - light: { - colors: { - danger: errorColor - } - }, - dark: { - colors: { - danger: errorColor - } - } - } - })], - daisyui: { - themes: [ - { - garden: { - ...themes['garden'], - primary: 'oklch(62.45% 0.1947 3.83636)', - error: errorColor + plugins: [ + require('@tailwindcss/typography'), + require('daisyui'), + heroui({ + themes: { + light: { + colors: { + danger: errorColor, + }, }, - }, - { dark: { - ...themes['dark'], - error: errorColor - }, - }, - { - dracula: { - ...themes['dracula'], - error: errorColor + colors: { + danger: errorColor, + }, }, }, - ], + }), + ], + daisyui: { + themes: allThemes, }, } From 1d734a894b41cbfb9bf9c45e0371c6a618b43154 Mon Sep 17 00:00:00 2001 From: djohnson Date: Tue, 8 Jul 2025 09:11:20 +0200 Subject: [PATCH 2/5] fix: sidebar flickers when closing the flicker is still there but its during the closing animation instead of after --- src/containers/SideBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/SideBar.tsx b/src/containers/SideBar.tsx index 24332f1b..33d164c9 100644 --- a/src/containers/SideBar.tsx +++ b/src/containers/SideBar.tsx @@ -51,7 +51,7 @@ export const SideBar = () => {