This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// ************************************************************************************************************************** | ||
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED. | ||
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION. | ||
// ************************************************************************************************************************** | ||
|
||
import { PropType } from "vue"; | ||
import { DnvueComponentProps } from "../component-props"; | ||
|
||
/** | ||
* 提供了按钮相关的通用属性。 | ||
*/ | ||
export const BtnCommonProps = Object.assign({}, DnvueComponentProps, { | ||
/** | ||
* 设置或获取一个字符串,用于表示按钮文本资源名称。 | ||
* | ||
* @type {string} | ||
*/ | ||
text: { | ||
type: String, | ||
default: "BUTTON" | ||
}, | ||
/** | ||
* 设置或获取一个字符串,用于表示 @mdi/font 图标名称。 | ||
* | ||
* @type {string} | ||
*/ | ||
iconName: { | ||
type: String, | ||
default: "" | ||
}, | ||
/** | ||
* 设置或获取一个字符串,用于表示类型。 | ||
* | ||
* @type {string} | ||
*/ | ||
elType: { | ||
type: String as PropType<"primary" | "success" | "warning" | "danger" | "info">, | ||
default: "primary" | ||
}, | ||
/** | ||
* 设置或获取一个值,用于表示是否为朴素按钮。 | ||
* | ||
* @type {string} | ||
*/ | ||
elPlain: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
/** | ||
* 设置或获取一个字符串,用于表示按钮模式。 | ||
* | ||
* @type {string} | ||
*/ | ||
mode: { | ||
type: String as PropType<"button" | "text" | "link">, | ||
default: "button" | ||
}, | ||
/** | ||
* 设置或获取一个字符串,用于表示按钮边框。 | ||
* | ||
* @type {string} | ||
*/ | ||
border: { | ||
type: String as PropType<"normal" | "round" | "circle">, | ||
default: "normal" | ||
}, | ||
/** | ||
* 设置或获取一个值,用于表示是否为块状元素。 | ||
* | ||
* @type {boolean} | ||
*/ | ||
block: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// ************************************************************************************************************************** | ||
// COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED. | ||
// LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION. | ||
// ************************************************************************************************************************** | ||
|
||
import vBtn from "./v-btn.vue"; | ||
|
||
export { vBtn }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
************************************************************************************************************************** | ||
COPYRIGHT © 2006 - 2022 WANG YUCAI. ALL RIGHTS RESERVED. | ||
LICENSED UNDER THE MIT LICENSE. SEE LICENSE FILE IN THE PROJECT ROOT FOR FULL LICENSE INFORMATION. | ||
************************************************************************************************************************** | ||
--> | ||
|
||
<template> | ||
<el-button :class="readonlyIconClassName" :type="elType" :plain="elPlain" :text="mode === 'text'" :link="mode === 'link'" :round="border === 'round'" :circle="border === 'circle'" :loading="inProcessing" :disabled="isDisabled" :data-v-role--block="block" @click="onClick"> | ||
<slot /> | ||
<template v-if="!readonlyDefaultSlotVisible"> | ||
{{ $t(text) }} | ||
</template> | ||
</el-button> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { BtnCommonProps } from "./btn-props"; | ||
import { DnvueComponentEvents } from "../component-events"; | ||
import { computed, useSlots } from "vue"; | ||
import { paramCase } from "change-case"; | ||
const slots = useSlots(); | ||
const props = defineProps(BtnCommonProps); | ||
const events = defineEmits(DnvueComponentEvents); | ||
const readonlyDefaultSlotVisible = computed<boolean>(() => { | ||
return slots["default"] !== null && slots["default"] !== undefined; | ||
}); | ||
const readonlyIconClassName = computed<string[] | null>(() => { | ||
if (String.isNullOrWhitespace(props.iconName)) return null; | ||
return ["mdi", paramCase(props.iconName)]; | ||
}); | ||
function onClick(): void { | ||
events("click"); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters