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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: migrate theme class to base-ui (#304)
白熱6bcb40c324d5
diff --git a/packages/base-ui/src/Basics/CSS/Skin/base.less b/packages/base-ui/src/Basics/CSS/Skin/base.lessindex 16135e83cc..057fb72b29 100644--- a/packages/base-ui/src/Basics/CSS/Skin/base.less+++ b/packages/base-ui/src/Basics/CSS/Skin/base.less@@ -1,7 +1,8 @@/**- * new design system+ * =====================================+ * Ramu / 瑞木 / Red+ * =====================================*/-// Ramu / 瑞木 / Red@red-50: #fee7e7;@red-100: #fdcece;@red-200: #fb9d9d;@@ -13,7 +14,24 @@@red-800: #b20000;@red-900: #9d0000;-// Hemerocallis / 萱草 / Orange+:export {+ --red-50: @red-50;+ --red-100: @red-100;+ --red-200: @red-200;+ --red-300: @red-300;+ --red-400: @red-400;+ --red-500: @red-500;+ --red-600: @red-600;+ --red-700: @red-700;+ --red-800: @red-800;+ --red-900: @red-900;+}++/**+ * =====================================+ * Hemerocallis / 萱草 / Orange+ * =====================================+ */@orange-50: #fef0e6;@orange-100: #fee1cd;@orange-200: #fdc49b;@@ -25,7 +43,24 @@@orange-800: #cc4f10;@orange-900: #b24000;-// Marigold / 万寿菊 / Gold+:export {+ --orange-50: @orange-50;+ --orange-100: @orange-100;+ --orange-200: @orange-200;+ --orange-300: @orange-300;+ --orange-400: @orange-400;+ --orange-500: @orange-500;+ --orange-600: @orange-600;+ --orange-700: @orange-700;+ --orange-800: @orange-800;+ --orange-900: @orange-900;+}++/**+ * =====================================+ * Marigold / 万寿菊 / Gold+ * =====================================+ */@gold-50: #fef6e6;@gold-100: #feeecd;@gold-200: #fddc9b;@@ -37,7 +72,24 @@@gold-800: #a97100;@gold-900: #8f5f00;-// Forsythia Suspensa / 连翘 / Yellow+:export {+ --gold-50: @gold-50;+ --gold-100: @gold-100;+ --gold-200: @gold-200;+ --gold-300: @gold-300;+ --gold-400: @gold-400;+ --gold-500: @gold-500;+ --gold-600: @gold-600;+ --gold-700: @gold-700;+ --gold-800: @gold-800;+ --gold-900: @gold-900;+}++/**+ * =====================================+ * Forsythia Suspensa / 连翘 / Yellow+ * =====================================+ */@yellow-50: #fefbe6;@yellow-100: #fef7cd;@yellow-200: #fdf09b;@@ -49,7 +101,24 @@@yellow-800: #c5a300;@yellow-900: #b19401;-// Eustoma Grandiflorum / 洋桔梗 / Verdancy+:export {+ --yellow-50: @yellow-50;+ --yellow-100: @yellow-100;+ --yellow-200: @yellow-200;+ --yellow-300: @yellow-300;+ --yellow-400: @yellow-400;+ --yellow-500: @yellow-500;+ --yellow-600: @yellow-600;+ --yellow-700: @yellow-700;+ --yellow-800: @yellow-800;+ --yellow-900: @yellow-900;+}++/**+ * =====================================+ * Eustoma Grandiflorum / 洋桔梗 / Verdancy+ * =====================================+ */@verdancy-50: #f7fde8;@verdancy-100: #effbd0;@verdancy-200: #def6a2;@@ -61,7 +130,24 @@@verdancy-800: #688c0d;@verdancy-900: #58770a;-// asparagus fern / 文竹 / Green+:export {+ --verdancy-50: @verdancy-50;+ --verdancy-100: @verdancy-100;+ --verdancy-200: @verdancy-200;+ --verdancy-300: @verdancy-300;+ --verdancy-400: @verdancy-400;+ --verdancy-500: @verdancy-500;+ --verdancy-600: @verdancy-600;+ --verdancy-700: @verdancy-700;+ --verdancy-800: @verdancy-800;+ --verdancy-900: @verdancy-900;+}++/**+ * =====================================+ * Asparagus Fern / 文竹 / Green+ * =====================================+ */@green-50: #effce8;@green-100: #dff9d2;@green-200: #bff3a5;@@ -73,7 +159,24 @@@green-800: #398712;@green-900: #317310;-// 霁 / Jiqing+:export {+ --green-50: @green-50;+ --green-100: @green-100;+ --green-200: @green-200;+ --green-300: @green-300;+ --green-400: @green-400;+ --green-500: @green-500;+ --green-600: @green-600;+ --green-700: @green-700;+ --green-800: @green-800;+ --green-900: @green-900;+}++/**+ * =====================================+ * 霁 / Jiqing+ * =====================================+ */@jiqing-50: #e8fcfc;@jiqing-100: #d1fafa;@jiqing-200: #a3f5f5;@@ -85,7 +188,24 @@@jiqing-800: #008a8a;@jiqing-900: #007676;-// Cornflower / 矢车菊 / Blue+:export {+ --jiqing-50: @jiqing-50;+ --jiqing-100: @jiqing-100;+ --jiqing-200: @jiqing-200;+ --jiqing-300: @jiqing-300;+ --jiqing-400: @jiqing-400;+ --jiqing-500: @jiqing-500;+ --jiqing-600: @jiqing-600;+ --jiqing-700: @jiqing-700;+ --jiqing-800: @jiqing-800;+ --jiqing-900: @jiqing-900;+}++/**+ * =====================================+ * Cornflower / 矢车菊 / Blue+ * =====================================+ */@blue-50: #e5f3ff;@blue-100: #cce6ff;@blue-200: #99ceff;@@ -97,7 +217,24 @@@blue-800: #0063c0;@blue-900: #0053a0;-// Hyacinth / 风信子 / Hyacinth Blue+:export {+ --blue-50: @blue-50;+ --blue-100: @blue-100;+ --blue-200: @blue-200;+ --blue-300: @blue-300;+ --blue-400: @blue-400;+ --blue-500: @blue-500;+ --blue-600: @blue-600;+ --blue-700: @blue-700;+ --blue-800: @blue-800;+ --blue-900: @blue-900;+}++/**+ * =====================================+ * Hyacinth / 风信子 / Hyacinth Blue+ * =====================================+ */@hyacinth-50: #e8ecfd;@hyacinth-100: #d0d9fb;@hyacinth-200: #a2b3f6;@@ -109,7 +246,24 @@@hyacinth-800: #0025b7;@hyacinth-900: #001f9c;-// Violet / 紫罗兰 / Purple+:export {+ --hyacinth-50: @hyacinth-50;+ --hyacinth-100: @hyacinth-100;+ --hyacinth-200: @hyacinth-200;+ --hyacinth-300: @hyacinth-300;+ --hyacinth-400: @hyacinth-400;+ --hyacinth-500: @hyacinth-500;+ --hyacinth-600: @hyacinth-600;+ --hyacinth-700: @hyacinth-700;+ --hyacinth-800: @hyacinth-800;+ --hyacinth-900: @hyacinth-900;+}++/**+ * =====================================+ * Violet / 紫罗兰 / Purple+ * =====================================+ */@purple-50: #f1eafa;@purple-100: #e3d5f6;@purple-200: #c7abed;@@ -121,7 +275,24 @@@purple-800: #510eb0;@purple-900: #3f0198;-// Sorrel pulp / 酢浆 / Magenta+:export {+ --purple-50: @purple-50;+ --purple-100: @purple-100;+ --purple-200: @purple-200;+ --purple-300: @purple-300;+ --purple-400: @purple-400;+ --purple-500: @purple-500;+ --purple-600: @purple-600;+ --purple-700: @purple-700;+ --purple-800: @purple-800;+ --purple-900: @purple-900;+}++/**+ * =====================================+ * Sorrel pulp / 酢浆 / Magenta+ * =====================================+ */@magenta-50: #fde8f3;@magenta-100: #fbd0e8;@magenta-200: #f6a2d0;@@ -133,7 +304,24 @@@magenta-800: #a1095c;@magenta-900: #8f0550;-// 灰 / Grey+:export {+ --magenta-50: @magenta-50;+ --magenta-100: @magenta-100;+ --magenta-200: @magenta-200;+ --magenta-300: @magenta-300;+ --magenta-400: @magenta-400;+ --magenta-500: @magenta-500;+ --magenta-600: @magenta-600;+ --magenta-700: @magenta-700;+ --magenta-800: @magenta-800;+ --magenta-900: @magenta-900;+}++/**+ * =====================================+ * 灰 / Grey+ * =====================================+ */@grey-50: #f9f9f9;@grey-100: #f5f5f5;@grey-200: #e5e5e5;@@ -147,6 +335,21 @@@grey-950: #606060;@grey-1000: #505050;+:export {+ --grey-50: @grey-50;+ --grey-100: @grey-100;+ --grey-200: @grey-200;+ --grey-300: @grey-300;+ --grey-400: @grey-400;+ --grey-500: @grey-500;+ --grey-600: @grey-600;+ --grey-700: @grey-700;+ --grey-800: @grey-800;+ --grey-900: @grey-900;+ --grey-950: @grey-950;+ --grey-1000: @grey-1000;+}+// 黑 / 白 / Black / White@color-black: #35322b;@color-white: #ffffff;@@ -190,9 +393,8 @@@padding-xs: 4px;// Font Size-@font-size-xxxl: 20px;-@font-size-xxl: 18px;-@font-size-xl: 17px;+@font-size-xxl: 20px;+@font-size-xl: 18px;@font-size-lg: 16px;@font-size-base: 15px;@font-size-sm: 14px;@@ -200,152 +402,6 @@@font-size-xxs: 12px;:export {- // Ramu / 瑞木 / Red- --red-50: @red-50;- --red-100: @red-100;- --red-200: @red-200;- --red-300: @red-300;- --red-400: @red-400;- --red-500: @red-500;- --red-600: @red-600;- --red-700: @red-700;- --red-800: @red-800;- --red-900: @red-900;-- // Hemerocallis / 萱草 / Orange- --orange-50: @orange-50;- --orange-100: @orange-100;- --orange-200: @orange-200;- --orange-300: @orange-300;- --orange-400: @orange-400;- --orange-500: @orange-500;- --orange-600: @orange-600;- --orange-700: @orange-700;- --orange-800: @orange-800;- --orange-900: @orange-900;-- // Marigold / 万寿菊 / Gold- --gold-50: @gold-50;- --gold-100: @gold-100;- --gold-200: @gold-200;- --gold-300: @gold-300;- --gold-400: @gold-400;- --gold-500: @gold-500;- --gold-600: @gold-600;- --gold-700: @gold-700;- --gold-800: @gold-800;- --gold-900: @gold-900;-- // Forsythia Suspensa / 连翘 / Yellow- --yellow-50: @yellow-50;- --yellow-100: @yellow-100;- --yellow-200: @yellow-200;- --yellow-300: @yellow-300;- --yellow-400: @yellow-400;- --yellow-500: @yellow-500;- --yellow-600: @yellow-600;- --yellow-700: @yellow-700;- --yellow-800: @yellow-800;- --yellow-900: @yellow-900;-- // Eustoma Grandiflorum / 洋桔梗 / Verdancy- --verdancy-50: @verdancy-50;- --verdancy-100: @verdancy-100;- --verdancy-200: @verdancy-200;- --verdancy-300: @verdancy-300;- --verdancy-400: @verdancy-400;- --verdancy-500: @verdancy-500;- --verdancy-600: @verdancy-600;- --verdancy-700: @verdancy-700;- --verdancy-800: @verdancy-800;- --verdancy-900: @verdancy-900;-- // Asparagus Fern / 文竹 / Green- --green-50: @green-50;- --green-100: @green-100;- --green-200: @green-200;- --green-300: @green-300;- --green-400: @green-400;- --green-500: @green-500;- --green-600: @green-600;- --green-700: @green-700;- --green-800: @green-800;- --green-900: @green-900;-- // 霁 / Jiqing- --jiqing-50: @jiqing-50;- --jiqing-100: @jiqing-100;- --jiqing-200: @jiqing-200;- --jiqing-300: @jiqing-300;- --jiqing-400: @jiqing-400;- --jiqing-500: @jiqing-500;- --jiqing-600: @jiqing-600;- --jiqing-700: @jiqing-700;- --jiqing-800: @jiqing-800;- --jiqing-900: @jiqing-900;-- // Cornflower / 矢车菊 / Blue- --blue-50: @blue-50;- --blue-100: @blue-100;- --blue-200: @blue-200;- --blue-300: @blue-300;- --blue-400: @blue-400;- --blue-500: @blue-500;- --blue-600: @blue-600;- --blue-700: @blue-700;- --blue-800: @blue-800;- --blue-900: @blue-900;-- // Hyacinth / 风信子 / Hyacinth Blue- --hyacinth-50: @hyacinth-50;- --hyacinth-100: @hyacinth-100;- --hyacinth-200: @hyacinth-200;- --hyacinth-300: @hyacinth-300;- --hyacinth-400: @hyacinth-400;- --hyacinth-500: @hyacinth-500;- --hyacinth-600: @hyacinth-600;- --hyacinth-700: @hyacinth-700;- --hyacinth-800: @hyacinth-800;- --hyacinth-900: @hyacinth-900;-- // Violet / 紫罗兰 / Purple- --purple-50: @purple-50;- --purple-100: @purple-100;- --purple-200: @purple-200;- --purple-300: @purple-300;- --purple-400: @purple-400;- --purple-500: @purple-500;- --purple-600: @purple-600;- --purple-700: @purple-700;- --purple-800: @purple-800;- --purple-900: @purple-900;-- // Sorrel pulp / 酢浆 / Magenta- --magenta-50: @magenta-50;- --magenta-100: @magenta-100;- --magenta-200: @magenta-200;- --magenta-300: @magenta-300;- --magenta-400: @magenta-400;- --magenta-500: @magenta-500;- --magenta-600: @magenta-600;- --magenta-700: @magenta-700;- --magenta-800: @magenta-800;- --magenta-900: @magenta-900;-- // 灰 / Grey- --grey-50: @grey-50;- --grey-100: @grey-100;- --grey-200: @grey-200;- --grey-300: @grey-300;- --grey-400: @grey-400;- --grey-500: @grey-500;- --grey-600: @grey-600;- --grey-700: @grey-700;- --grey-800: @grey-800;- --grey-900: @grey-900;- --grey-950: @grey-950;- --grey-1000: @grey-1000;-// 黑 / 白 / Black / White--color-black: @color-black;--color-white: @color-white;@@ -388,7 +444,6 @@--padding-xs: @padding-xs;// Font Size- --font-size-xxxl: @font-size-xxxl;--font-size-xxl: @font-size-xxl;--font-size-xl: @font-size-xl;--font-size-lg: @font-size-lg;@@ -401,8 +456,6 @@// TODO: to be removed// base css variables-@border-width-base: 1px;-@border-style-base: solid;@line-height-base: 1.5715;@gray-3: #f5f5f5;@@ -427,8 +480,6 @@@disabled-bg: @gray-3; //失效背景色:export {- --border-width-base: @border-width-base;- --border-style-base: @border-style-base;--line-height-base: @line-height-base;--font-size-base: @font-size-base;--font-size-lg: @font-size-lg;diff --git a/packages/base-ui/src/Components/Button/Style/index.module.less b/packages/base-ui/src/Components/Button/Style/index.module.lessindex 0647069dbd..4ff138dcdd 100644--- a/packages/base-ui/src/Components/Button/Style/index.module.less+++ b/packages/base-ui/src/Components/Button/Style/index.module.less@@ -51,10 +51,10 @@&::before {position: absolute;- top: -@border-width-base;- right: -@border-width-base;- bottom: -@border-width-base;- left: -@border-width-base;+ top: -1px;+ right: -1px;+ bottom: -1px;+ left: -1px;z-index: 1;display: none;background: @bg-color-secondary;diff --git a/packages/base-ui/src/Components/Button/Style/mixin.less b/packages/base-ui/src/Components/Button/Style/mixin.lessindex aebdde1c74..982305b4a6 100644--- a/packages/base-ui/src/Components/Button/Style/mixin.less+++ b/packages/base-ui/src/Components/Button/Style/mixin.less@@ -1,7 +1,7 @@@import '../../../Basics/CSS/Skin/default.module.less';.button-size(@height; @padding-horizontal; @font-size; @border-radius) {- @padding-vertical: max((round(((@height - @font-size * @line-height-base) / 2) * 10) / 10) - @border-width-base,+ @padding-vertical: max((round(((@height - @font-size * @line-height-base) / 2) * 10) / 10) - 1px,0);height: @height;// padding: @padding-vertical @padding-horizontal;@@ -76,10 +76,10 @@text-align: center;background-image: none;padding: 0 10px;- border: @border-width-base @border-style-base transparent;+ border: 1px solid transparent;cursor: pointer;user-select: none;- .button-size(30px; 15px; @font-size-base; @border-width-base);+ .button-size(30px; 15px; @font-size-base; 1px);&,&:active {diff --git a/packages/base-ui/src/Components/Checkbox/index.module.less b/packages/base-ui/src/Components/Checkbox/index.module.lessindex f80fc26be4..3ac21a86ea 100644--- a/packages/base-ui/src/Components/Checkbox/index.module.less+++ b/packages/base-ui/src/Components/Checkbox/index.module.less@@ -28,7 +28,7 @@width: @font-size-base;height: @font-size-base;background-color: #fff;- border: @border-width-base @border-style-base var(--border-color);+ border: 1px solid var(--border-color);&::after {@check-width: (@font-size-base / 14) * 5px;diff --git a/packages/base-ui/src/Components/DesignToken/Palette.tsx b/packages/base-ui/src/Components/DesignToken/Palette.tsxindex a17104a830..1ad6652915 100644--- a/packages/base-ui/src/Components/DesignToken/Palette.tsx+++ b/packages/base-ui/src/Components/DesignToken/Palette.tsx@@ -51,15 +51,7 @@ export function Palette(props: IProps) {},{title: 'Font Size',- colors: [- 'fontSizeXs',- 'fontSizeSm',- 'fontSizeBase',- 'fontSizeLg',- 'fontSizeXl',- 'fontSizeXxl',- 'fontSizeXxxl',- ],+ colors: ['fontSizeXs', 'fontSizeSm', 'fontSizeBase', 'fontSizeLg', 'fontSizeXl', 'fontSizeXxl'],},{title: 'Margin',@@ -145,7 +137,7 @@ export function Palette(props: IProps) {<tr><th>name</th><th>value</th>- <th>Less variable</th>+ <th>Less variable (deprecated)</th><th>CSS variable</th></tr></thead>diff --git a/packages/base-ui/src/Components/Menu/index.module.less b/packages/base-ui/src/Components/Menu/index.module.lessindex 3392751084..ee8316eb32 100644--- a/packages/base-ui/src/Components/Menu/index.module.less+++ b/packages/base-ui/src/Components/Menu/index.module.less@@ -31,7 +31,6 @@padding: var(--padding-xs);margin: var(--margin-xs) var(--margin-sm);font-size: 14px;-border-radius: var(--border-radius-base);&:hover,&.select-item-selected {@@ -55,7 +54,7 @@.menu-button() {border-radius: 0;transition: opacity 218ms;- background: var(--bg-color-secondary);+ background: rgb(var(--bg-color-secondary));box-shadow: var(--box-shadow-base);cursor: default;margin: 0;diff --git a/packages/base-ui/src/Components/Tabs/index.module.less b/packages/base-ui/src/Components/Tabs/index.module.lessindex 94ecef6fbb..82ccad240a 100644--- a/packages/base-ui/src/Components/Tabs/index.module.less+++ b/packages/base-ui/src/Components/Tabs/index.module.less@@ -73,12 +73,12 @@.tabs-tab {margin: 0;background: @bg-color;- border: @border-width-base @border-style-base @border-color;+ border: 1px solid @border-color;&-active {color: var(--primary-color);background: var(--bg);- border-bottom: @border-width-base @border-style-base var(--bg);+ border-bottom: 1px solid var(--bg);}}}diff --git a/packages/base-ui/src/Components/Tooltip/index.module.less b/packages/base-ui/src/Components/Tooltip/index.module.lessindex bf713ee5c4..ab0a78cba2 100644--- a/packages/base-ui/src/Components/Tooltip/index.module.less+++ b/packages/base-ui/src/Components/Tooltip/index.module.less@@ -1,15 +1,10 @@@import '../../Basics/CSS/triangle.less';@import '../../Basics/CSS/Skin/default.module.less';-@tooltip-color: @color-white;-@tooltip-bg: @color-black;--//** Tooltip arrow width+@tooltip-color: rgb(var(--color-white));+@tooltip-bg: rgb(var(--color-black));@tooltip-arrow-width: 5px;-//** Tooltip arrow color-@tooltip-arrow-color: @tooltip-bg;-// Base class.tooltip {position: absolute;z-index: 4;@@ -40,7 +35,7 @@bottom: 0;margin-left: -@tooltip-arrow-width;border-width: @tooltip-arrow-width @tooltip-arrow-width 0;- border-top-color: @tooltip-arrow-color;+ border-top-color: @tooltip-bg;}&-placement-top &-arrow {@@ -51,7 +46,7 @@left: 0;margin-top: -@tooltip-arrow-width;border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0;- border-right-color: @tooltip-arrow-color;+ border-right-color: @tooltip-bg;}&-placement-right &-arrow {@@ -62,7 +57,7 @@right: 0;margin-top: -@tooltip-arrow-width;border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width;- border-left-color: @tooltip-arrow-color;+ border-left-color: @tooltip-bg;}&-placement-left &-arrow {@@ -73,7 +68,7 @@top: 0;margin-left: -@tooltip-arrow-width;border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;- border-bottom-color: @tooltip-arrow-color;+ border-bottom-color: @tooltip-bg;}&-placement-bottom &-arrow {diff --git a/packages/base-ui/src/views/app.module.less b/packages/base-ui/src/views/app.module.lessindex 93abe8087e..912385c2a4 100644--- a/packages/base-ui/src/views/app.module.less+++ b/packages/base-ui/src/views/app.module.less@@ -66,7 +66,6 @@}.main-content {- background: var(--bg);}.outer-right-container {@@ -79,6 +78,6 @@}::selection {- background-color: var(--primary-color);+ background-color: rgb(var(--primary-color));}}diff --git a/packages/base-ui/src/views/app.tsx b/packages/base-ui/src/views/app.tsxindex 06efc13b75..2f32418855 100644--- a/packages/base-ui/src/views/app.tsx+++ b/packages/base-ui/src/views/app.tsx@@ -11,6 +11,7 @@ import { IWorkbenchOptions } from '../controllers/ui/ui.controller';import style from './app.module.less';import { ContextMenu } from './components/contextmenu/contextmenu';import { DocBars } from './components/DocBars';+import { themeInstance } from './theme';export interface IUniverAppProps extends IWorkbenchOptions {headerComponents?: Set<() => ComponentType>;@@ -47,12 +48,18 @@ export function App(props: IUniverAppProps) {const [locale, setLocale] = useState<LocaleType>(localeService.getLocale().getCurrentLocale());useEffect(() => {- const listener = localeService.getLocale().locale$.subscribe((locale) => {- locale && setLocale(locale);- });+ const listeners = [+ localeService.getLocale().locale$.subscribe((locale) => {+ locale && setLocale(locale);+ }),+ themeService.currentTheme$.subscribe((theme) => {+ themeInstance.setTheme(theme);+ }),+ ];return () => {- listener.unsubscribe();+ // batch unsubscribe+ listeners.forEach((listener) => listener.unsubscribe());};}, []);diff --git a/packages/base-ui/src/views/components/DocBars/Button/index.module.less b/packages/base-ui/src/views/components/DocBars/Button/index.module.lessindex fdc147be99..393a562523 100644--- a/packages/base-ui/src/views/components/DocBars/Button/index.module.less+++ b/packages/base-ui/src/views/components/DocBars/Button/index.module.less@@ -10,12 +10,12 @@}&-text {- .button-color(var(--text-color), transparent, transparent);+ .button-color(rgb(var(--text-color)), transparent, transparent);box-shadow: none;&:hover {- color: var(--text-color);- background-color: var(--grey-100);+ color: rgb(var(--text-color));+ background-color: rgb(var(--grey-100));border-color: transparent;}@@ -26,8 +26,8 @@// }.button-disabled(var(--disabled-color); transparent; transparent);&-active {- color: var(--text-color);- background-color: var(--grey-100);+ color: rgb(var(--text-color));+ background-color: rgb(var(--grey-100));border-color: transparent;}height: 26px;@@ -35,10 +35,10 @@&::before {position: absolute;- top: -@border-width-base;- right: -@border-width-base;- bottom: -@border-width-base;- left: -@border-width-base;+ top: -1px;+ right: -1px;+ bottom: -1px;+ left: -1px;z-index: 1;display: none;background: @bg-color-secondary;diff --git a/packages/base-ui/src/views/components/DocBars/index.module.less b/packages/base-ui/src/views/components/DocBars/index.module.lessindex 6575623c42..d0d66eeaad 100644--- a/packages/base-ui/src/views/components/DocBars/index.module.less+++ b/packages/base-ui/src/views/components/DocBars/index.module.less@@ -13,9 +13,9 @@height: 40px;padding: 0 @padding-xl;- color: var(--text-color);+ color: rgb(var(--text-color));font-size: var(--font-size);- background-color: @bg-color-secondary;+ background-color: rgb(var(--bg-color-secondary));box-sizing: border-box;display: flex;align-items: center;@@ -25,7 +25,7 @@height: 100%;display: flex;align-items: center;- border-bottom: 1px solid @border-color;+ border-bottom: 1px solid rgb(var(--border-color));> div {height: 26px;diff --git a/packages/core/src/services/theme/theme.ts b/packages/base-ui/src/views/theme.tssimilarity index 74%rename from packages/core/src/services/theme/theme.tsrename to packages/base-ui/src/views/theme.tsindex 8ebdbb05aa..6452c22f9f 100644--- a/packages/core/src/services/theme/theme.ts+++ b/packages/base-ui/src/views/theme.ts@@ -1,6 +1,4 @@-export interface IStyleSheet {- [key: string]: string;-}+import { IStyleSheet } from '@univerjs/core';function convertToDashCase(input: string): string {const dashCase = input.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`).replace(/(\d+)/g, '-$1');@@ -8,6 +6,19 @@ function convertToDashCase(input: string): string {return `--${dashCase}`;}+function convertHexToRgb(input: string): string {+ if (input.startsWith('#')) {+ const hex = input.replace('#', '');+ const r = parseInt(hex.substring(0, 2), 16);+ const g = parseInt(hex.substring(2, 4), 16);+ const b = parseInt(hex.substring(4, 6), 16);++ return `${r}, ${g}, ${b}`;+ }++ return input;+}+class Theme {private styleSheet;@@ -41,16 +52,14 @@ class Theme {* before: {--primary-color:"#0188fb",--primary-color-hover:"#5391ff"}* after: {--primary-color:#0188fb;--primary-color-hover:#5391ff;}*/-- let currentSkin = theme;- currentSkin = Object.fromEntries(- Object.keys(theme).map((item) => [convertToDashCase(item), currentSkin[item]])+ const currentTheme = Object.fromEntries(+ Object.keys(theme).map((item) => [convertToDashCase(item), convertHexToRgb(theme[item])]));// 3. insert new theme// TODO: CSS selector should be configurablethis.styleSheet.insertRule(- `:root ${JSON.stringify(currentSkin)+ `:root ${JSON.stringify(currentTheme).replace(/"/g, '').replace(/,(?=--)/g, ';')}`);diff --git a/packages/core/src/Types/Interfaces/IUniverData.ts b/packages/core/src/Types/Interfaces/IUniverData.tsindex de3e9f5aac..eeb848fa82 100644--- a/packages/core/src/Types/Interfaces/IUniverData.ts+++ b/packages/core/src/Types/Interfaces/IUniverData.ts@@ -1,4 +1,4 @@-import { IStyleSheet } from '../../services/theme/theme';+import { IStyleSheet } from '../../services/theme/theme.service';import { ILocales } from '../../Shared/Locale';import { LocaleType } from '../Enum';diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex c697efc2f3..50c1294dea 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -30,7 +30,7 @@ export {type ISheetLocation,SheetInterceptorService,} from './services/sheet-interceptor/sheet-interceptor.service';-export { ThemeService } from './services/theme/theme.service';+export { type IStyleSheet, ThemeService } from './services/theme/theme.service';export {type IUndoRedoCommandInfos,IUndoRedoService,diff --git a/packages/core/src/services/theme/theme.service.ts b/packages/core/src/services/theme/theme.service.tsindex a87568e84c..3442bded2d 100644--- a/packages/core/src/services/theme/theme.service.ts+++ b/packages/core/src/services/theme/theme.service.ts@@ -2,7 +2,10 @@ import { BehaviorSubject, Observable } from 'rxjs';import { Nullable } from '../../common/type-utils';import { Disposable, toDisposable } from '../../Shared/lifecycle';-import { IStyleSheet, themeInstance } from './theme';++export interface IStyleSheet {+ [key: string]: string;+}export class ThemeService extends Disposable {private currentTheme: Nullable<IStyleSheet>;@@ -36,7 +39,6 @@ export class ThemeService extends Disposable {setDarkMode(flag: boolean) {}setTheme(theme: IStyleSheet) {- themeInstance.setTheme(theme);this.currentTheme = theme;this._currentTheme$.next(theme);}diff --git a/packages/sheets-plugin-debugger/src/commands/operations/i18n.operation.ts b/packages/sheets-plugin-debugger/src/commands/operations/i18n.operation.tsdeleted file mode 100644index 4ea8378ede..0000000000--- a/packages/sheets-plugin-debugger/src/commands/operations/i18n.operation.ts+++ /dev/null@@ -1,18 +0,0 @@-import { CommandType, ICommand, LocaleType } from '@univerjs/core';-import { IAccessor } from '@wendellhu/redi';--import { I18nService } from '../../services/i18n.service';--export interface II18nCommandParams {- value: LocaleType;-}--export const I18nOperation: ICommand = {- id: 'debugger.operation.locale',- type: CommandType.COMMAND,- handler: async (accessor: IAccessor, params: II18nCommandParams) => {- const localeService = accessor.get(I18nService);- localeService.setI18n(params.value);- return true;- },-};diff --git a/packages/sheets-plugin-debugger/src/commands/operations/locale.operation.ts b/packages/sheets-plugin-debugger/src/commands/operations/locale.operation.tsnew file mode 100644index 0000000000..bf6321e19d--- /dev/null+++ b/packages/sheets-plugin-debugger/src/commands/operations/locale.operation.ts@@ -0,0 +1,18 @@+import { CommandType, ICommand, LocaleType } from '@univerjs/core';+import { IAccessor } from '@wendellhu/redi';++import { LocaleService } from '../../services/locale.service';++export interface ILocaleCommandParams {+ value: LocaleType;+}++export const LocaleOperation: ICommand = {+ id: 'debugger.operation.locale',+ type: CommandType.COMMAND,+ handler: async (accessor: IAccessor, params: ILocaleCommandParams) => {+ const localeService = accessor.get(LocaleService);+ localeService.setLocale(params.value);+ return true;+ },+};diff --git a/packages/sheets-plugin-debugger/src/commands/operations/theme.operation.ts b/packages/sheets-plugin-debugger/src/commands/operations/theme.operation.tsnew file mode 100644index 0000000000..fef938d97d--- /dev/null+++ b/packages/sheets-plugin-debugger/src/commands/operations/theme.operation.ts@@ -0,0 +1,19 @@+import { CommandType, ICommand, IStyleSheet } from '@univerjs/core';+import { IAccessor } from '@wendellhu/redi';++import { ThemeService } from '../../services/theme.service';++export interface IThemeCommandParams {+ value?: IStyleSheet;+}++export const ThemeOperation: ICommand = {+ id: 'debugger.operation.theme',+ type: CommandType.COMMAND,+ handler: async (accessor: IAccessor, params: IThemeCommandParams) => {+ const themeService = accessor.get(ThemeService);++ params.value && themeService.setTheme(params.value);+ return true;+ },+};diff --git a/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts b/packages/sheets-plugin-debugger/src/controllers/debugger.controller.tsindex 373cb8b919..61ec883a8c 100644--- a/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts+++ b/packages/sheets-plugin-debugger/src/controllers/debugger.controller.ts@@ -2,8 +2,9 @@ import { IMenuService } from '@univerjs/base-ui';import { Disposable, ICommandService } from '@univerjs/core';import { Inject, Injector } from '@wendellhu/redi';-import { I18nOperation } from '../commands/operations/i18n.operation';-import { DebuggerMenuItemFactory } from './menu';+import { LocaleOperation } from '../commands/operations/locale.operation';+import { ThemeOperation } from '../commands/operations/theme.operation';+import { LocaleMenuItemFactory, ThemeMenuItemFactory } from './menu';export class DebuggerController extends Disposable {constructor(@@ -14,11 +15,12 @@ export class DebuggerController extends Disposable {super();this._initializeContextMenu();- [I18nOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));+ [LocaleOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));+ [ThemeOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}private _initializeContextMenu() {- [DebuggerMenuItemFactory].forEach((factory) => {+ [LocaleMenuItemFactory, ThemeMenuItemFactory].forEach((factory) => {this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));});}diff --git a/packages/sheets-plugin-debugger/src/controllers/menu.ts b/packages/sheets-plugin-debugger/src/controllers/menu.tsindex d8ac737de7..a95be7a207 100644--- a/packages/sheets-plugin-debugger/src/controllers/menu.ts+++ b/packages/sheets-plugin-debugger/src/controllers/menu.ts@@ -1,11 +1,20 @@-import { DisplayTypes, IMenuSelectorItem, MenuItemType, MenuPosition, SelectTypes } from '@univerjs/base-ui';+import {+ defaultTheme,+ DisplayTypes,+ greenTheme,+ IMenuSelectorItem,+ MenuItemType,+ MenuPosition,+ SelectTypes,+} from '@univerjs/base-ui';import { IAccessor } from '@wendellhu/redi';-import { I18nOperation } from '../commands/operations/i18n.operation';+import { LocaleOperation } from '../commands/operations/locale.operation';+import { ThemeOperation } from '../commands/operations/theme.operation';-export function DebuggerMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {+export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {return {- id: I18nOperation.id,+ id: LocaleOperation.id,icon: 'ShortcutIcon',title: 'debugger.locale.title',tooltip: 'debugger.locale.tooltip',@@ -25,3 +34,26 @@ export function DebuggerMenuItemFactory(accessor: IAccessor): IMenuSelectorItem],};}++export function ThemeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {+ return {+ id: ThemeOperation.id,+ icon: 'ShortcutIcon',+ title: 'debugger.theme.title',+ tooltip: 'debugger.theme.tooltip',+ display: DisplayTypes.ICON,+ type: MenuItemType.SELECTOR,+ selectType: SelectTypes.NEO,+ positions: [MenuPosition.TOOLBAR],+ selections: [+ {+ label: 'green',+ value: greenTheme,+ },+ {+ label: 'default',+ value: defaultTheme,+ },+ ],+ };+}diff --git a/packages/sheets-plugin-debugger/src/debugger-plugin.ts b/packages/sheets-plugin-debugger/src/debugger-plugin.tsindex e7609b6baa..13d6fe476a 100644--- a/packages/sheets-plugin-debugger/src/debugger-plugin.ts+++ b/packages/sheets-plugin-debugger/src/debugger-plugin.ts@@ -1,9 +1,10 @@-import { LocaleService, Plugin, PluginType } from '@univerjs/core';+import { LocaleService as _LocaleService, Plugin, PluginType } from '@univerjs/core';import { Inject, Injector } from '@wendellhu/redi';import { DebuggerController } from './controllers/debugger.controller';import { en } from './locale';-import { I18nService } from './services/i18n.service';+import { LocaleService } from './services/locale.service';+import { ThemeService } from './services/theme.service';export interface IDebuggerPluginConfig {}@@ -15,7 +16,7 @@ export class DebuggerPlugin extends Plugin {constructor(config: IDebuggerPluginConfig,@Inject(Injector) override readonly _injector: Injector,- @Inject(LocaleService) private readonly _localeService: LocaleService+ @Inject(_LocaleService) private readonly _localeService: _LocaleService) {super('debugger');}@@ -30,7 +31,8 @@ export class DebuggerPlugin extends Plugin {this._debuggerController = this._injector.createInstance(DebuggerController);this._injector.add([DebuggerController, { useValue: this._debuggerController }]);- this._injector.add([I18nService]);+ this._injector.add([LocaleService]);+ this._injector.add([ThemeService]);this.registerExtension();}diff --git a/packages/sheets-plugin-debugger/src/locale/en.ts b/packages/sheets-plugin-debugger/src/locale/en.tsindex 4fab9a241b..8c777ff355 100644--- a/packages/sheets-plugin-debugger/src/locale/en.ts+++ b/packages/sheets-plugin-debugger/src/locale/en.ts@@ -4,5 +4,9 @@ export default {title: 'Language (Debugger Tools)',tooltip: 'Language (Debugger Tools)',},+ theme: {+ title: 'Theme (Debugger Tools)',+ tooltip: 'Theme (Debugger Tools)',+ },},};diff --git a/packages/sheets-plugin-debugger/src/locale/zh.ts b/packages/sheets-plugin-debugger/src/locale/zh.tsindex d33c9ef42e..4d153b3ccc 100644--- a/packages/sheets-plugin-debugger/src/locale/zh.ts+++ b/packages/sheets-plugin-debugger/src/locale/zh.ts@@ -4,5 +4,9 @@ export default {title: '语言 (调试工具)',tooltip: '语言 (调试工具)',},+ theme: {+ title: '主题 (调试工具)',+ tooltip: '主题 (调试工具)',+ },},};diff --git a/packages/sheets-plugin-debugger/src/services/i18n.service.ts b/packages/sheets-plugin-debugger/src/services/i18n.service.tsdeleted file mode 100644index df084ab788..0000000000--- a/packages/sheets-plugin-debugger/src/services/i18n.service.ts+++ /dev/null@@ -1,10 +0,0 @@-import { LocaleService, LocaleType } from '@univerjs/core';-import { Inject } from '@wendellhu/redi';--export class I18nService {- constructor(@Inject(LocaleService) private readonly _localeService: LocaleService) {}-- setI18n(locale: LocaleType) {- this._localeService.setLocale(locale);- }-}diff --git a/packages/sheets-plugin-debugger/src/services/locale.service.ts b/packages/sheets-plugin-debugger/src/services/locale.service.tsnew file mode 100644index 0000000000..c87693bc8f--- /dev/null+++ b/packages/sheets-plugin-debugger/src/services/locale.service.ts@@ -0,0 +1,10 @@+import { LocaleService as _LocaleService, LocaleType } from '@univerjs/core';+import { Inject } from '@wendellhu/redi';++export class LocaleService {+ constructor(@Inject(_LocaleService) private readonly _localeService: _LocaleService) {}++ setLocale(locale: LocaleType) {+ this._localeService.setLocale(locale);+ }+}diff --git a/packages/sheets-plugin-debugger/src/services/theme.service.ts b/packages/sheets-plugin-debugger/src/services/theme.service.tsnew file mode 100644index 0000000000..6d72d554d9--- /dev/null+++ b/packages/sheets-plugin-debugger/src/services/theme.service.ts@@ -0,0 +1,10 @@+import { IStyleSheet, ThemeService as _ThemeService } from '@univerjs/core';+import { Inject } from '@wendellhu/redi';++export class ThemeService {+ constructor(@Inject(_ThemeService) private readonly _themeService: _ThemeService) {}++ setTheme(theme: IStyleSheet) {+ this._themeService.setTheme(theme);+ }+}diff --git a/packages/ui-plugin-sheets/src/View/FormulaBar/index.module.less b/packages/ui-plugin-sheets/src/View/FormulaBar/index.module.lessindex 88b4cf613d..b387f861ea 100644--- a/packages/ui-plugin-sheets/src/View/FormulaBar/index.module.less+++ b/packages/ui-plugin-sheets/src/View/FormulaBar/index.module.less@@ -1,8 +1,8 @@.formula-box {height: 40px;padding: 0 var(--padding-xl);- background: var(--bg-color-secondary);- border-bottom: 1px solid var(--border-color);+ background: rgb(var(--bg-color-secondary));+ border-bottom: 1px solid rgb(var(--border-color));box-sizing: border-box;display: flex;diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/index.module.less b/packages/ui-plugin-sheets/src/View/SheetContainer/index.module.lessindex 3582337c23..707919e948 100644--- a/packages/ui-plugin-sheets/src/View/SheetContainer/index.module.less+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/index.module.less@@ -3,7 +3,7 @@.sheet-container {height: 40px;padding: 0 @padding-xl;- border-top: 1px solid @border-color;+ border-top: 1px solid rgb(var(--border-color));box-sizing: border-box;display: flex;justify-content: space-between;