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.

refactor(sheets-ui): refactor sheetbar styles (#5135)

Wenzhao Hu3157f941c201
diff --git a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png
index 6468716fb0..b30552dc06 100644
Binary files a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png
index d6a0e89299..f14f5c930e 100644
Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/dark-mode-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png
index 03e06c1b49..e789059066 100644
Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png differ
diff --git a/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx b/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx
index 0bcb100c49..f8546a4735 100644
--- a/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx
+++ b/packages/sheets-ui/src/views/cell-alert/CellAlertPopup.tsx
@@ -16,10 +16,8 @@
import type { ICanvasPopup } from '../../services/canvas-pop-manager.service';
import type { ICellAlert } from '../../services/cell-alert-manager.service';
-import { clsx } from '@univerjs/design';
import { ErrorSingle, WarningSingle } from '@univerjs/icons';
import { CellAlertType } from '../../services/cell-alert-manager.service';
-import styles from './index.module.less';
/**
*
@@ -35,18 +33,29 @@ export function CellAlert({ popup }: { popup: ICanvasPopup }) {
const { type, title, message } = alert as ICellAlert;
const iconMap = {
- [CellAlertType.ERROR]: <ErrorSingle className={clsx(styles.cellAlertIcon, styles.cellAlertIconError)} />,
- [CellAlertType.INFO]: <WarningSingle className={clsx(styles.cellAlertIcon, styles.cellAlertIconInfo)} />,
- [CellAlertType.WARNING]: <WarningSingle className={clsx(styles.cellAlertIcon, styles.cellAlertIconWarning)} />,
+ [CellAlertType.ERROR]: <ErrorSingle className="univer-mr-1.5 univer-text-red-400" />,
+ [CellAlertType.INFO]: <WarningSingle className="univer-mr-1.5 univer-text-blue-500" />,
+ [CellAlertType.WARNING]: <WarningSingle className="univer-mr-1.5 univer-text-orange-400" />,
};
return (
- <div className={styles.cellAlert}>
- <div className={styles.cellAlertTitle}>
+ <div
+ className={`
+ univer-z-[100] univer-box-border univer-w-[156px] univer-rounded-lg univer-bg-white univer-px-2
+ univer-py-1 univer-text-black univer-shadow
+ dark:univer-bg-black dark:univer-text-white
+ `}
+ >
+ <div
+ className={`
+ univer-mb-1.5 univer-flex univer-h-5 univer-flex-row univer-items-center univer-text-sm
+ univer-font-medium
+ `}
+ >
{type ? iconMap[type] : null}
{title}
</div>
- <div className={styles.cellAlertContent}>{message}</div>
+ <div className="univer-text-sm">{message}</div>
</div>
);
}
diff --git a/packages/sheets-ui/src/views/cell-alert/index.module.less b/packages/sheets-ui/src/views/cell-alert/index.module.less
deleted file mode 100644
index 3cdf78be96..0000000000
--- a/packages/sheets-ui/src/views/cell-alert/index.module.less
+++ /dev/null
@@ -1,41 +0,0 @@
-.cell-alert {
- box-sizing: border-box;
- box-shadow: var(--box-shadow-base);
- padding: var(--padding-sm) var(--padding-base);
- border-radius: var(--border-radius-lg);
- color: rgba(var(--color-black));
- background: rgba(var(--color-white));
- z-index: 100;
- width: 156px;
-
- &-title {
- height: 20px;
- font-size: var(--font-size-sm);
- font-weight: 500;
- display: flex;
- flex-direction: row;
- align-items: center;
- margin-bottom: 6px;
- line-height: 20px;
- }
-
- &-icon {
- margin-right: 6px;
- }
-
- &-icon-error {
- color: rgba(var(--red-400));
- }
-
- &-icon-info {
- color: rgba(var(--blue-500));
- }
-
- &-icon-warning {
- color: rgba(var(--gold-400));
- }
-
- &-content {
- font-size: var(--font-size-sm);
- }
-}
diff --git a/packages/sheets-ui/src/views/clipboard/ClipboardPopupMenu.tsx b/packages/sheets-ui/src/views/clipboard/ClipboardPopupMenu.tsx
index e67e69d95e..403b1a5e4c 100644
--- a/packages/sheets-ui/src/views/clipboard/ClipboardPopupMenu.tsx
+++ b/packages/sheets-ui/src/views/clipboard/ClipboardPopupMenu.tsx
@@ -17,19 +17,17 @@
import type { IDiscreteRange } from '../../controllers/utils/range-tools';
import type { IPasteHookKeyType } from '../../services/clipboard/type';
import { ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
-import { clsx, Dropdown } from '@univerjs/design';
+import { Dropdown } from '@univerjs/design';
import { convertTransformToOffsetX, convertTransformToOffsetY, IRenderManagerService } from '@univerjs/engine-render';
import { CheckMarkSingle, MoreDownSingle, PasteSpecial } from '@univerjs/icons';
import { useDependency, useObservable } from '@univerjs/ui';
import { useState } from 'react';
import { SheetOptionalPasteCommand } from '../../commands/commands/clipboard.command';
import { useActiveWorkbook } from '../../components/hook';
-// import { SheetClipboardController } from '../../controllers/clipboard/clipboard.controller';
import { getSheetObject } from '../../controllers/utils/component-tools';
import { ISheetClipboardService, PREDEFINED_HOOK_NAME } from '../../services/clipboard/clipboard.service';
import { ISheetSelectionRenderService } from '../../services/selection/base-selection-render.service';
import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';
-import styles from './index.module.less';
const DEFAULT_PADDING = 2;
@@ -138,7 +136,11 @@ export const ClipboardPopupMenu = () => {
return (
<div
- className={styles.sheetPasteOptionsWrapper}
+ className={`
+ univer-absolute univer-cursor-pointer univer-items-center univer-justify-center univer-rounded
+ univer-border univer-border-solid univer-border-gray-200 univer-p-1
+ dark:univer-border-gray-700
+ `}
style={{
left: relativePosition.positionX + DEFAULT_PADDING,
top: relativePosition.positionY + DEFAULT_PADDING,
@@ -149,9 +151,11 @@ export const ClipboardPopupMenu = () => {
<Dropdown
overlay={(
<div
- className={clsx(styles.sheetPasteOptionsMenu, `
- univer-border univer-border-solid univer-border-gray-200 univer-opacity-100
- `)}
+ // TODO: a query here?
+ className={`
+ univer-border univer-border-solid univer-border-gray-200 univer-opacity-100 univer-shadow
+ dark:univer-border-gray-700
+ `}
>
<ul>
{SheetPasteOptions.map((item) => {
@@ -160,18 +164,24 @@ export const ClipboardPopupMenu = () => {
return (
<li
key={item.value}
- className={clsx(styles.sheetPasteOptionsMenuItem, 'hover:univer-bg-neutral-100')}
+ className={`
+ univer-rounded univer-border univer-border-solid univer-border-gray-200
+ univer-shadow
+ dark:univer-border-gray-700
+ hover:univer-bg-neutral-100
+ `}
onClick={() => handleClick(item.value)}
>
<span>
{selected && (
- <CheckMarkSingle className={styles.sheetPasteOptionsMenuItemIcon} style={{ color: 'rgb(var(--green-700, #409f11))' }} />
+ <CheckMarkSingle className="univer-absolute" style={{ color: 'rgb(var(--green-700, #409f11))' }} />
)}
</span>
<div
- className={clsx(styles.sheetPasteOptionsMenuItemTitle, `
- univer-text-gray-700
- `)}
+ className={`
+ univer-ml-5 univer-text-sm univer-text-gray-700
+ dark:univer-text-white
+ `}
>
{localeService.t(item.label)}
</div>
@@ -186,7 +196,11 @@ export const ClipboardPopupMenu = () => {
>
<div
- className={styles.sheetPasteOptionsIconWrapper}
+ className={`
+ univer-flex univer-cursor-pointer univer-content-center univer-items-center univer-rounded
+ univer-border univer-border-solid univer-border-gray-200 univer-py-1
+ dark:univer-border-gray-700
+ `}
onClick={() => {
setMenuVisible(!menuVisible);
}}
diff --git a/packages/sheets-ui/src/views/clipboard/index.module.less b/packages/sheets-ui/src/views/clipboard/index.module.less
deleted file mode 100644
index 55c13243e4..0000000000
--- a/packages/sheets-ui/src/views/clipboard/index.module.less
+++ /dev/null
@@ -1,51 +0,0 @@
-.sheet-paste-options {
- &-wrapper {
- position: absolute;
- display: flex;
- background-color: #fff;
- z-index: 10;
- border-radius: 4px;
- }
-
- &-icon-wrapper {
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- border: 1px solid rgb(var(--grey-200, #e5e5e5));
- border-radius: 4px;
- padding: 3px;
- }
-
- &-menu {
- ul {
- list-style-type: none;
- padding: 0;
- margin: 8px;
- }
-
- border: 1px solid rgb(var(--grey-200, #e5e5e5));
- box-shadow: var(--box-shadow-base);
- border-radius: 4px;
-
- &-item {
- padding: 8px 4px;
- cursor: pointer;
- position: relative;
-
- &:hover {
- background-color: rgb(var(--grey-100, #f5f5f5));
- }
-
- &-title {
- font-size: 13px;
- color: rgb(var(--black, #35322b));
- margin-left: 20px;
- }
-
- &-icon {
- position: absolute;
- }
- }
- }
-}
diff --git a/packages/sheets-ui/src/views/count-bar/index.module.less b/packages/sheets-ui/src/views/count-bar/index.module.less
deleted file mode 100644
index 8f35045f9d..0000000000
--- a/packages/sheets-ui/src/views/count-bar/index.module.less
+++ /dev/null
@@ -1,5 +0,0 @@
-.count-bar {
- display: flex;
- flex: 0 0 260px;
- justify-content: flex-end;
-}
diff --git a/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx b/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx
index 245b382eda..1b713aeebc 100644
--- a/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx
+++ b/packages/sheets-ui/src/views/defined-name/DefinedNameOverlay.tsx
@@ -26,11 +26,7 @@ import React, { useEffect, useState } from 'react';
import { SidebarDefinedNameOperation } from '../../commands/operations/sidebar-defined-name.operation';
import { DEFINED_NAME_CONTAINER } from './component-name';
-export interface IDefinedNameOverlayProps {
-
-}
-
-export function DefinedNameOverlay(props: IDefinedNameOverlayProps) {
+export function DefinedNameOverlay() {
const commandService = useDependency(ICommandService);
const localeService = useDependency(LocaleService);
const definedNamesService = useDependency(IDefinedNamesService);
diff --git a/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx b/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx
index 0c61c4a827..725734bd5d 100644
--- a/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx
+++ b/packages/sheets-ui/src/views/editor-container/EditorContainer.tsx
@@ -26,7 +26,6 @@ import { EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY } from '../../common/keys';
import { IEditorBridgeService } from '../../services/editor-bridge.service';
import { ICellEditorManagerService } from '../../services/editor/cell-editor-manager.service';
import { useKeyEventConfig } from './hooks';
-import styles from './index.module.less';
interface ICellIEditorProps { }
@@ -138,7 +137,11 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
return (
<div
- className={styles.editorContainer}
+ className={`
+ univer-absolute univer-z-10 univer-top-[200px] univer-left-[100px] univer-flex univer-w-[100px]
+ univer-h-[50px] univer-border univer-border-solid univer-border-gray-100
+ dark:univer-bg-gray-700
+ `}
style={{
left: state.left,
top: state.top,
@@ -149,7 +152,10 @@ export const EditorContainer: React.FC<ICellIEditorProps> = () => {
{FormulaEditor && (
<FormulaEditor
editorId={DOCS_NORMAL_EDITOR_UNIT_ID_KEY}
- className={styles.editorInput}
+ className={`
+ univer-relative univer-flex univer-w-full univer-h-full
+ [&_*canvas]:univer-absolute
+ `}
initValue=""
onChange={() => {}}
isFocus={visible?.visible}
diff --git a/packages/sheets-ui/src/views/editor-container/index.module.less b/packages/sheets-ui/src/views/editor-container/index.module.less
deleted file mode 100644
index 19c13f673a..0000000000
--- a/packages/sheets-ui/src/views/editor-container/index.module.less
+++ /dev/null
@@ -1,28 +0,0 @@
-.editor-container {
- position: absolute;
- z-index: 10;
- top: 200px;
- left: 100px;
- display: flex;
- width: 100px;
- height: 50px;
-
- border: 1px solid rgb(var(--primary-color));
- box-shadow: none;
- box-sizing: content-box;
-
- .editor-input {
- position: relative;
- display: flex;
- width: 100%;
- height: 100%;
-
- // Do not set a color, it should be transparent.
- // create a rendering editor canvas may took 200ms, there would be a white flash if rendering have not finished.
- // background: white;
-
- canvas {
- position: absolute;
- }
- }
-}
diff --git a/packages/sheets-ui/src/views/mobile/sheet-bar/MobileSheetBar.tsx b/packages/sheets-ui/src/views/mobile/sheet-bar/MobileSheetBar.tsx
index 8cee774efd..a015e42281 100644
--- a/packages/sheets-ui/src/views/mobile/sheet-bar/MobileSheetBar.tsx
+++ b/packages/sheets-ui/src/views/mobile/sheet-bar/MobileSheetBar.tsx
@@ -30,7 +30,6 @@ import {
import { useDependency } from '@univerjs/ui';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useActiveWorkbook } from '../../../components/hook';
-import styles from './index.module.less';
export function MobileSheetBar() {
const workbook = useActiveWorkbook();
@@ -107,14 +106,26 @@ function MobileSheetBarImpl(props: { workbook: Workbook }) {
}, [commandService, updateSheetItems]);
return (
- <div className={styles.mobileSheetBarContainer}>
- <div className={styles.mobileSheetBarSlider}>
+ <div
+ className={`
+ univer-w-full univer-overflow-x-scroll univer-h-8 univer-bg-gray-100
+ dark:univer-bg-gray-900
+ `}
+ >
+ <div className="univer-flex univer-flex-nowrap univer-items-center univer-h-8">
{sheetList.map((sheet) => (
<div
className={clsx(
- styles.mobileSheetBarItem,
+ `
+ univer-items-center univer-box-border univer-shrink-0 univer-flex-nowrap univer-text-xs
+ univer-h-full univer-min-w-12 univer-overflow-hidden univer-py-0.5 univer-px-1
+ univer-text-center univer-whitespace-nowrap univer-border-0 univer-border-r
+ univer-border-solid univer-border-r-gray-200 univer-truncate univer-max-w-[120px]
+ univer-leading-7
+ dark:univer-border-r-gray-700
+ `,
{
- [styles.mobileSheetBarItemActivated]: sheet.sheetId === activeKey,
+ 'univer-text-primary-600 univer-bg-white dark:univer-bg-slate-600': sheet.sheetId === activeKey,
}
)}
key={sheet.sheetId}
diff --git a/packages/sheets-ui/src/views/mobile/sheet-bar/index.module.less b/packages/sheets-ui/src/views/mobile/sheet-bar/index.module.less
deleted file mode 100644
index 929e78f324..0000000000
--- a/packages/sheets-ui/src/views/mobile/sheet-bar/index.module.less
+++ /dev/null
@@ -1,40 +0,0 @@
-.mobile-sheet-bar {
- &-container {
- width: 100%;
- overflow-x: scroll;
- height: 32px;
- background-color: rgb(var(--bg-color));
- }
-
- &-slider {
- display: flex;
- flex-wrap: nowrap;
- align-items: center;
- height: 32px;
- }
-
- &-item {
- align-items: center;
- box-sizing: border-box;
- flex-grow: 1;
- flex-shrink: 0;
- flex-wrap: nowrap;
- font-size: 12px;
- height: 100%;
- line-height: 28px;
- min-width: 48px;
- overflow: hidden;
- padding: 2px 4px;
- text-align: center;
- white-space: nowrap;
- border-right: 1px solid rgb(var(--border-color));
- background-color: rgb(var(--bg-color));
- text-overflow: ellipsis;
- max-width: 120px;
-
- &.mobile-sheet-bar-item-activated {
- color: rgb(var(--primary-color));
- background-color: rgb(var(--bg-color-secondary));
- }
- }
-}
diff --git a/packages/sheets-ui/src/views/permission/spin/index.module.less b/packages/sheets-ui/src/views/permission/spin/index.module.less
deleted file mode 100644
index e666a34363..0000000000
--- a/packages/sheets-ui/src/views/permission/spin/index.module.less
+++ /dev/null
@@ -1,42 +0,0 @@
-.spin-container {
- position: relative;
- width: 100%;
- height: 100%;
-}
-
-.spin-overlay {
- position: absolute;
- top: -2px;
- left: -2px;
- right: -2px;
- bottom: -2px;
- display: flex;
- justify-content: center;
- align-items: center;
- backdrop-filter: blur(10px);
- background-color: rgba(255, 255, 255, 0.5);
- z-index: 10;
-}
-
-.spinner {
- width: 40px;
- height: 40px;
- border: 4px solid #f3f3f3;
- border-top: 4px solid #3498db;
- border-radius: 50%;
- animation: spin 2s linear infinite;
-}
-
-.content-blur {
- filter: blur(2px);
- pointer-events: none;
-}
-
-@keyframes spin {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
-}
diff --git a/packages/sheets-ui/src/views/permission/spin/index.tsx b/packages/sheets-ui/src/views/permission/spin/index.tsx
index 2d93fc0c8d..0c03a27c5d 100644
--- a/packages/sheets-ui/src/views/permission/spin/index.tsx
+++ b/packages/sheets-ui/src/views/permission/spin/index.tsx
@@ -15,7 +15,9 @@
*/
import React from 'react';
-import styles from './index.module.less';
+
+// TODO@jikkai: this component should be moved to the design package
+// so it could be reused.
interface ISpinProps {
loading: boolean;
@@ -24,13 +26,25 @@ interface ISpinProps {
const Spin = ({ loading, children }: ISpinProps) => {
return (
- <div className={styles.spinContainer}>
+ <div className="univer-relative univer-h-full univer-w-full">
{loading && (
- <div className={styles.spinOverlay}>
- <div className={styles.spinner} />
+ <div
+ className={`
+ univer-absolute -univer-bottom-0.5 -univer-left-0.5 -univer-right-0.5 -univer-top-0.5 univer-z-10
+ univer-flex univer-items-center univer-justify-center univer-bg-white univer-backdrop-blur
+ dark:univer-bg-black
+ `}
+ >
+ <div
+ className={`
+ univer-size-10 univer-animate-spin univer-rounded-full univer-border-4 univer-border-solid
+ univer-border-gray-100 univer-border-t-primary-500
+ `}
+ />
+
</div>
)}
- <div className={loading ? styles.contentBlur : ''}>
+ <div className={loading ? 'univer-pointer-events-none univer-blur-sm' : ''}>
{children}
</div>
</div>
diff --git a/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx b/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx
index 57cc313286..bee7e3c2ec 100644
--- a/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/SheetBar.tsx
@@ -78,7 +78,11 @@ export const SheetBar = () => {
<div className="univer-relative univer-flex univer-h-full univer-min-w-0 univer-flex-1">
<div className="univer-flex univer-items-center univer-pl-2">
{/* Add sheet button */}
- <SheetBarButton onClick={addSheet} disabled={!(workbookCreateSheetPermission?.value && workbookEditablePermission?.value)}>
+ <SheetBarButton
+ className="univer-mr-2"
+ onClick={addSheet}
+ disabled={!(workbookCreateSheetPermission?.value && workbookEditablePermission?.value)}
+ >
<IncreaseSingle />
</SheetBarButton>
{/* All sheets button */}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/SheetBarButton.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/SheetBarButton.tsx
index ffb6ba8a53..7a5fc8ea50 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/SheetBarButton.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/SheetBarButton.tsx
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import React from 'react';
+import { Button } from '@univerjs/design';
-import styles from './index.module.less';
+import React from 'react';
export interface IBaseSheetBarButtonProps {
children?: React.ReactNode;
@@ -53,16 +53,8 @@ export function SheetBarButton(props: IBaseSheetBarButtonProps) {
};
return (
- <button
- data-u-comp="sheet-bar-append-button"
- className={styles.sheetBarBtn}
- type="button"
- style={style}
- disabled={disabled}
- onClick={handleClick}
- {...restProps}
- >
+ <Button data-u-comp="sheet-bar-append-button" size="small" disabled={disabled} onClick={handleClick} style={style} {...restProps} variant="text" className={className}>
{children}
- </button>
+ </Button>
);
}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/index.module.less b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/index.module.less
deleted file mode 100644
index aac7595c8c..0000000000
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-button/index.module.less
+++ /dev/null
@@ -1,30 +0,0 @@
-@sheet-bar-btn-size: 24px;
-
-.sheet-bar-btn {
- cursor: pointer;
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: @sheet-bar-btn-size;
- height: @sheet-bar-btn-size;
- padding: 0;
-
- font-size: var(--font-size-lg);
- color: rgb(var(--text-color-secondary-darker));
-
- background-color: transparent;
- border: none;
- border-radius: var(--border-radius-base);
- outline: none;
-
- &:not([disabled]):hover {
- background-color: rgb(var(--bg-color-hover));
- }
-
- &[disabled] {
- cursor: not-allowed;
- color: rgb(var(--grey-200));
- }
-}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx
index 1e8dbc6058..68922f9208 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx
@@ -16,11 +16,10 @@
import type { BooleanNumber } from '@univerjs/core';
import { ColorKit, ThemeService } from '@univerjs/core';
+import { clsx } from '@univerjs/design';
import { useDependency } from '@univerjs/ui';
import React, { useEffect, useState } from 'react';
-import styles from './index.module.less';
-
export interface IBaseSheetBarProps {
label?: React.ReactNode;
children?: any[];
@@ -53,14 +52,23 @@ export function SheetBarItem(props: IBaseSheetBarProps) {
return (
<div
+ data-u-comp="slide-tab-item"
key={sheetId}
data-id={sheetId}
- className={currentSelected
+ className={clsx(`
+ univer-mx-1 univer-box-border univer-flex univer-flex-grow univer-cursor-pointer univer-select-none
+ univer-flex-row univer-items-center univer-rounded univer-text-xs univer-text-black
+ dark:univer-text-white
+ `, currentSelected
? `
- ${styles.slideTabActive}
- ${styles.slideTabItem}
+ univer-flex univer-justify-center univer-bg-white univer-font-bold univer-text-primary-700
+ univer-shadow-sm univer-transition-[box-shadow]
+ dark:univer-bg-black
`
- : styles.slideTabItem}
+ : `
+ dark:hover:univer-bg-gray-700
+ hover:univer-bg-gray-100
+ `)}
style={{
backgroundColor: !currentSelected && color ? color : '',
color: !currentSelected && color ? getTextColor(color) : '',
@@ -68,7 +76,14 @@ export function SheetBarItem(props: IBaseSheetBarProps) {
currentSelected && color ? `0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${color}` : '',
}}
>
- <div className={styles.slideTabDiv}>{label}</div>
+ <div
+ className={`
+ univer-box-border univer-flex univer-items-center univer-whitespace-nowrap univer-rounded
+ univer-border-2 univer-border-solid univer-border-transparent univer-py-1
+ `}
+ >
+ {label}
+ </div>
</div>
);
}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx
index 51173627ec..adb875af34 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx
@@ -43,7 +43,6 @@ import { merge } from 'rxjs';
import { useActiveWorkbook } from '../../../components/hook';
import { IEditorBridgeService } from '../../../services/editor-bridge.service';
import { ISheetBarService } from '../../../services/sheet-bar/sheet-bar.service';
-import styles from './index.module.less';
import { SheetBarItem } from './SheetBarItem';
import { SlideTabBar } from './utils/slide-tab-bar';
@@ -84,10 +83,10 @@ export function SheetBarTabs() {
? (
<>
<LockSingle />
- <span>{sheet.getName()}</span>
+ <span className="univer-outline-none">{sheet.getName()}</span>
</>
)
- : <span>{sheet.getName()}</span>;
+ : <span className="univer-outline-none">{sheet.getName()}</span>;
return {
sheetId: sheet.getSheetId(),
@@ -142,10 +141,8 @@ export function SheetBarTabs() {
const setupSlideTabBarInit = () => {
const slideTabBar = new SlideTabBar({
- slideTabBarClassName: styles.slideTabBar,
- slideTabBarItemActiveClassName: styles.slideTabActive,
- slideTabBarItemClassName: styles.slideTabItem,
- slideTabBarSpanEditClassName: styles.slideTabDivEdit,
+ slideTabBarSelector: '[data-u-comp=slide-tab-bar]',
+ slideTabBarItemSelector: '[data-u-comp=slide-tab-item]',
slideTabBarItemAutoSort: true,
slideTabBarContainer: slideTabBarContainerRef.current,
currentIndex: 0,
@@ -375,7 +372,7 @@ export function SheetBarTabs() {
const resizeInit = (slideTabBar: SlideTabBar) => {
// Target element
- const slideTabBarContainer = slideTabBarContainerRef.current?.querySelector(`.${styles.slideTabBar}`);
+ const slideTabBarContainer = slideTabBarContainerRef.current?.querySelector('[data-u-comp=slide-tab-bar]');
if (!slideTabBarContainer) return;
// Create a ResizeObserver
@@ -412,7 +409,7 @@ export function SheetBarTabs() {
return (
<DropdownLegacy
- className={styles.slideTabItemDropdown}
+ className="univer-select-none"
visible={visible}
align={{ offset }}
trigger={['contextMenu']}
@@ -429,12 +426,19 @@ export function SheetBarTabs() {
onVisibleChange={onVisibleChange}
>
<div
- className={styles.slideTabBarContainer}
+ className="univer-max-w-[calc(100%-112px)] univer-overflow-hidden"
ref={slideTabBarContainerRef}
onDragStart={(e) => e.preventDefault()}
onContextMenu={(e) => e.preventDefault()}
>
- <div className={styles.slideTabBar} style={{ boxShadow }}>
+ <div
+ data-u-comp="slide-tab-bar"
+ className={`
+ univer-flex univer-select-none univer-flex-row univer-items-center univer-overflow-hidden
+ univer-px-1.5 univer-py-1
+ `}
+ style={{ boxShadow }}
+ >
{sheetList.map((item) => (
<SheetBarItem {...item} key={item.sheetId} selected={activeKey === item.sheetId} />
))}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/index.module.less b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/index.module.less
deleted file mode 100644
index 93f40129be..0000000000
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/index.module.less
+++ /dev/null
@@ -1,85 +0,0 @@
-@tab-shadow: 0px 0 8px rgba(0, 0, 0, 0.08);
-@padding-left-right: 6px;
-
-.slide-tab-bar-container {
- overflow: hidden;
- max-width: calc(100% - 112px);
-
- .slide-tab-bar {
- user-select: none;
-
- overflow: hidden;
- display: flex;
- flex-direction: row;
- align-items: center;
-
- padding: var(--padding-xs) @padding-left-right;
-
- transition: box-shadow 0.2s;
- }
-}
-
-/**
-Tab Item, Put outside to be compatible with drag styles
-*/
-.slide-tab-item {
- cursor: pointer;
- user-select: none;
-
- display: flex;
- flex-direction: row;
- flex-grow: 1;
- align-items: center;
-
- box-sizing: border-box;
- margin: 0 var(--margin-xxs);
-
- font-size: var(--font-size-xs);
- line-height: 16px;
- color: rgb(var(--grey-1000));
-
- border-radius: var(--border-radius-base);
-
- &:not(.slide-tab-active):hover {
- background-color: rgb(var(--bg-color-hover));
- }
-
- .slide-tab-div {
- box-sizing: border-box;
- padding: var(--padding-xs) var(--padding-sm);
-
- white-space: nowrap;
-
- border: 2px solid transparent;
- border-radius: var(--border-radius-base);
- display: flex;
- align-items: center;
-
- &-edit {
- cursor: text;
- outline: none;
-
- &::selection {
- color: rgb(var(--color-white));
- background-color: rgb(var(--primary-color));
- }
- }
- }
-}
-
-.slide-tab-active {
- font-weight: 700;
- color: rgb(var(--primary-color));
-
- background-color: rgb(var(--bg-color-secondary));
- box-shadow: @tab-shadow;
-
- transition: box-shadow 0.2s;
- display: flex;
- justify-content: center;
-}
-
-.slide-tab-item-dropdown {
- user-select: none;
- min-width: auto !important;
-}
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts
index 0cfc02272a..9bb592dfc6 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts
@@ -20,11 +20,9 @@ export interface IScrollState {
leftEnd: boolean;
rightEnd: boolean;
}
-export interface SlideTabBarConfig {
- slideTabBarClassName: string;
- slideTabBarItemActiveClassName: string;
- slideTabBarItemClassName: string;
- slideTabBarSpanEditClassName: string;
+export interface ISlideTabBarConfig {
+ slideTabBarSelector: string;
+ slideTabBarItemSelector: string;
slideTabBarContainer: HTMLDivElement | null;
slideTabBarItemAutoSort: boolean;
currentIndex: number;
@@ -138,7 +136,6 @@ export class SlideTabItem {
input.removeEventListener('compositionend', compositionendAction);
input.removeEventListener('input', inputAction);
input.removeEventListener('keydown', keydownAction);
- input.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName);
}
// Event must be removed before updateItems
@@ -194,7 +191,6 @@ export class SlideTabItem {
input.addEventListener('compositionend', compositionendAction);
input.addEventListener('input', inputAction);
input.addEventListener('keydown', keydownAction);
- input.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName);
this._editMode = true;
SlideTabBar.keepSelectAll(input);
}
@@ -394,7 +390,7 @@ export class SlideTabBar {
protected _slideTabItems: SlideTabItem[] = [];
- protected _config: SlideTabBarConfig;
+ protected _config: ISlideTabBarConfig;
protected _downActionX: number = 0;
@@ -443,21 +439,19 @@ export class SlideTabBar {
protected _rightMoveX: number = 0;
// eslint-disable-next-line max-lines-per-function
- constructor(config: Partial<SlideTabBarConfig>) {
+ constructor(config: Partial<ISlideTabBarConfig>) {
if (config.slideTabBarContainer == null) {
throw new Error('not found slide-tab-bar root element');
}
- const slideTabBar = config.slideTabBarContainer.querySelector(
- `.${config.slideTabBarClassName ?? 'slide-tab-bar'}`
- );
+ const slideTabBar = config.slideTabBarContainer.querySelector(`${config.slideTabBarSelector}`);
if (slideTabBar == null) {
throw new Error('not found slide-tab-bar');
}
this._slideTabBar = slideTabBar as HTMLElement;
this._slideScrollbar = new SlideScrollbar(this);
- this._config = config as SlideTabBarConfig;
+ this._config = config as ISlideTabBarConfig;
this._initConfig();
@@ -478,7 +472,7 @@ export class SlideTabBar {
}
const slideItemId = (downEvent.target as HTMLElement)
- ?.closest(`.${config.slideTabBarItemClassName}`)
+ ?.closest(`${config.slideTabBarItemSelector}`)
?.getAttribute('data-id');
const slideItemIndex = this._slideTabItems.findIndex((item) => item.getId() === slideItemId);
@@ -672,7 +666,7 @@ export class SlideTabBar {
return this._slideScrollbar;
}
- getConfig(): SlideTabBarConfig {
+ getConfig(): ISlideTabBarConfig {
return this._config;
}
@@ -1035,9 +1029,7 @@ export class SlideTabBar {
}
protected _initConfig(): void {
- const slideTabItems = this._slideTabBar.querySelectorAll(
- `.${this._config.slideTabBarItemClassName ?? 'slide-tab-item'}`
- );
+ const slideTabItems = this._slideTabBar.querySelectorAll(`${this._config.slideTabBarItemSelector}`);
this._downActionX = 0;
this._moveActionX = 0;
diff --git a/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx b/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
index ff4043e80a..75360d7e54 100644
--- a/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
+++ b/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
@@ -22,10 +22,10 @@ import { useMemo } from 'react';
import { useActiveWorkbook } from '../../components/hook';
import { SHEETS_UI_PLUGIN_CONFIG_KEY } from '../../controllers/config.schema';
import { AutoFillPopupMenu } from '../auto-fill-popup-menu/AutoFillPopupMenu';
-import { CountBar } from '../count-bar/CountBar';
import { EditorContainer } from '../editor-container/EditorContainer';
import { FormulaBar } from '../formula-bar/FormulaBar';
import { SheetBar } from '../sheet-bar/SheetBar';
+import { SheetZoomSlider } from '../sheet-slider/CountBar';
import { StatusBar } from '../status-bar/StatusBar';
export const SHEET_FOOTER_BAR_HEIGHT = 36;
@@ -67,7 +67,7 @@ export function RenderSheetFooter() {
)))}
</div>
)}
- {zoomSlider && <CountBar />}
+ {zoomSlider && <SheetZoomSlider />}
</section>
);
}
diff --git a/packages/sheets-ui/src/views/count-bar/CountBar.tsx b/packages/sheets-ui/src/views/sheet-slider/CountBar.tsx
similarity index 83%
rename from packages/sheets-ui/src/views/count-bar/CountBar.tsx
rename to packages/sheets-ui/src/views/sheet-slider/CountBar.tsx
index a7dff0652b..2ef6d35b19 100644
--- a/packages/sheets-ui/src/views/count-bar/CountBar.tsx
+++ b/packages/sheets-ui/src/views/sheet-slider/CountBar.tsx
@@ -16,12 +16,7 @@
import { ZoomSlider } from './ZoomSlider';
-interface ICountBarProps {
- changeRatio?: (ratio: string) => void;
- onChange?: (value: string) => void;
-}
-
-export function CountBar(props: ICountBarProps) {
+export function SheetZoomSlider() {
return (
<section className="univer-flex univer-flex-shrink-0 univer-justify-end">
<ZoomSlider />
diff --git a/packages/sheets-ui/src/views/count-bar/ZoomSlider.tsx b/packages/sheets-ui/src/views/sheet-slider/ZoomSlider.tsx
similarity index 100%
rename from packages/sheets-ui/src/views/count-bar/ZoomSlider.tsx
rename to packages/sheets-ui/src/views/sheet-slider/ZoomSlider.tsx
diff --git a/packages/sheets-ui/src/views/count-bar/index.ts b/packages/sheets-ui/src/views/sheet-slider/index.ts
similarity index 100%
rename from packages/sheets-ui/src/views/count-bar/index.ts
rename to packages/sheets-ui/src/views/sheet-slider/index.ts
diff --git a/packages/ui/src/components/slider/Slider.tsx b/packages/ui/src/components/slider/Slider.tsx
index ad073582d6..56d64c1a35 100644
--- a/packages/ui/src/components/slider/Slider.tsx
+++ b/packages/ui/src/components/slider/Slider.tsx
@@ -236,6 +236,7 @@ export function Slider(props: ISliderProps) {
className={`
univer-flex univer-h-7 univer-w-[55px] univer-cursor-pointer univer-items-center
univer-justify-center univer-rounded univer-text-sm univer-text-gray-800 univer-transition-all
+ dark:univer-text-white dark:hover:univer-bg-gray-700
hover:univer-bg-gray-100
`}
>