Skip to content

Commit 7791465

Browse files
committed
fix(button): Replace @nextui-org/theme to @heroui/theme
1 parent e9d3743 commit 7791465

File tree

1 file changed

+82
-69
lines changed

1 file changed

+82
-69
lines changed
Lines changed: 82 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,103 @@
11
<script lang="ts" setup>
2-
import { computed, ref } from 'vue'
3-
import { button } from '@nextui-org/theme'
4-
import { useRipple } from '@vue-nextui/shared'
2+
import { computed, ref } from "vue";
3+
import { button } from "@heroui/theme";
4+
import { useRipple } from "@vue-nextui/shared";
55
66
interface Button {
7-
/**
8-
* 按钮的变体样式
9-
*/
10-
variant: 'solid' | 'bordered' | 'light' | 'flat' | 'faded' | 'shadow' | 'ghost'
11-
12-
/**
13-
* 按钮的尺寸
14-
*/
15-
size: 'sm' | 'md' | 'lg'
16-
17-
/**
18-
* 按钮的颜色
19-
*/
20-
color: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger'
21-
22-
/**
23-
* 按钮的圆角样式
24-
*/
25-
radius: 'none' | 'sm' | 'md' | 'lg' | 'full'
26-
27-
/**
28-
* 是否占满父容器宽度
29-
*/
30-
fullWidth: boolean
31-
32-
/**
33-
* 是否禁用按钮
34-
*/
35-
isDisabled: boolean
36-
37-
/**
38-
* 是否在按钮组中
39-
*/
40-
isInGroup: boolean
41-
42-
/**
43-
* 是否仅为图标按钮
44-
*/
45-
isIconOnly: boolean
46-
47-
/**
48-
* 是否禁用动画效果
49-
*/
50-
disableAnimation: boolean
7+
/**
8+
* 按钮的变体样式
9+
*/
10+
variant:
11+
| "solid"
12+
| "bordered"
13+
| "light"
14+
| "flat"
15+
| "faded"
16+
| "shadow"
17+
| "ghost";
18+
19+
/**
20+
* 按钮的尺寸
21+
*/
22+
size: "sm" | "md" | "lg";
23+
24+
/**
25+
* 按钮的颜色
26+
*/
27+
color:
28+
| "default"
29+
| "primary"
30+
| "secondary"
31+
| "success"
32+
| "warning"
33+
| "danger";
34+
35+
/**
36+
* 按钮的圆角样式
37+
*/
38+
radius: "none" | "sm" | "md" | "lg" | "full";
39+
40+
/**
41+
* 是否占满父容器宽度
42+
*/
43+
fullWidth: boolean;
44+
45+
/**
46+
* 是否禁用按钮
47+
*/
48+
isDisabled: boolean;
49+
50+
/**
51+
* 是否在按钮组中
52+
*/
53+
isInGroup: boolean;
54+
55+
/**
56+
* 是否仅为图标按钮
57+
*/
58+
isIconOnly: boolean;
59+
60+
/**
61+
* 是否禁用动画效果
62+
*/
63+
disableAnimation: boolean;
5164
}
5265
53-
type ButtonState = "pressed" | "hover"
66+
type ButtonState = "pressed" | "hover";
5467
55-
type ButtonProps = Partial<Button>
68+
type ButtonProps = Partial<Button>;
5669
57-
const props = defineProps<ButtonProps>()
70+
const props = defineProps<ButtonProps>();
5871
5972
const buttonState = ref<ButtonState | undefined>();
6073
61-
const buttonRef = ref<HTMLButtonElement>()
62-
useRipple(buttonRef)
74+
const buttonRef = ref<HTMLButtonElement>();
75+
useRipple(buttonRef);
6376
6477
const className = computed(() => {
65-
return button({ ...props })
66-
})
78+
return button({ ...props });
79+
});
6780
6881
function setButtonState(): () => void;
6982
function setButtonState(state: ButtonState): () => void;
7083
function setButtonState(state?: ButtonState) {
71-
return () => {
72-
buttonState.value = state
73-
}
84+
return () => {
85+
buttonState.value = state;
86+
};
7487
}
7588
</script>
7689

7790
<template>
78-
<button
79-
ref="buttonRef"
80-
:data-pressed="buttonState === 'pressed'"
81-
:data-hover="buttonState === 'hover'"
82-
:class="className"
83-
@mouseup="setButtonState()"
84-
@mousedown="setButtonState('pressed')"
85-
@mouseenter="setButtonState('hover')"
86-
@mouseleave="setButtonState()"
87-
>
88-
<slot />
89-
</button>
91+
<button
92+
ref="buttonRef"
93+
:data-pressed="buttonState === 'pressed'"
94+
:data-hover="buttonState === 'hover'"
95+
:class="className"
96+
@mouseup="setButtonState()"
97+
@mousedown="setButtonState('pressed')"
98+
@mouseenter="setButtonState('hover')"
99+
@mouseleave="setButtonState()"
100+
>
101+
<slot />
102+
</button>
90103
</template>

0 commit comments

Comments
 (0)