|
@@ -10,6 +10,7 @@
|
|
|
v-bind="viewProps"
|
|
v-bind="viewProps"
|
|
|
:pressedColor="finalPressedColor"
|
|
:pressedColor="finalPressedColor"
|
|
|
:touchable="touchable && !loading"
|
|
:touchable="touchable && !loading"
|
|
|
|
|
+ :gap="iconMargin"
|
|
|
@state="(v) => state = v"
|
|
@state="(v) => state = v"
|
|
|
@click="(e) => emit('click', e)"
|
|
@click="(e) => emit('click', e)"
|
|
|
>
|
|
>
|
|
@@ -18,18 +19,12 @@
|
|
|
v-if="loading"
|
|
v-if="loading"
|
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
|
:color="themeContext.resolveThemeColor(loadingColor) || currentStyle.color"
|
|
:color="themeContext.resolveThemeColor(loadingColor) || currentStyle.color"
|
|
|
- :innerStyle="{
|
|
|
|
|
- marginRight: iconMargin ? '10rpx': undefined,
|
|
|
|
|
- }"
|
|
|
|
|
/>
|
|
/>
|
|
|
<Icon
|
|
<Icon
|
|
|
v-else-if="icon"
|
|
v-else-if="icon"
|
|
|
:icon="icon"
|
|
:icon="icon"
|
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
|
:color="currentStyle.color"
|
|
:color="currentStyle.color"
|
|
|
- :innerStyle="{
|
|
|
|
|
- marginRight: iconMargin ? '10rpx': undefined,
|
|
|
|
|
- }"
|
|
|
|
|
v-bind="iconProps"
|
|
v-bind="iconProps"
|
|
|
/>
|
|
/>
|
|
|
</slot>
|
|
</slot>
|
|
@@ -48,9 +43,6 @@
|
|
|
:icon="rightIcon"
|
|
:icon="rightIcon"
|
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
:size="selectStyleType(size, 'medium', FonstSizes)"
|
|
|
:color="currentStyle.color"
|
|
:color="currentStyle.color"
|
|
|
- :innerStyle="{
|
|
|
|
|
- marginLeft: iconMargin ? '10rpx' : undefined,
|
|
|
|
|
- }"
|
|
|
|
|
v-bind="rightIconProps"
|
|
v-bind="rightIconProps"
|
|
|
/>
|
|
/>
|
|
|
</slot>
|
|
</slot>
|
|
@@ -59,7 +51,7 @@
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { computed, inject, ref } from 'vue';
|
|
import { computed, inject, ref } from 'vue';
|
|
|
-import { useTheme, type ViewStyle } from '../theme/ThemeDefine';
|
|
|
|
|
|
|
+import { propGetThemeVar, useTheme, type ViewStyle } from '../theme/ThemeDefine';
|
|
|
import { configPadding, DynamicColor, DynamicSize, selectStyleType } from '../theme/ThemeTools';
|
|
import { configPadding, DynamicColor, DynamicSize, selectStyleType } from '../theme/ThemeTools';
|
|
|
import type { IconProps } from './Icon.vue';
|
|
import type { IconProps } from './Icon.vue';
|
|
|
import type { FlexProps } from '../layout/FlexView.vue';
|
|
import type { FlexProps } from '../layout/FlexView.vue';
|
|
@@ -122,6 +114,11 @@ export interface ButtonProp {
|
|
|
*/
|
|
*/
|
|
|
iconProps?: IconProps;
|
|
iconProps?: IconProps;
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 图标与文字之间的间距
|
|
|
|
|
+ * @default 10
|
|
|
|
|
+ */
|
|
|
|
|
+ iconMargin?: number|string;
|
|
|
|
|
+ /**
|
|
|
* 右侧图标。支持 Icon 组件里的所有图标,也可以传入图标的图片 URL(http/https)。
|
|
* 右侧图标。支持 Icon 组件里的所有图标,也可以传入图标的图片 URL(http/https)。
|
|
|
*/
|
|
*/
|
|
|
rightIcon?: string,
|
|
rightIcon?: string,
|
|
@@ -212,14 +209,15 @@ const themeContext = useTheme();
|
|
|
const props = withDefaults(defineProps<ButtonProp>(), {
|
|
const props = withDefaults(defineProps<ButtonProp>(), {
|
|
|
touchable: true,
|
|
touchable: true,
|
|
|
loading: false,
|
|
loading: false,
|
|
|
- color: 'primary',
|
|
|
|
|
- pressedColor: 'pressed.primary',
|
|
|
|
|
- disabledColor: 'grey',
|
|
|
|
|
- type: 'default',
|
|
|
|
|
- size: 'medium',
|
|
|
|
|
- block: false,
|
|
|
|
|
- radius: 16,
|
|
|
|
|
- shape: "round",
|
|
|
|
|
|
|
+ color: () => propGetThemeVar('ButtonColor', 'primary'),
|
|
|
|
|
+ pressedColor: () => propGetThemeVar('ButtonPressedColor', 'pressed.primary'),
|
|
|
|
|
+ disabledColor: () => propGetThemeVar('ButtonDisabledColor', 'grey'),
|
|
|
|
|
+ type: () => propGetThemeVar('ButtonType', 'default'),
|
|
|
|
|
+ size: () => propGetThemeVar('ButtonSize', 'medium'),
|
|
|
|
|
+ block: () => propGetThemeVar('ButtonBlock', false),
|
|
|
|
|
+ radius: () => propGetThemeVar('ButtonRadius', 16),
|
|
|
|
|
+ iconMargin: () => propGetThemeVar('ButtonIconMargin', 10),
|
|
|
|
|
+ shape: () => propGetThemeVar('ButtonShape', "round"),
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const FonstSizes = computed(() => ({
|
|
const FonstSizes = computed(() => ({
|
|
@@ -423,7 +421,6 @@ const currentStyle = computed(() => {
|
|
|
const state = ref('');
|
|
const state = ref('');
|
|
|
|
|
|
|
|
const currentText = computed(() => (props.loading ? (props.loadingText || props.text) : props.text));
|
|
const currentText = computed(() => (props.loading ? (props.loadingText || props.text) : props.text));
|
|
|
-const iconMargin = computed(() => Boolean(currentText.value));
|
|
|
|
|
const textColorFinal = computed(() => (
|
|
const textColorFinal = computed(() => (
|
|
|
state.value === 'active' ?
|
|
state.value === 'active' ?
|
|
|
themeContext.resolveThemeColor(props.pressedTextColor) :
|
|
themeContext.resolveThemeColor(props.pressedTextColor) :
|