Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(themes): add purple theme (#7095)

白熱3619e19c32ba
diff --git a/common/debugger/src/views/use-theme.ts b/common/debugger/src/views/use-theme.ts
index 19b14f50d4..7fcc69aa43 100644
--- a/common/debugger/src/views/use-theme.ts
+++ b/common/debugger/src/views/use-theme.ts
@@ -15,7 +15,7 @@
*/
import { ThemeService } from '@univerjs/core';
-import { defaultTheme, greenTheme, redTheme } from '@univerjs/themes';
+import { defaultTheme, greenTheme, purpleTheme, redTheme } from '@univerjs/themes';
import { useDependency } from '@univerjs/ui';
import { useEffect } from 'react';
@@ -32,6 +32,10 @@ const themes = [
label: '🔴',
value: redTheme,
},
+ {
+ label: '🟣',
+ value: purpleTheme,
+ },
];
export function useTheme() {
@@ -45,7 +49,7 @@ export function useTheme() {
if (theme) {
themeService.setTheme(theme.value);
}
- }, []);
+ }, [themeService]);
const onSelect = (value: string) => {
localStorage.setItem('local.theme', value);
diff --git a/examples/src/theme-customizer/constants.ts b/examples/src/theme-customizer/constants.ts
index 60c5027adb..71adcd618b 100644
--- a/examples/src/theme-customizer/constants.ts
+++ b/examples/src/theme-customizer/constants.ts
@@ -15,7 +15,7 @@
*/
import type { IThemePreset, ThemeScaleKey, ThemeShadeKey, TokenDensity } from './types';
-import { defaultTheme, greenTheme } from '@univerjs/themes';
+import { defaultTheme, greenTheme, purpleTheme, redTheme } from '@univerjs/themes';
export const PREVIEW_CONTAINER_ID = 'theme-customizer-preview';
@@ -34,6 +34,8 @@ export const LOOP_COLOR_OPTIONS = COLOR_SCALE_KEYS.flatMap((scale) =>
export const THEME_PRESETS: IThemePreset[] = [
{ key: 'default', label: 'defaultTheme', theme: defaultTheme },
{ key: 'green', label: 'greenTheme', theme: greenTheme },
+ { key: 'red', label: 'redTheme', theme: redTheme },
+ { key: 'purple', label: 'purpleTheme', theme: purpleTheme },
];
export const TOKEN_DENSITY_LABELS: Record<TokenDensity, string> = {
diff --git a/examples/src/theme-customizer/types.ts b/examples/src/theme-customizer/types.ts
index 83577bc9cc..96708a9e60 100644
--- a/examples/src/theme-customizer/types.ts
+++ b/examples/src/theme-customizer/types.ts
@@ -23,7 +23,7 @@ export type EditorMode = 'tokens' | 'json';
export type TokenDensity = 'core' | 'full';
export interface IThemePreset {
- key: 'default' | 'green';
+ key: 'default' | 'green' | 'red' | 'purple';
label: string;
theme: Theme;
}
diff --git a/packages/themes/README.md b/packages/themes/README.md
index 9cce3a064f..832eabb0f2 100644
--- a/packages/themes/README.md
+++ b/packages/themes/README.md
@@ -4,7 +4,7 @@
[![license](https://img.shields.io/npm/l/@univerjs/themes?style=flat-square)](https://npmjs.com/package/@univerjs/themes)
[![downloads](https://img.shields.io/npm/dm/@univerjs/themes?style=flat-square)](https://npmjs.com/package/@univerjs/themes)
-`@univerjs/themes` contains built-in Univer theme definitions such as the default theme and green theme.
+`@univerjs/themes` contains built-in Univer theme definitions such as the default, green, red, and purple themes.
## Package Overview
@@ -25,7 +25,7 @@ Keep all `@univerjs/*` packages on the same version.
## Usage
```ts
-import { defaultTheme, greenTheme } from '@univerjs/themes';
+import { defaultTheme, greenTheme, purpleTheme, redTheme } from '@univerjs/themes';
```
## Resources
@@ -33,4 +33,3 @@ import { defaultTheme, greenTheme } from '@univerjs/themes';
- [Documentation](https://docs.univer.ai)
- [NPM package](https://npmjs.com/package/@univerjs/themes)
- [GitHub repository](https://github.com/dream-num/univer)
-
diff --git a/packages/themes/src/index.ts b/packages/themes/src/index.ts
index 8b55ceafb1..c749f71737 100644
--- a/packages/themes/src/index.ts
+++ b/packages/themes/src/index.ts
@@ -16,4 +16,5 @@
export { default as defaultTheme, type Theme } from './default';
export { default as greenTheme } from './green';
+export { default as purpleTheme } from './purple';
export { default as redTheme } from './red';
diff --git a/packages/themes/src/purple.ts b/packages/themes/src/purple.ts
new file mode 100644
index 0000000000..3635d3f84b
--- /dev/null
+++ b/packages/themes/src/purple.ts
@@ -0,0 +1,190 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Theme } from './default';
+
+const purpleTheme: Theme = {
+ white: '#FFFFFF',
+ black: '#000000',
+ primary: {
+ 50: '#F5F3FF',
+ 100: '#EDE9FE',
+ 200: '#DDD6FE',
+ 300: '#C4B5FD',
+ 400: '#A78BFA',
+ 500: '#8B5CF6',
+ 600: '#7C3AED',
+ 700: '#6D28D9',
+ 800: '#5B21B6',
+ 900: '#4C1D95',
+ },
+ gray: {
+ 50: '#FAFAFC',
+ 100: '#F1F0F5',
+ 200: '#E5E2EC',
+ 300: '#C5BFCE',
+ 400: '#91879E',
+ 500: '#6F647B',
+ 600: '#554B61',
+ 700: '#403748',
+ 800: '#302838',
+ 900: '#241D2A',
+ },
+ blue: {
+ 50: '#EFF6FF',
+ 100: '#DBEAFE',
+ 200: '#BFDBFE',
+ 300: '#93C5FD',
+ 400: '#60A5FA',
+ 500: '#3B82F6',
+ 600: '#2563EB',
+ 700: '#1D4ED8',
+ 800: '#1E40AF',
+ 900: '#1E3A8A',
+ },
+ red: {
+ 50: '#FFF1F2',
+ 100: '#FFE4E6',
+ 200: '#FECDD3',
+ 300: '#FDA4AF',
+ 400: '#FB7185',
+ 500: '#F43F5E',
+ 600: '#E11D48',
+ 700: '#BE123C',
+ 800: '#9F1239',
+ 900: '#881337',
+ },
+ orange: {
+ 50: '#FFF7ED',
+ 100: '#FFEDD5',
+ 200: '#FED7AA',
+ 300: '#FDBA74',
+ 400: '#FB923C',
+ 500: '#F97316',
+ 600: '#EA580C',
+ 700: '#C2410C',
+ 800: '#9A3412',
+ 900: '#7C2D12',
+ },
+ yellow: {
+ 50: '#FEFCE8',
+ 100: '#FEF9C3',
+ 200: '#FEF08A',
+ 300: '#FDE047',
+ 400: '#FACC15',
+ 500: '#EAB308',
+ 600: '#CA8A04',
+ 700: '#A16207',
+ 800: '#854D0E',
+ 900: '#713F12',
+ },
+ green: {
+ 50: '#F0FDF4',
+ 100: '#DCFCE7',
+ 200: '#BBF7D0',
+ 300: '#86EFAC',
+ 400: '#4ADE80',
+ 500: '#22C55E',
+ 600: '#16A34A',
+ 700: '#15803D',
+ 800: '#166534',
+ 900: '#14532D',
+ },
+ jiqing: {
+ 50: '#ECFEFF',
+ 100: '#CFFAFE',
+ 200: '#A5F3FC',
+ 300: '#67E8F9',
+ 400: '#22D3EE',
+ 500: '#06B6D4',
+ 600: '#0891B2',
+ 700: '#0E7490',
+ 800: '#155E75',
+ 900: '#164E63',
+ },
+ indigo: {
+ 50: '#EEF2FF',
+ 100: '#E0E7FF',
+ 200: '#C7D2FE',
+ 300: '#A5B4FC',
+ 400: '#818CF8',
+ 500: '#6366F1',
+ 600: '#4F46E5',
+ 700: '#4338CA',
+ 800: '#3730A3',
+ 900: '#312E81',
+ },
+ purple: {
+ 50: '#FAF5FF',
+ 100: '#F3E8FF',
+ 200: '#E9D5FF',
+ 300: '#D8B4FE',
+ 400: '#C084FC',
+ 500: '#A855F7',
+ 600: '#9333EA',
+ 700: '#7E22CE',
+ 800: '#6B21A8',
+ 900: '#581C87',
+ },
+ pink: {
+ 50: '#FDF2F8',
+ 100: '#FCE7F3',
+ 200: '#FBCFE8',
+ 300: '#F9A8D4',
+ 400: '#F472B6',
+ 500: '#EC4899',
+ 600: '#DB2777',
+ 700: '#BE185D',
+ 800: '#9D174D',
+ 900: '#831843',
+ },
+ 'loop-color': {
+ 1: 'primary.500',
+ 2: 'indigo.500',
+ 3: 'pink.500',
+ 4: 'blue.500',
+ 5: 'jiqing.500',
+ 6: 'green.500',
+ 7: 'yellow.500',
+ 8: 'orange.500',
+ 9: 'red.500',
+ 10: 'purple.700',
+ 11: 'gray.700',
+ 12: 'indigo.700',
+ },
+ highlight: {
+ background: {
+ 1: { color: 'primary.500', alpha: 0.28 },
+ 2: { color: 'indigo.500', alpha: 0.28 },
+ 3: { color: 'pink.500', alpha: 0.28 },
+ 4: { color: 'blue.500', alpha: 0.28 },
+ 5: { color: 'jiqing.500', alpha: 0.28 },
+ 6: { color: 'green.500', alpha: 0.28 },
+ 7: { color: 'yellow.500', alpha: 0.28 },
+ 8: { color: 'gray.400', alpha: 0.28 },
+ 9: { color: 'primary.500', alpha: 0.14 },
+ 10: { color: 'indigo.500', alpha: 0.14 },
+ 11: { color: 'pink.500', alpha: 0.14 },
+ 12: { color: 'blue.500', alpha: 0.14 },
+ 13: { color: 'jiqing.500', alpha: 0.14 },
+ 14: { color: 'green.500', alpha: 0.14 },
+ 15: { color: 'yellow.500', alpha: 0.14 },
+ 16: { color: 'gray.400', alpha: 0.14 },
+ },
+ },
+};
+
+export default purpleTheme;