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(design): refactor Button & Avatar (#5020)

白熱0a6a1197bc68
diff --git a/.cursor/rules/git-commit.mdc b/.cursor/rules/git-commit.mdc
deleted file mode 100644
index 5d0e803ece..0000000000
--- a/.cursor/rules/git-commit.mdc
+++ /dev/null
@@ -1,8 +0,0 @@
----
-description: when generate git commit message
-globs:
-alwaysApply: false
----
-
-# Your rule content
-- git commit message must not be longer than 100 characters
diff --git a/.cursor/rules/implement-figma-component.mdc b/.cursor/rules/implement-figma-component.mdc
deleted file mode 100644
index 16014539ab..0000000000
--- a/.cursor/rules/implement-figma-component.mdc
+++ /dev/null
@@ -1,15 +0,0 @@
----
-description: When user only give you an figma link.
-globs:
-alwaysApply: false
----
-
-# Your rule content
-
-When I give you a figma link, it means you need to get the design from figma. And help me to implements it as a react component.
-Please only use tailwindcss and html element (don't use button) only to write this component.
-Please write a storybook demo for this component, please put storbook demo in the same directory with the component, storybook demo like packages/design/src/components/date-picker/DatePicker.stories.tsx.
-Please note all interface should start with `I`.
-Please make all svg file to react-component. make sure all files in one dir.
-If the component include list items. you should using dataset and map to make sure this is configurable.
-
diff --git a/.cursor/rules/tailwindcss.mdc b/.cursor/rules/tailwindcss.mdc
deleted file mode 100644
index e398131177..0000000000
--- a/.cursor/rules/tailwindcss.mdc
+++ /dev/null
@@ -1,53 +0,0 @@
----
-description:
-globs:
-alwaysApply: true
----
-
-# Your rule content
-
-- The config file of tailwindcss is on [tailwind.config.ts](mdc:common/shared/tailwind/tailwind.config.ts).
-- The prefix is `univer-`, eg. `univer-cursor-pointer`
-
-## Colors
-
-We use a consistent color system across the application. Here are the main color variables:
-
-### Primary Colors
-- Primary: `primary-{50,100,200,300,400,500,600,700,800,900}`
- - Example: `univer-text-primary-500` for primary text color
-
-### Gray Scale
-- Gray: `gray-{50,100,200,300,400,500,600,700,800,900}`
- - Example: `univer-bg-gray-100` for light gray background
-
-### Status Colors
-- Blue: `blue-{50,100,200,300,400,500,600,700,800,900}`
-- Red: `red-{50,100,200,300,400,500,600,700,800,900}`
-- Orange: `orange-{50,100,200,300,400,500,600,700,800,900}`
-- Yellow: `yellow-{50,100,200,300,400,500,600,700,800,900}`
-- Green: `green-{50,100,200,300,400,500,600,700,800,900}`
-
-### Additional Colors
-- Jiqing: `jiqing-{50,100,200,300,400,500,600,700,800,900}`
-- Indigo: `indigo-{50,100,200,300,400,500,600,700,800,900}`
-- Purple: `purple-{50,100,200,300,400,500,600,700,800,900}`
-- Pink: `pink-{50,100,200,300,400,500,600,700,800,900}`
-
-## Common Color Usage Examples
-
-### Text Colors
-- Primary text: `univer-text-gray-800` (#181C2A)
-- Secondary text: `univer-text-gray-400` (#979DAC)
-- Disabled text: `univer-text-gray-300` (#CDD0D8)
-
-### Background Colors
-- Primary background: `univer-bg-gray-100` (#EEEFF1)
-- Secondary background: `univer-bg-gray-50` (#F9FAFB)
-- Active/Selected: `univer-bg-primary-50` (#F3F5FF)
-
-### Border Colors
-- Default border: `univer-border-gray-200` (#E3E5EA)
-- Active border: `univer-border-primary-500` (#466AF7)
-
-Remember to always prefix class names with `univer-` when using these colors.
diff --git a/.gitignore b/.gitignore
index 7e4a19a762..4ef0899e75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
#ide
*.DS_Store
.idea
+.cursor
# .vscode
#npm
@@ -118,4 +119,4 @@ playwright-report.json
typedoc.json
# tsx
-**/tsx-0
\ No newline at end of file
+**/tsx-0
diff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png
index d6987ff443..365742a53a 100644
Binary files a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png and b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png differ
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 7233b859c9..af657e5e96 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/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 c5ac5cc056..af657e5e96 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-experimental/action-recorder/src/views/components/RecorderPanel.tsx b/packages-experimental/action-recorder/src/views/components/RecorderPanel.tsx
index a68792c8b2..2bc705a612 100644
--- a/packages-experimental/action-recorder/src/views/components/RecorderPanel.tsx
+++ b/packages-experimental/action-recorder/src/views/components/RecorderPanel.tsx
@@ -67,9 +67,9 @@ function RecordPanelImpl() {
</div>
<div className={styles.actionRecorderPanelTitle}>{titleText}</div>
<div className={styles.actionRecorderPanelActions}>
- <Button type="default" size="small" onClick={recording ? stopRecording : closePanel}>{ recording ? 'Cancel' : 'Close' }</Button>
- <Button type="primary" size="small" onClick={recording ? completeRecording : () => startRecording()}>{ recording ? 'Save' : 'Start' }</Button>
- { !recording && <Button type="primary" size="small" onClick={() => startRecording(true)}>Start(N)</Button>}
+ <Button size="small" onClick={recording ? stopRecording : closePanel}>{ recording ? 'Cancel' : 'Close' }</Button>
+ <Button variant="primary" size="small" onClick={recording ? completeRecording : () => startRecording()}>{ recording ? 'Save' : 'Start' }</Button>
+ { !recording && <Button variant="primary" size="small" onClick={() => startRecording(true)}>Start(N)</Button>}
</div>
</div>
);
diff --git a/packages/design/package.json b/packages/design/package.json
index 7242e9b97f..99d8a6c383 100644
--- a/packages/design/package.json
+++ b/packages/design/package.json
@@ -71,9 +71,11 @@
"@radix-ui/react-dropdown-menu": "^2.1.7",
"@radix-ui/react-popover": "^1.1.7",
"@radix-ui/react-separator": "^1.1.3",
+ "@radix-ui/react-slot": "^1.2.0",
"@radix-ui/react-tooltip": "^1.2.0",
"@rc-component/trigger": "^2.2.6",
"@univerjs/icons": "^0.2.35",
+ "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"rc-dialog": "^9.6.0",
diff --git a/packages/design/src/components/avatar/Avatar.tsx b/packages/design/src/components/avatar/Avatar.tsx
index 5db558b633..6f7411ecf4 100644
--- a/packages/design/src/components/avatar/Avatar.tsx
+++ b/packages/design/src/components/avatar/Avatar.tsx
@@ -17,8 +17,6 @@
import type { CSSProperties, ReactNode } from 'react';
import { clsx } from '../../helper/clsx';
-import styles from './index.module.less';
-
type Shape = 'circle' | 'square';
type AvatarSize = number | 'middle' | 'small';
type ImageFit = 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
@@ -26,6 +24,8 @@ type ImageFit = 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
export interface IAvatarProps {
children?: ReactNode;
+ className?: string;
+
/** Semantic DOM style */
style?: CSSProperties;
@@ -69,6 +69,7 @@ export interface IAvatarProps {
export function Avatar(props: IAvatarProps) {
const {
children,
+ className,
style,
title,
alt,
@@ -89,20 +90,33 @@ export function Avatar(props: IAvatarProps) {
}
: {};
- const _className = clsx(styles.avatar, {
- [styles.avatarCircle]: shape === 'circle',
- [styles.avatarSquare]: shape === 'square',
- [styles.avatarImage]: src,
- [styles.avatarMiddle]: size === 'middle',
- [styles.avatarSmall]: size === 'small',
- });
+ const _className = clsx(`
+ univer-relative univer-inline-block univer-overflow-hidden univer-whitespace-nowrap univer-bg-gray-200
+ univer-text-center univer-align-middle univer-text-white
+ `, {
+ 'univer-rounded-full': shape === 'circle',
+ 'univer-rounded': shape === 'square',
+ 'univer-bg-transparent': src,
+ 'univer-size-9 univer-leading-9': size === 'middle',
+ 'univer-size-7 univer-leading-7': size === 'small',
+ }, className);
const fitStyle = { objectFit: fit };
if (src) {
return (
- <span className={_className} style={{ ...sizeStyle, ...style, ...fitStyle }}>
- <img src={src} title={title} alt={alt} onError={onError} onLoad={onLoad} />
+ <span
+ className={_className}
+ style={{ ...sizeStyle, ...style, ...fitStyle }}
+ >
+ <img
+ className="univer-block univer-size-full"
+ src={src}
+ title={title}
+ alt={alt}
+ onError={onError}
+ onLoad={onLoad}
+ />
{children}
</span>
);
diff --git a/packages/design/src/components/avatar/index.module.less b/packages/design/src/components/avatar/index.module.less
deleted file mode 100644
index 1c2e2e5f84..0000000000
--- a/packages/design/src/components/avatar/index.module.less
+++ /dev/null
@@ -1,48 +0,0 @@
-@avatar-size-middle: 34px;
-@avatar-size-small: 28px;
-
-.avatar-size(@size) {
- width: @size;
- height: @size;
- line-height: @size;
-}
-
-.avatar {
- position: relative;
-
- overflow: hidden;
- display: inline-block;
-
- color: rgb(var(--bg-color-secondary));
- text-align: center;
- white-space: nowrap;
- vertical-align: middle;
-
- background: rgb(var(--grey-200));
-
- &-square {
- border-radius: var(--border-radius-base);
- }
-
- &-circle {
- border-radius: 50%;
- }
-
- &-middle {
- .avatar-size(@avatar-size-middle);
- }
-
- &-small {
- .avatar-size(@avatar-size-small);
- }
-
- &-image {
- background: transparent;
-
- > img {
- display: block;
- width: 100%;
- height: 100%;
- }
- }
-}
diff --git a/packages/design/src/components/button/Button.stories.tsx b/packages/design/src/components/button/Button.stories.tsx
index f5c35420bf..b9ab71b1b6 100644
--- a/packages/design/src/components/button/Button.stories.tsx
+++ b/packages/design/src/components/button/Button.stories.tsx
@@ -33,10 +33,12 @@ export const ButtonType = {
render() {
return (
<>
- <Button>default button</Button>
- <Button type="primary">primary button</Button>
- <Button type="text">text button</Button>
- <Button type="link">link button</Button>
+ <div>
+ <Button>default button</Button>
+ <Button variant="primary">primary button</Button>
+ <Button variant="text">text button</Button>
+ <Button variant="link">link button</Button>
+ </div>
</>
);
},
@@ -46,26 +48,13 @@ export const ButtonSize = {
render() {
return (
<>
- <Button size="small">small button</Button>
- <Button>medium button</Button>
- <Button type="primary" size="large">
- large button
- </Button>
- </>
- );
- },
-};
-
-export const ButtonBlock = {
- render() {
- return (
- <>
- <Button size="small" block>
- small button
- </Button>
- <Button type="primary" block>
- primary button
- </Button>
+ <div>
+ <Button size="small">small button</Button>
+ <Button>medium button</Button>
+ <Button variant="primary" size="large">
+ large button
+ </Button>
+ </div>
</>
);
},
@@ -75,13 +64,15 @@ export const ButtonDisabled = {
render() {
return (
<>
- <Button disabled>default button</Button>
- <Button type="text" disabled>
- text button
- </Button>
- <Button type="primary" disabled>
- primary button
- </Button>
+ <div>
+ <Button disabled>default button</Button>
+ <Button variant="text" disabled>
+ text button
+ </Button>
+ <Button variant="primary" disabled>
+ primary button
+ </Button>
+ </div>
</>
);
},
diff --git a/packages/design/src/components/button/Button.tsx b/packages/design/src/components/button/Button.tsx
index 0b648fc653..b9379ce481 100644
--- a/packages/design/src/components/button/Button.tsx
+++ b/packages/design/src/components/button/Button.tsx
@@ -14,96 +14,77 @@
* limitations under the License.
*/
-import type { CSSProperties, MouseEvent, ReactNode } from 'react';
+import type { VariantProps } from 'class-variance-authority';
+import type { ButtonHTMLAttributes } from 'react';
+import { Slot } from '@radix-ui/react-slot';
+import { cva } from 'class-variance-authority';
+import { forwardRef } from 'react';
import { clsx } from '../../helper/clsx';
-import styles from './index.module.less';
-
-export type ButtonType = 'primary' | 'default' | 'text' | 'link';
-export type ButtonSize = 'small' | 'middle' | 'large';
-
-export interface IButtonProps {
- children?: ReactNode;
-
- /** Semantic DOM class */
- className?: string;
-
- /** Semantic DOM style */
- style?: CSSProperties;
-
- /**
- * Set button type
- * @default 'default'
- */
- type?: ButtonType;
-
- /**
- * Set the size of button
- * @default 'middle'
- */
- size?: ButtonSize;
-
- /**
- * Option to fit button width to its parent width
- * @default false
- */
- block?: boolean;
-
- /** Set the original html `type` of button, see: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) */
- htmlType?: 'submit' | 'reset' | 'button';
-
- /**
- * Disabled state of button
- * @default false
- */
- disabled?: boolean;
-
- /** Set the handler to handle `click` event */
- onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
-
- id?: string;
-}
-
-export function Button(props: IButtonProps) {
- const {
- children,
- className,
- style,
- type = 'default',
- size = 'middle',
- block,
- htmlType,
- disabled = false,
- onClick,
-
- ...restProps
- } = props;
-
- const _className = clsx(
- styles.button,
- {
- [styles.buttonPrimary]: type === 'primary',
- [styles.buttonDefault]: type === 'default',
- [styles.buttonText]: type === 'text',
- [styles.buttonLink]: type === 'link',
- [styles.buttonSmall]: size === 'small',
- [styles.buttonMiddle]: size === 'middle',
- [styles.buttonLarge]: size === 'large',
- [styles.buttonBlock]: block,
+export const buttonVariants = cva(
+ `
+ univer-box-border univer-inline-flex univer-cursor-pointer univer-select-none univer-items-center
+ univer-justify-center univer-gap-2 univer-whitespace-nowrap univer-rounded-md univer-border univer-border-solid
+ univer-text-sm univer-font-medium univer-transition-colors
+ [&_svg]:univer-pointer-events-none [&_svg]:univer-size-4 [&_svg]:univer-shrink-0
+ disabled:univer-pointer-events-none disabled:univer-opacity-50
+ `,
+ {
+ variants: {
+ variant: {
+ default: `
+ univer-border-gray-200 univer-bg-white univer-text-gray-700
+ active:univer-bg-gray-200
+ dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
+ dark:hover:univer-bg-gray-600 dark:active:univer-bg-gray-500
+ hover:univer-bg-gray-100
+ `,
+ primary: `
+ univer-border-primary-600 univer-bg-primary-600 univer-text-white
+ active:univer-bg-primary-700
+ hover:univer-bg-primary-500
+ `,
+ text: `
+ univer-border-transparent univer-bg-transparent univer-text-gray-900
+ active:univer-bg-gray-200
+ dark:univer-text-white dark:hover:univer-bg-gray-700 dark:active:univer-bg-gray-600
+ hover:univer-bg-gray-100
+ `,
+ link: `
+ univer-border-transparent univer-bg-transparent univer-text-primary-600 univer-underline-offset-4
+ univer-underline-current
+ active:univer-text-primary-700
+ hover:univer-text-primary-500 hover:univer-underline
+ `,
+ },
+ size: {
+ small: 'univer-h-6 univer-rounded-md univer-px-1.5 univer-text-xs',
+ middle: 'univer-h-8 univer-rounded-lg univer-px-2 univer-text-sm',
+ large: 'univer-h-10 univer-rounded-lg univer-px-3 univer-text-sm',
+ },
},
- className
- );
+ defaultVariants: {
+ variant: 'default',
+ size: 'middle',
+ },
+ }
+);
- return (
- <button
- className={_className}
- style={style}
- type={htmlType}
- onClick={onClick}
- disabled={disabled}
- {...restProps}
- >
- {children}
- </button>
- );
+export interface IButtonProps
+ extends ButtonHTMLAttributes<HTMLButtonElement>,
+ VariantProps<typeof buttonVariants> {
+ asChild?: boolean;
}
+
+export const Button = forwardRef<HTMLButtonElement, IButtonProps>(
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : 'button';
+ return (
+ <Comp
+ className={clsx(buttonVariants({ variant, size, className }))}
+ ref={ref}
+ {...props}
+ />
+ );
+ }
+);
diff --git a/packages/design/src/components/button/__tests__/index.spec.tsx b/packages/design/src/components/button/__tests__/index.spec.tsx
index 637af97ac4..1ee422be73 100644
--- a/packages/design/src/components/button/__tests__/index.spec.tsx
+++ b/packages/design/src/components/button/__tests__/index.spec.tsx
@@ -22,7 +22,7 @@ import { Button } from '../Button';
describe('Button', () => {
it('renders correctly', () => {
- const { container } = render(<Button type="primary">btn1</Button>);
+ const { container } = render(<Button variant="primary">btn1</Button>);
expect(container);
});
diff --git a/packages/design/src/components/button/index.ts b/packages/design/src/components/button/index.ts
index 2c6a3d3108..3ef196b383 100644
--- a/packages/design/src/components/button/index.ts
+++ b/packages/design/src/components/button/index.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export { Button, type ButtonSize, type ButtonType, type IButtonProps } from './Button';
+export { Button, type IButtonProps } from './Button';
diff --git a/packages/design/src/components/config-provider/ConfigProvider.stories.tsx b/packages/design/src/components/config-provider/ConfigProvider.stories.tsx
index 12e788d397..7bf2218174 100644
--- a/packages/design/src/components/config-provider/ConfigProvider.stories.tsx
+++ b/packages/design/src/components/config-provider/ConfigProvider.stories.tsx
@@ -15,11 +15,11 @@
*/
import type { Meta } from '@storybook/react';
-import React, { useState } from 'react';
+import type { ILocale } from '../../locale/interface';
+import { useState } from 'react';
import enUS from '../../locale/en-US';
import zhCN from '../../locale/zh-CN';
-import type { ILocale } from '../../locale/interface';
import { Button } from '../button/Button';
import { Confirm } from '../confirm/Confirm';
import { ConfigProvider } from './ConfigProvider';
diff --git a/packages/design/src/components/confirm/Confirm.tsx b/packages/design/src/components/confirm/Confirm.tsx
index ff33496bf7..f562398f09 100644
--- a/packages/design/src/components/confirm/Confirm.tsx
+++ b/packages/design/src/components/confirm/Confirm.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import React, { useContext } from 'react';
+import type { ILocale } from '../../locale/interface';
+import React, { useContext } from 'react';
import { Button } from '../button/Button';
import { ConfigContext } from '../config-provider/ConfigProvider';
import { Dialog } from '../dialog/Dialog';
-import type { ILocale } from '../../locale/interface';
import styles from './index.module.less';
export interface IConfirmProps {
@@ -69,7 +69,7 @@ function Footer(props: { locale: ILocale['design']; cancelText?: string; confirm
return (
<footer className={styles.confirmFooter}>
<Button onClick={onClose}>{cancelText ?? locale?.Confirm.cancel}</Button>
- <Button type="primary" onClick={onConfirm}>
+ <Button variant="primary" onClick={onConfirm}>
{confirmText ?? locale?.Confirm.confirm}
</Button>
</footer>
diff --git a/packages/design/src/components/dialog/Dialog.tsx b/packages/design/src/components/dialog/Dialog.tsx
index 38aa3b7ac0..61120c1c8f 100644
--- a/packages/design/src/components/dialog/Dialog.tsx
+++ b/packages/design/src/components/dialog/Dialog.tsx
@@ -192,7 +192,7 @@ export function Dialog(props: IDialogProps) {
? (
<div>
<Button className="univer-mr-2" onClick={onCancel ?? onClose}>{locale?.Confirm?.cancel ?? 'Cancel'}</Button>
- <Button type="primary" onClick={onOk}>{locale?.Confirm?.confirm ?? 'Ok'}</Button>
+ <Button variant="primary" onClick={onOk}>{locale?.Confirm?.confirm ?? 'Ok'}</Button>
</div>
)
: null);
diff --git a/packages/design/src/components/input/Input.tsx b/packages/design/src/components/input/Input.tsx
index 5cd9a397f0..c70a120d53 100644
--- a/packages/design/src/components/input/Input.tsx
+++ b/packages/design/src/components/input/Input.tsx
@@ -23,7 +23,7 @@ type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
export interface IInputProps extends Pick<InputProps, 'onFocus' | 'onBlur'> {
autoFocus?: boolean;
className?: string;
- affixWrapperStyle?: React.CSSProperties;
+ style?: React.CSSProperties;
type?: 'text' | 'password';
placeholder?: string;
value?: string;
@@ -33,13 +33,12 @@ export interface IInputProps extends Pick<InputProps, 'onFocus' | 'onBlur'> {
onClick?: (e: React.MouseEvent<HTMLInputElement>) => void;
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
onChange?: (value: string) => void;
- style?: React.CSSProperties;
}
export const Input = ({
autoFocus = false,
className,
- affixWrapperStyle,
+ style,
type = 'text',
placeholder,
value,
@@ -75,7 +74,7 @@ export const Input = ({
disabled && 'univer-cursor-not-allowed univer-opacity-50',
className
)}
- style={affixWrapperStyle}
+ style={style}
>
<input
type={type}
diff --git a/packages/design/src/components/message/Message.stories.tsx b/packages/design/src/components/message/Message.stories.tsx
index 5c7d484293..fffa1e8473 100644
--- a/packages/design/src/components/message/Message.stories.tsx
+++ b/packages/design/src/components/message/Message.stories.tsx
@@ -41,19 +41,19 @@ export const Playground = {
return (
<section className="univer-space-x-2">
- <Button type="primary" onClick={() => handleOpen(MessageType.Success)}>
+ <Button variant="primary" onClick={() => handleOpen(MessageType.Success)}>
success
</Button>
- <Button type="primary" onClick={() => handleOpen(MessageType.Info)}>
+ <Button variant="primary" onClick={() => handleOpen(MessageType.Info)}>
info / default
</Button>
- <Button type="primary" onClick={() => handleOpen(MessageType.Warning)}>
+ <Button variant="primary" onClick={() => handleOpen(MessageType.Warning)}>
warning
</Button>
- <Button type="primary" onClick={() => handleOpen(MessageType.Error)}>
+ <Button variant="primary" onClick={() => handleOpen(MessageType.Error)}>
error
</Button>
- <Button type="primary" onClick={() => handleOpen(MessageType.Loading)}>
+ <Button variant="primary" onClick={() => handleOpen(MessageType.Loading)}>
loading
</Button>
diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts
index b454a774f7..259bff7c71 100644
--- a/packages/design/src/index.ts
+++ b/packages/design/src/index.ts
@@ -17,7 +17,7 @@
import './global.css';
export { Avatar, type IAvatarProps } from './components/avatar';
-export { Button, type ButtonSize, type ButtonType, type IButtonProps } from './components/button';
+export { Button, type IButtonProps } from './components/button';
export { CascaderList, type ICascaderListProps } from './components/cascader-list';
export { Checkbox, type ICheckboxProps } from './components/checkbox';
export { CheckboxGroup, type ICheckboxGroupProps } from './components/checkbox-group';
diff --git a/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx b/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx
index c2c940d405..ae672ad350 100644
--- a/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx
+++ b/packages/docs-hyper-link-ui/src/views/hyper-link-edit/index.tsx
@@ -161,7 +161,7 @@ export const DocHyperLinkEdit = () => {
{localeService.t('docLink.edit.cancel')}
</Button>
<Button
- type="primary"
+ variant="primary"
disabled={!link}
onClick={handleConfirm}
>
diff --git a/packages/drawing-ui/src/views/panel/DrawingGroup.tsx b/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
index 49228b858e..a3041add15 100644
--- a/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
+++ b/packages/drawing-ui/src/views/panel/DrawingGroup.tsx
@@ -195,7 +195,7 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
</div>
<div className={styles.imageCommonPanelRow}>
<div className={clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2, styles.imageCommonPanelColumnCenter)}>
- <Button size="small" onClick={() => { onGroupBtnClick(); }} style={{ display: gridDisplay(groupBtnShow) }}>
+ <Button style={{ display: gridDisplay(groupBtnShow) }} size="small" onClick={() => { onGroupBtnClick(); }}>
<span className={styles.imageCommonPanelInline}>
<GroupSingle />
{localeService.t('image-panel.group.group')}
@@ -203,7 +203,7 @@ export const DrawingGroup = (props: IDrawingGroupProps) => {
</Button>
</div>
<div className={clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2, styles.imageCommonPanelColumnCenter)}>
- <Button size="small" onClick={() => { onUngroupBtnClick(); }} style={{ display: gridDisplay(ungroupBtnShow) }}>
+ <Button style={{ display: gridDisplay(ungroupBtnShow) }} size="small" onClick={() => { onUngroupBtnClick(); }}>
<span className={styles.imageCommonPanelInline}>
<UngroupSingle />
{localeService.t('image-panel.group.unGroup')}
diff --git a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
index 541af4b1dd..3cb53350f8 100644
--- a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
+++ b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
@@ -232,7 +232,7 @@ export const ReplaceDialog = forwardRef(function ReplaceDIalogImpl(_props, ref)
</>
</FormDualColumnLayout>
<div className="univer-mt-6 univer-flex univer-justify-between">
- <Button type="primary" onClick={onClickFindButton} disabled={findDisabled}>{localeService.t('find-replace.dialog.find')}</Button>
+ <Button variant="primary" onClick={onClickFindButton} disabled={findDisabled}>{localeService.t('find-replace.dialog.find')}</Button>
<span className="univer-inline-flex univer-gap-2">
<Button disabled={replaceDisabled} onClick={onClickReplaceButton}>{localeService.t('find-replace.dialog.replace')}</Button>
<Button disabled={replaceAllDisabled} onClick={onClickReplaceAllButton}>{localeService.t('find-replace.dialog.replace-all')}</Button>
diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
index 4003f42332..ab8f142a96 100644
--- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
+++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/index.tsx
@@ -259,7 +259,7 @@ export const RuleEdit = (props: IRuleEditProps) => {
`}
>
<Button size="small" onClick={handleCancel}>{localeService.t('sheet.cf.panel.cancel')}</Button>
- <Button className={styleBase.mLSm} size="small" type="primary" onClick={handleSubmit}>{localeService.t('sheet.cf.panel.submit')}</Button>
+ <Button className={styleBase.mLSm} size="small" variant="primary" onClick={handleSubmit}>{localeService.t('sheet.cf.panel.submit')}</Button>
</div>
</div>
);
diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
index 5a204c15f1..02473220a8 100644
--- a/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
@@ -74,7 +74,7 @@ export class DataValidationRejectInputController extends Disposable {
title: React.createElement(
Button,
{
- type: 'primary',
+ variant: 'primary',
onClick: () => this._dialogService.close('reject-input-dialog'),
},
this._localeService.t('dataValidation.alert.ok')
@@ -105,7 +105,7 @@ export class DataValidationRejectInputController extends Disposable {
title: React.createElement(
Button,
{
- type: 'primary',
+ variant: 'primary',
onClick: () => this._dialogService.close('reject-input-dialog'),
},
this._localeService.t('dataValidation.alert.ok')
diff --git a/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx b/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
index ad51e76b3d..a9ea3ec84c 100644
--- a/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
@@ -147,7 +147,7 @@ export function DateDropdown(props: IDropdownComponentProps) {
disabledDate={(current) => !numfmt.parseDate(current.format('YYYY-MM-DD'))}
/>
<div className={styles.dvDateDropdownBtns}>
- <Button size="small" type="primary" onClick={handleSave} disabled={!date.isValid()}>
+ <Button size="small" variant="primary" onClick={handleSave} disabled={!date.isValid()}>
{localeService.t('dataValidation.alert.ok')}
</Button>
</div>
diff --git a/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
index 12208c7517..841edb480a 100644
--- a/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
@@ -342,7 +342,7 @@ export function DataValidationDetail() {
<Button className={styles.dataValidationDetailButton} onClick={handleDelete}>
{localeService.t('dataValidation.panel.removeRule')}
</Button>
- <Button className={styles.dataValidationDetailButton} type="primary" onClick={handleOk}>
+ <Button className={styles.dataValidationDetailButton} variant="primary" onClick={handleOk}>
{localeService.t('dataValidation.panel.done')}
</Button>
</div>
diff --git a/packages/sheets-data-validation-ui/src/views/components/list/index.tsx b/packages/sheets-data-validation-ui/src/views/components/list/index.tsx
index 1a57c435b9..92a2bd54ec 100644
--- a/packages/sheets-data-validation-ui/src/views/components/list/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/list/index.tsx
@@ -123,7 +123,7 @@ export function DataValidationList(props: { workbook: Workbook }) {
</Button>
)
: null}
- <Button className={styles.dataValidationListButton} type="primary" onClick={handleAddRule}>
+ <Button className={styles.dataValidationListButton} variant="primary" onClick={handleAddRule}>
{localeService.t('dataValidation.panel.add')}
</Button>
</div>
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
index 0bbea5ed5e..6302e41a0a 100644
--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterPanel.tsx
@@ -94,14 +94,14 @@ export function FilterPanel() {
<div style={{ flex: 1 }} />
)}
<div className={styles.sheetsFilterPanelFooter}>
- <Button type="link" onClick={onClearCriteria} disabled={clearFilterDisabled}>
+ <Button variant="link" onClick={onClearCriteria} disabled={clearFilterDisabled}>
{localeService.t('sheets-filter.panel.clear-filter')}
</Button>
<span className={styles.sheetsFilterPanelFooterPrimaryButtons}>
- <Button type="default" onClick={onCancel}>
+ <Button variant="default" onClick={onCancel}>
{localeService.t('sheets-filter.panel.cancel')}
</Button>
- <Button disabled={!canApply} type="primary" onClick={onApply}>
+ <Button disabled={!canApply} variant="primary" onClick={onApply}>
{localeService.t('sheets-filter.panel.confirm')}
</Button>
</span>
diff --git a/packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx b/packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx
index 5d1f4a4426..77607eb780 100644
--- a/packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx
+++ b/packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx
@@ -70,7 +70,7 @@ export function MoreFunctions() {
<div className={styles.formulaMoreFunctionsOperation}>
{/* TODO@Dushusir: open input params after range selector refactor */}
{inputParams && (
- <Button type="primary" size="small" onClick={handleClickNextPrev}>
+ <Button variant="primary" size="small" onClick={handleClickNextPrev}>
{localeService.t('formula.moreFunctions.next')}
</Button>
)}
@@ -80,7 +80,7 @@ export function MoreFunctions() {
</Button>
)}
{selectFunction && !!workbook && (
- <Button type="primary" size="small" onClick={handleConfirm}>
+ <Button variant="primary" size="small" onClick={handleConfirm}>
{localeService.t('formula.moreFunctions.confirm')}
</Button>
)}
diff --git a/packages/sheets-formula-ui/src/views/range-selector/index.tsx b/packages/sheets-formula-ui/src/views/range-selector/index.tsx
index 63d1ea1f70..5b71837281 100644
--- a/packages/sheets-formula-ui/src/views/range-selector/index.tsx
+++ b/packages/sheets-formula-ui/src/views/range-selector/index.tsx
@@ -151,6 +151,7 @@ export function RangeSelectorDialog(props: IRangeSelectorDialogProps) {
<Button onClick={onClose}>{localeService.t('rangeSelector.cancel')}</Button>
<Button
style={{ marginLeft: 10 }}
+ variant="primary"
onClick={() => {
onConfirm(
ranges
@@ -161,7 +162,6 @@ export function RangeSelectorDialog(props: IRangeSelectorDialogProps) {
.map((text) => deserializeRangeWithSheet(text)).map((unitRange) => ({ ...unitRange, range: rangePreProcess(unitRange.range) }))
);
}}
- type="primary"
>
{localeService.t('rangeSelector.confirm')}
</Button>
@@ -173,7 +173,7 @@ export function RangeSelectorDialog(props: IRangeSelectorDialogProps) {
{ranges.map((text, index) => (
<div key={index} className={styles.sheetRangeSelectorDialogItem}>
<Input
- affixWrapperStyle={{ width: '100%' }}
+ className="univer-w-full"
placeholder={localeService.t('rangeSelector.placeHolder')}
onFocus={() => setFocusIndex(index)}
value={text}
@@ -185,7 +185,7 @@ export function RangeSelectorDialog(props: IRangeSelectorDialogProps) {
))}
{ranges.length < maxRangeCount && (
<div>
- <Button type="link" size="small" onClick={handleRangeAdd}>
+ <Button variant="link" size="small" onClick={handleRangeAdd}>
<IncreaseSingle />
<span>{localeService.t('rangeSelector.addAnotherRange')}</span>
</Button>
diff --git a/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx b/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
index d242f1f624..7b5e9843ab 100644
--- a/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
+++ b/packages/sheets-hyper-link-ui/src/views/CellLinkEdit/index.tsx
@@ -581,7 +581,7 @@ export const CellLinkEdit = () => {
{localeService.t('hyperLink.form.cancel')}
</Button>
<Button
- type="primary"
+ variant="primary"
style={{ marginLeft: 8 }}
onClick={async () => {
handleSubmit();
diff --git a/packages/sheets-numfmt-ui/src/views/components/index.tsx b/packages/sheets-numfmt-ui/src/views/components/index.tsx
index f977d4fd83..ecbbd44249 100644
--- a/packages/sheets-numfmt-ui/src/views/components/index.tsx
+++ b/packages/sheets-numfmt-ui/src/views/components/index.tsx
@@ -132,7 +132,7 @@ export const SheetNumfmtPanel: FC<ISheetNumfmtPanelProps> = (props) => {
<Button size="small" onClick={handleCancel} className="m-r-12">
{t('sheet.numfmt.cancel')}
</Button>
- <Button type="primary" size="small" onClick={handleConfirm}>
+ <Button variant="primary" size="small" onClick={handleConfirm}>
{t('sheet.numfmt.confirm')}
</Button>
</div>
diff --git a/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx b/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx
index 653a47195f..947232c5e4 100644
--- a/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx
+++ b/packages/sheets-sort-ui/src/views/CustomSortPanel.tsx
@@ -160,8 +160,19 @@ export function CustomSortPanel() {
</div>
</div>
<div className={styles.customSortPanelFooter}>
- <Button className={styles.customSortPanelFooterBtn} type="default" onClick={() => cancel()}>{localeService.t('sheets-sort.dialog.cancel')}</Button>
- <Button className={styles.customSortPanelFooterBtn} type="primary" onClick={() => apply(list, hasTitle)}>{localeService.t('sheets-sort.dialog.confirm')}</Button>
+ <Button
+ className={styles.customSortPanelFooterBtn}
+ onClick={() => cancel()}
+ >
+ {localeService.t('sheets-sort.dialog.cancel')}
+ </Button>
+ <Button
+ className={styles.customSortPanelFooterBtn}
+ variant="primary"
+ onClick={() => apply(list, hasTitle)}
+ >
+ {localeService.t('sheets-sort.dialog.confirm')}
+ </Button>
</div>
</div>
);
diff --git a/packages/sheets-ui/src/facade/f-workbook.ts b/packages/sheets-ui/src/facade/f-workbook.ts
index 19b9865cad..e45e9dca5c 100644
--- a/packages/sheets-ui/src/facade/f-workbook.ts
+++ b/packages/sheets-ui/src/facade/f-workbook.ts
@@ -80,7 +80,7 @@ export interface IFWorkbookSheetsUIMixin {
* title: (
* <>
* <Button onClick={() => { console.log('Cancel clicked') }}>Cancel</Button>
- * <Button type="primary" onClick={() => { console.log('Confirm clicked') }} style={{marginLeft: '10px'}}>Confirm</Button>
+ * <Button variant="primary" onClick={() => { console.log('Confirm clicked') }} style={{marginLeft: '10px'}}>Confirm</Button>
* </>
* )
* },
diff --git a/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx b/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
index 601794d672..f42b347167 100644
--- a/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
+++ b/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
@@ -212,7 +212,13 @@ export const DefinedNameInput = (props: IDefinedNameInputProps) => {
return (
<div className={styles.definedNameInput} style={{ display: state ? 'block' : 'none' }}>
<div>
- <Input placeholder={localeService.t('definedName.inputNamePlaceholder')} value={nameValue} allowClear onChange={setNameValue} affixWrapperStyle={widthStyle} />
+ <Input
+ style={widthStyle}
+ placeholder={localeService.t('definedName.inputNamePlaceholder')}
+ value={nameValue}
+ allowClear
+ onChange={setNameValue}
+ />
</div>
<div>
<RadioGroup value={typeValue} onChange={typeValueChange}>
@@ -247,7 +253,6 @@ export const DefinedNameInput = (props: IDefinedNameInputProps) => {
onVerify={(res: boolean) => {
setValidFormulaOrRange(res);
}}
-
onFocus={() => isFocusFormulaEditorSet(true)}
ref={formulaEditorRef}
/>
@@ -256,7 +261,12 @@ export const DefinedNameInput = (props: IDefinedNameInputProps) => {
<Select style={widthStyle} value={localSheetIdValue} options={options} onChange={setLocalSheetIdValue} />
</div>
<div>
- <Input affixWrapperStyle={widthStyle} placeholder={localeService.t('definedName.inputCommentPlaceholder')} value={commentValue} onChange={setCommentValue} />
+ <Input
+ style={widthStyle}
+ placeholder={localeService.t('definedName.inputCommentPlaceholder')}
+ value={commentValue}
+ onChange={setCommentValue}
+ />
</div>
<div style={{ display: validString.length === 0 ? 'none' : 'flex' }} className={styles.definedNameInputValidation}>
<span>
@@ -274,7 +284,7 @@ export const DefinedNameInput = (props: IDefinedNameInputProps) => {
</Button>
<Button
style={{ marginLeft: 15 }}
- type="primary"
+ variant="primary"
onClick={confirmChange}
>
{localeService.t('definedName.confirm')}
diff --git a/packages/sheets-ui/src/views/permission/error-msg-dialog/index.tsx b/packages/sheets-ui/src/views/permission/error-msg-dialog/index.tsx
index 22147adf8c..00c01b916c 100644
--- a/packages/sheets-ui/src/views/permission/error-msg-dialog/index.tsx
+++ b/packages/sheets-ui/src/views/permission/error-msg-dialog/index.tsx
@@ -29,7 +29,7 @@ export const AlertDialog = ({ errorMsg }: { errorMsg: string }) => {
<p>{errorMsg || localeService.t('permission.dialog.alertContent')}</p>
<div className={styles.sheetPermissionAlertDialogButton}>
<Button
- type="primary"
+ variant="primary"
onClick={() => {
dialogService.close(UNIVER_SHEET_PERMISSION_ALERT_DIALOG_ID);
}}
diff --git a/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailFooterPart.tsx b/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailFooterPart.tsx
index e5f790798e..866d457ba2 100644
--- a/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailFooterPart.tsx
+++ b/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailFooterPart.tsx
@@ -61,7 +61,7 @@ export const PermissionDetailFooterPart = (props: IPermissionDetailFooterPartPro
return (
<div className={styles.sheetPermissionPanelFooter}>
<Button
- type="primary"
+ variant="primary"
onClick={async () => {
if (rangesErrMsg) return;
diff --git a/packages/sheets-ui/src/views/permission/panel-list/index.tsx b/packages/sheets-ui/src/views/permission/panel-list/index.tsx
index 0af8243548..75eb61c0d1 100644
--- a/packages/sheets-ui/src/views/permission/panel-list/index.tsx
+++ b/packages/sheets-ui/src/views/permission/panel-list/index.tsx
@@ -342,7 +342,7 @@ export const SheetPermissionPanelList = () => {
<div className={styles.sheetPermissionPanelAddWrapper}>
<Button
className={styles.sheetPermissionPanelAddButton}
- type="primary"
+ variant="primary"
onClick={() => {
const sidebarProps = {
header: { title: `${localeService.t('permission.panel.title')}` },
diff --git a/packages/sheets-ui/src/views/permission/permission-dialog/index.tsx b/packages/sheets-ui/src/views/permission/permission-dialog/index.tsx
index 9f845d0743..15b9d8ea23 100644
--- a/packages/sheets-ui/src/views/permission/permission-dialog/index.tsx
+++ b/packages/sheets-ui/src/views/permission/permission-dialog/index.tsx
@@ -211,7 +211,7 @@ export const SheetPermissionDialog = () => {
{localeService.t('permission.button.cancel')}
</Button>
<Button
- type="primary"
+ variant="primary"
onClick={() => {
handleChangeActionPermission();
dialogService.close(UNIVER_SHEET_PERMISSION_DIALOG_ID);
diff --git a/packages/sheets-ui/src/views/permission/user-dialog/index.tsx b/packages/sheets-ui/src/views/permission/user-dialog/index.tsx
index 296230f029..ee16892326 100644
--- a/packages/sheets-ui/src/views/permission/user-dialog/index.tsx
+++ b/packages/sheets-ui/src/views/permission/user-dialog/index.tsx
@@ -88,7 +88,7 @@ export const SheetPermissionUserDialog = () => {
{localeService.t('permission.button.cancel')}
</Button>
<Button
- type="primary"
+ variant="primary"
onClick={() => {
sheetPermissionUserManagerService.setSelectUserList(selectUserInfo);
dialogService.close(UNIVER_SHEET_PERMISSION_USER_DIALOG_ID);
diff --git a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
index c34f4e48ab..3ea73a3a5e 100644
--- a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
+++ b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
@@ -136,7 +136,7 @@ export const ThreadCommentEditor = forwardRef<IThreadCommentEditorInstance, IThr
{localeService.t('threadCommentUI.editor.cancel')}
</Button>
<Button
- type="primary"
+ variant="primary"
disabled={!canSubmit}
onClick={handleSave}
>
diff --git a/packages/thread-comment-ui/src/views/thread-comment-panel/index.tsx b/packages/thread-comment-ui/src/views/thread-comment-panel/index.tsx
index 2dbac35234..e4fcb2be82 100644
--- a/packages/thread-comment-ui/src/views/thread-comment-panel/index.tsx
+++ b/packages/thread-comment-ui/src/views/thread-comment-panel/index.tsx
@@ -254,8 +254,8 @@ export const ThreadCommentPanel = (props: IThreadCommentPanelProps) => {
{isFiltering
? (
<Button
+ variant="link"
onClick={onReset}
- type="link"
>
{localeService.t('threadCommentUI.panel.reset')}
</Button>
@@ -264,7 +264,7 @@ export const ThreadCommentPanel = (props: IThreadCommentPanelProps) => {
<Button
id="thread-comment-add"
className={styles.threadCommentPanelAdd}
- type="primary"
+ variant="primary"
onClick={onAdd}
disabled={disableAdd}
>
diff --git a/packages/ui/src/components/notification/Notification.stories.tsx b/packages/ui/src/components/notification/Notification.stories.tsx
index 49a3056739..900be230ad 100644
--- a/packages/ui/src/components/notification/Notification.stories.tsx
+++ b/packages/ui/src/components/notification/Notification.stories.tsx
@@ -36,7 +36,7 @@ export const Playground = {
<>
<Notification />
<Button
- type="primary"
+ variant="primary"
onClick={() =>
notification.show({
type: 'success',
@@ -53,7 +53,7 @@ export const Playground = {
Notification Info
</Button>
<Button
- type="primary"
+ variant="primary"
onClick={() =>
notification.show({
type: 'warning',
@@ -64,7 +64,7 @@ export const Playground = {
Notification Warning
</Button>
<Button
- type="primary"
+ variant="primary"
onClick={() =>
notification.show({ type: 'error', title: 'Notification Error', content: 'Notification content' })}
>
diff --git a/packages/ui/src/components/slider/Slider.tsx b/packages/ui/src/components/slider/Slider.tsx
index fc39ef4ca2..12b2676af8 100644
--- a/packages/ui/src/components/slider/Slider.tsx
+++ b/packages/ui/src/components/slider/Slider.tsx
@@ -164,7 +164,7 @@ export function Slider(props: ISliderProps) {
[styles.sliderDisabled]: disabled,
})}
>
- <Button type="text" size="small" disabled={value <= min || disabled} onClick={() => handleStep(-10)}>
+ <Button variant="text" size="small" disabled={value <= min || disabled} onClick={() => handleStep(-10)}>
<ReduceSingle />
</Button>
@@ -194,7 +194,7 @@ export function Slider(props: ISliderProps) {
</div>
</div>
- <Button type="text" size="small" disabled={value >= max || disabled} onClick={() => handleStep(10)}>
+ <Button variant="text" size="small" disabled={value >= max || disabled} onClick={() => handleStep(10)}>
<IncreaseSingle />
</Button>
diff --git a/packages/ui/src/facade/f-univer.ts b/packages/ui/src/facade/f-univer.ts
index 342e62e88c..8a1356d1bd 100644
--- a/packages/ui/src/facade/f-univer.ts
+++ b/packages/ui/src/facade/f-univer.ts
@@ -275,7 +275,7 @@ export interface IFUniverUIMixin {
* title: (
* <>
* <Button onClick={() => { console.log('Cancel clicked') }}>Cancel</Button>
- * <Button type="primary" onClick={() => { console.log('Confirm clicked') }} style={{marginLeft: '10px'}}>Confirm</Button>
+ * <Button variant="primary" onClick={() => { console.log('Confirm clicked') }} style={{marginLeft: '10px'}}>Confirm</Button>
* </>
* )
* },
diff --git a/packages/uniscript/src/views/components/ScriptEditorPanel.tsx b/packages/uniscript/src/views/components/ScriptEditorPanel.tsx
index 02a090c057..6162478cfd 100644
--- a/packages/uniscript/src/views/components/ScriptEditorPanel.tsx
+++ b/packages/uniscript/src/views/components/ScriptEditorPanel.tsx
@@ -94,7 +94,7 @@ export function ScriptEditorPanel() {
<div ref={editorContainerRef} />
</div>
<div className="univer-mt-2.5">
- <Button type="primary" size="small" onClick={startExecution}>
+ <Button variant="primary" size="small" onClick={startExecution}>
{localeService.t('script-panel.panel.execute')}
</Button>
</div>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b78725bb3a..14dc0b9e9e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1125,6 +1125,9 @@ importers:
'@radix-ui/react-separator':
specifier: ^1.1.3
+ '@radix-ui/react-slot':
+ specifier: ^1.2.0
+ version: 1.2.0(@types/[email protected])([email protected])
'@radix-ui/react-tooltip':
specifier: ^1.2.0
@@ -1134,6 +1137,9 @@ importers:
'@univerjs/icons':
specifier: ^0.2.35
+ class-variance-authority:
+ specifier: ^0.7.1
+ version: 0.7.1
clsx:
specifier: ^2.1.1
version: 2.1.1
@@ -6355,6 +6361,9 @@ packages:
resolution: {integrity: sha512-2VEG9JICxIqTpoK1eMzZqaV+u/EiwEJkMGzTrZf6sU/fwsnOITVgYJ8yojSy6CaXtO9V0Cc6ZQZ8h8m4UBuLwQ==}
+ resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}
+
resolution: {integrity: sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==}
@@ -14695,6 +14704,10 @@ snapshots:
libphonenumber-js: 1.11.3
validator: 13.12.0
+ dependencies:
+ clsx: 2.1.1
+