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.

fix(sheets-ui): optimize the style of SelectList in dark mode (#5538)

白熱95d63946327c
diff --git a/packages/engine-render/src/services/canvas-color.service.ts b/packages/engine-render/src/services/canvas-color.service.ts
index 7371344830..98f481d7c4 100644
--- a/packages/engine-render/src/services/canvas-color.service.ts
+++ b/packages/engine-render/src/services/canvas-color.service.ts
@@ -50,9 +50,6 @@ export class CanvasColorService extends Disposable implements ICanvasColorServic
return color;
}
- // TODO: if the color is background color from _themeService: do not invert it.
- // Or maybe there should be a whitelist.
-
if (this._cache.has(color)) {
return this._cache.get(color)!;
}
diff --git a/packages/sheets-ui/src/views/dropdown/list-dropdown/index.tsx b/packages/sheets-ui/src/views/dropdown/list-dropdown/index.tsx
index c2b48332cb..03cc92534d 100644
--- a/packages/sheets-ui/src/views/dropdown/list-dropdown/index.tsx
+++ b/packages/sheets-ui/src/views/dropdown/list-dropdown/index.tsx
@@ -20,11 +20,23 @@ import type { ISheetLocation } from '@univerjs/sheets';
import type { IPopup } from '@univerjs/ui';
import type { CSSProperties } from 'react';
import type { IBaseDropdownProps } from '../type';
-import { BuildTextUtils, ICommandService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';
+import {
+ BuildTextUtils,
+ ColorKit,
+ ICommandService,
+ IUniverInstanceService,
+ LocaleService,
+ UniverInstanceType,
+} from '@univerjs/core';
import { borderClassName, clsx, scrollbarClassName } from '@univerjs/design';
import { RichTextEditingMutation } from '@univerjs/docs';
import { CheckMarkIcon } from '@univerjs/icons';
-import { RangeProtectionPermissionEditPoint, SheetPermissionCheckController, WorkbookEditablePermission, WorksheetEditPermission } from '@univerjs/sheets';
+import {
+ RangeProtectionPermissionEditPoint,
+ SheetPermissionCheckController,
+ WorkbookEditablePermission,
+ WorksheetEditPermission,
+} from '@univerjs/sheets';
import { RectPopup, useDependency } from '@univerjs/ui';
import { useEffect, useMemo, useState } from 'react';
import { IEditorBridgeService } from '../../../services/editor-bridge.service';
@@ -106,6 +118,9 @@ const SelectList = (props: ISelectListProps) => {
};
const index = item.label.toLocaleLowerCase().indexOf(lowerFilter!);
+
+ const isDark = new ColorKit(item.color).isDark();
+
return (
<div
key={i}
@@ -118,10 +133,14 @@ const SelectList = (props: ISelectListProps) => {
onClick={handleClick}
>
<div
- className={`
+ className={clsx(`
univer-h-4 univer-w-fit univer-flex-[0_1_auto] univer-overflow-hidden univer-truncate
- univer-whitespace-nowrap univer-rounded-lg univer-px-1 univer-py-0 univer-text-xs
- `}
+ univer-whitespace-nowrap univer-rounded-full univer-px-1.5 univer-py-0.5
+ univer-text-xs
+ `, {
+ 'univer-text-gray-900': !isDark,
+ 'univer-text-white': isDark,
+ })}
style={{ background: item.color }}
>
{lowerFilter && item.label.toLowerCase().includes(lowerFilter)