mirror of
https://github.com/usememos/memos.git
synced 2025-12-12 07:06:20 +08:00
feat: add midnight theme
This commit is contained in:
parent
07a030ddfd
commit
97cec0b57e
5 changed files with 116 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { Monitor, Moon, Palette, Sun, Wallpaper } from "lucide-react";
|
import { Monitor, Moon, MoonStar, Palette, Sun, Wallpaper } from "lucide-react";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { instanceStore } from "@/store";
|
import { instanceStore } from "@/store";
|
||||||
import { THEME_OPTIONS } from "@/utils/theme";
|
import { THEME_OPTIONS } from "@/utils/theme";
|
||||||
|
|
@ -15,6 +15,7 @@ const THEME_ICONS: Record<string, JSX.Element> = {
|
||||||
"default-dark": <Moon className="w-4 h-4" />,
|
"default-dark": <Moon className="w-4 h-4" />,
|
||||||
paper: <Palette className="w-4 h-4" />,
|
paper: <Palette className="w-4 h-4" />,
|
||||||
whitewall: <Wallpaper className="w-4 h-4" />,
|
whitewall: <Wallpaper className="w-4 h-4" />,
|
||||||
|
midnight: <MoonStar className="w-4 h-4" />,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThemeSelect = ({ value, onValueChange, className }: ThemeSelectProps = {}) => {
|
const ThemeSelect = ({ value, onValueChange, className }: ThemeSelectProps = {}) => {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { createRequestKey } from "./store-utils";
|
||||||
/**
|
/**
|
||||||
* Valid theme options
|
* Valid theme options
|
||||||
*/
|
*/
|
||||||
const VALID_THEMES = ["system", "default", "default-dark", "paper", "whitewall"] as const;
|
const VALID_THEMES = ["system", "default", "default-dark", "paper", "whitewall", "midnight"] as const;
|
||||||
export type Theme = (typeof VALID_THEMES)[number];
|
export type Theme = (typeof VALID_THEMES)[number];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
107
web/src/themes/midnight.css
Normal file
107
web/src/themes/midnight.css
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
:root {
|
||||||
|
--background: oklch(0.14 0.003 270);
|
||||||
|
--foreground: oklch(0.92 0.003 270);
|
||||||
|
--card: oklch(0.18 0.003 270);
|
||||||
|
--card-foreground: oklch(0.92 0.003 270);
|
||||||
|
--popover: oklch(0.18 0.003 270);
|
||||||
|
--popover-foreground: oklch(0.9 0.003 270);
|
||||||
|
--primary: oklch(0.7 0.08 290);
|
||||||
|
--primary-foreground: oklch(0.14 0.003 270);
|
||||||
|
--secondary: oklch(0.2 0.005 290);
|
||||||
|
--secondary-foreground: oklch(0.88 0.003 270);
|
||||||
|
--muted: oklch(0.18 0.005 270);
|
||||||
|
--muted-foreground: oklch(0.7 0.003 270);
|
||||||
|
--accent: oklch(0.22 0.008 295);
|
||||||
|
--accent-foreground: oklch(0.92 0.003 270);
|
||||||
|
--destructive: oklch(0.55 0.1 25);
|
||||||
|
--destructive-foreground: oklch(0.95 0.005 270);
|
||||||
|
--border: oklch(0.25 0.005 270);
|
||||||
|
--input: oklch(0.3 0.008 270);
|
||||||
|
--ring: oklch(0.7 0.08 290);
|
||||||
|
--chart-1: oklch(0.7 0.12 295);
|
||||||
|
--chart-2: oklch(0.7 0.12 285);
|
||||||
|
--chart-3: oklch(0.64 0.1 300);
|
||||||
|
--chart-4: oklch(0.68 0.12 295);
|
||||||
|
--chart-5: oklch(0.75 0.15 305);
|
||||||
|
--sidebar: oklch(0.13 0.002 270);
|
||||||
|
--sidebar-foreground: oklch(0.92 0.003 270);
|
||||||
|
--sidebar-primary: oklch(0.7 0.08 290);
|
||||||
|
--sidebar-primary-foreground: oklch(0.14 0.003 270);
|
||||||
|
--sidebar-accent: oklch(0.22 0.008 295);
|
||||||
|
--sidebar-accent-foreground: oklch(0.92 0.003 270);
|
||||||
|
--sidebar-border: oklch(0.25 0.005 270);
|
||||||
|
--sidebar-ring: oklch(0.7 0.08 290);
|
||||||
|
--font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
||||||
|
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
|
||||||
|
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
||||||
|
"Noto Color Emoji";
|
||||||
|
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
|
||||||
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||||
|
"Liberation Mono", "Courier New", monospace;
|
||||||
|
--radius: 0.5rem;
|
||||||
|
--shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||||
|
--shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
|
||||||
|
--shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
|
||||||
|
0 1px 2px -1px hsl(0 0% 0% / 0.1);
|
||||||
|
--shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
|
||||||
|
0 1px 2px -1px hsl(0 0% 0% / 0.1);
|
||||||
|
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
|
||||||
|
0 2px 4px -1px hsl(0 0% 0% / 0.1);
|
||||||
|
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
|
||||||
|
0 4px 6px -1px hsl(0 0% 0% / 0.1);
|
||||||
|
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.1),
|
||||||
|
0 8px 10px -1px hsl(0 0% 0% / 0.1);
|
||||||
|
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);
|
||||||
|
--tracking-normal: 0em;
|
||||||
|
--spacing: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--color-background: var(--background);
|
||||||
|
--color-foreground: var(--foreground);
|
||||||
|
--color-card: var(--card);
|
||||||
|
--color-card-foreground: var(--card-foreground);
|
||||||
|
--color-popover: var(--popover);
|
||||||
|
--color-popover-foreground: var(--popover-foreground);
|
||||||
|
--color-primary: var(--primary);
|
||||||
|
--color-primary-foreground: var(--primary-foreground);
|
||||||
|
--color-secondary: var(--secondary);
|
||||||
|
--color-secondary-foreground: var(--secondary-foreground);
|
||||||
|
--color-muted: var(--muted);
|
||||||
|
--color-muted-foreground: var(--muted-foreground);
|
||||||
|
--color-accent: var(--accent);
|
||||||
|
--color-accent-foreground: var(--accent-foreground);
|
||||||
|
--color-destructive: var(--destructive);
|
||||||
|
--color-destructive-foreground: var(--destructive-foreground);
|
||||||
|
--color-border: var(--border);
|
||||||
|
--color-input: var(--input);
|
||||||
|
--color-ring: var(--ring);
|
||||||
|
--color-chart-1: var(--chart-1);
|
||||||
|
--color-chart-2: var(--chart-2);
|
||||||
|
--color-chart-3: var(--chart-3);
|
||||||
|
--color-chart-4: var(--chart-4);
|
||||||
|
--color-chart-5: var(--chart-5);
|
||||||
|
--color-sidebar: var(--sidebar);
|
||||||
|
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||||
|
--color-sidebar-primary: var(--sidebar-primary);
|
||||||
|
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||||
|
--color-sidebar-accent: var(--sidebar-accent);
|
||||||
|
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||||
|
--color-sidebar-border: var(--sidebar-border);
|
||||||
|
--color-sidebar-ring: var(--sidebar-ring);
|
||||||
|
--font-sans: var(--font-sans);
|
||||||
|
--font-mono: var(--font-mono);
|
||||||
|
--font-serif: var(--font-serif);
|
||||||
|
--radius-sm: calc(var(--radius) - 4px);
|
||||||
|
--radius-md: calc(var(--radius) - 2px);
|
||||||
|
--radius-lg: var(--radius);
|
||||||
|
--radius-xl: calc(var(--radius) + 4px);
|
||||||
|
--shadow-2xs: var(--shadow-2xs);
|
||||||
|
--shadow-xs: var(--shadow-xs);
|
||||||
|
--shadow-sm: var(--shadow-sm);
|
||||||
|
--shadow: var(--shadow);
|
||||||
|
--shadow-md: var(--shadow-md);
|
||||||
|
--shadow-lg: var(--shadow-lg);
|
||||||
|
--shadow-xl: var(--shadow-xl);
|
||||||
|
--shadow-2xl: var(--shadow-2xl);
|
||||||
|
}
|
||||||
2
web/src/types/modules/setting.d.ts
vendored
2
web/src/types/modules/setting.d.ts
vendored
|
|
@ -1 +1 @@
|
||||||
type Theme = "system" | "default" | "default-dark" | "paper" | "whitewall";
|
type Theme = "system" | "default" | "default-dark" | "paper" | "whitewall" | "midnight";
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import defaultDarkThemeContent from "../themes/default-dark.css?raw";
|
import defaultDarkThemeContent from "../themes/default-dark.css?raw";
|
||||||
import paperThemeContent from "../themes/paper.css?raw";
|
import paperThemeContent from "../themes/paper.css?raw";
|
||||||
import whitewallThemeContent from "../themes/whitewall.css?raw";
|
import whitewallThemeContent from "../themes/whitewall.css?raw";
|
||||||
|
import midnightThemeContent from "../themes/midnight.css?raw";
|
||||||
|
|
||||||
const VALID_THEMES = ["system", "default", "default-dark", "paper", "whitewall"] as const;
|
const VALID_THEMES = ["system", "default", "default-dark", "paper", "whitewall", "midnight"] as const;
|
||||||
type ValidTheme = (typeof VALID_THEMES)[number];
|
type ValidTheme = (typeof VALID_THEMES)[number];
|
||||||
|
|
||||||
const THEME_CONTENT: Record<ValidTheme, string | null> = {
|
const THEME_CONTENT: Record<ValidTheme, string | null> = {
|
||||||
|
|
@ -11,6 +12,7 @@ const THEME_CONTENT: Record<ValidTheme, string | null> = {
|
||||||
"default-dark": defaultDarkThemeContent,
|
"default-dark": defaultDarkThemeContent,
|
||||||
paper: paperThemeContent,
|
paper: paperThemeContent,
|
||||||
whitewall: whitewallThemeContent,
|
whitewall: whitewallThemeContent,
|
||||||
|
midnight: midnightThemeContent,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ThemeOption {
|
export interface ThemeOption {
|
||||||
|
|
@ -24,6 +26,7 @@ export const THEME_OPTIONS: ThemeOption[] = [
|
||||||
{ value: "default-dark", label: "Dark" },
|
{ value: "default-dark", label: "Dark" },
|
||||||
{ value: "paper", label: "Paper" },
|
{ value: "paper", label: "Paper" },
|
||||||
{ value: "whitewall", label: "Whitewall" },
|
{ value: "whitewall", label: "Whitewall" },
|
||||||
|
{ value: "midnight", label: "Midnight"},
|
||||||
];
|
];
|
||||||
|
|
||||||
const validateTheme = (theme: string): ValidTheme => {
|
const validateTheme = (theme: string): ValidTheme => {
|
||||||
|
|
@ -44,7 +47,7 @@ export const getSystemTheme = (): "default" | "default-dark" => {
|
||||||
* Resolves the actual theme to apply based on user preference
|
* Resolves the actual theme to apply based on user preference
|
||||||
* If theme is "system", returns the system preference, otherwise returns the theme as-is
|
* If theme is "system", returns the system preference, otherwise returns the theme as-is
|
||||||
*/
|
*/
|
||||||
export const resolveTheme = (theme: string): "default" | "default-dark" | "paper" | "whitewall" => {
|
export const resolveTheme = (theme: string): "default" | "default-dark" | "paper" | "whitewall" | "midnight" => {
|
||||||
if (theme === "system") {
|
if (theme === "system") {
|
||||||
return getSystemTheme();
|
return getSystemTheme();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue