✨(component): 整理 button 与 card 代码
This commit is contained in:
parent
7057e4894f
commit
8bc1d329cd
@ -8,45 +8,39 @@ export default {
|
||||
<script setup lang="ts">
|
||||
import "./index.less";
|
||||
import { computed } from "vue";
|
||||
import {
|
||||
ButtonBorder,
|
||||
ButtonEmits,
|
||||
ButtonNativeType,
|
||||
ButtonSize,
|
||||
ButtonType,
|
||||
} from "./interface";
|
||||
import { ButtonBorder, ButtonEmits, ButtonNativeType, ButtonSize, ButtonType } from "./interface";
|
||||
import { BooleanOrString, String } from "../../types";
|
||||
|
||||
export interface LayButtonProps {
|
||||
export interface ButtonProps {
|
||||
type?: ButtonType;
|
||||
size?: ButtonSize;
|
||||
prefixIcon?: String;
|
||||
suffixIcon?: String;
|
||||
loadingIcon?: String;
|
||||
borderStyle?: String;
|
||||
border?: ButtonBorder;
|
||||
fluid?: BooleanOrString;
|
||||
radius?: BooleanOrString;
|
||||
loading?: BooleanOrString;
|
||||
disabled?: BooleanOrString;
|
||||
nativeType?: ButtonNativeType;
|
||||
borderStyle?: String;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayButtonProps>(), {
|
||||
fluid: false,
|
||||
radius: false,
|
||||
loading: false,
|
||||
disabled: false,
|
||||
const props = withDefaults(defineProps<ButtonProps>(), {
|
||||
loadingIcon: "layui-icon-loading-one",
|
||||
nativeType: "button",
|
||||
borderStyle: "soild",
|
||||
nativeType: "button",
|
||||
disabled: false,
|
||||
loading: false,
|
||||
radius: false,
|
||||
fluid: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits(ButtonEmits);
|
||||
const emits = defineEmits(ButtonEmits);
|
||||
|
||||
const onClick = (event: MouseEvent) => {
|
||||
if (!props.disabled) {
|
||||
emit("click", event);
|
||||
emits("click", event);
|
||||
}
|
||||
};
|
||||
|
||||
@ -87,4 +81,4 @@ const classes = computed(() => {
|
||||
<slot v-else></slot>
|
||||
<i v-if="suffixIcon" :class="`layui-icon ${suffixIcon}`"></i>
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
@ -5,17 +5,17 @@ export default {
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, useSlots } from "vue";
|
||||
import "./index.less";
|
||||
import { computed, useSlots } from "vue";
|
||||
import { String } from "../../types";
|
||||
import { CardShadow } from "./interface";
|
||||
|
||||
export interface LayCardProps {
|
||||
export interface CardProps {
|
||||
title?: String;
|
||||
shadow?: CardShadow;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayCardProps>(), {
|
||||
const props = withDefaults(defineProps<CardProps>(), {
|
||||
shadow: "always",
|
||||
});
|
||||
|
||||
@ -33,11 +33,10 @@ const classes = computed(() => {
|
||||
<div class="layui-card" :class="classes">
|
||||
<div class="layui-card-header" v-if="slot.title || title || slot.extra">
|
||||
<span class="layui-card-header-title">
|
||||
<slot name="title" v-if="slot.title"></slot>
|
||||
<template v-else>{{ title }}</template>
|
||||
<slot name="title">{{ title }}</slot>
|
||||
</span>
|
||||
<span class="layui-card-header-extra">
|
||||
<slot name="extra" v-if="slot.extra"></slot>
|
||||
<span class="layui-card-header-extra" v-if="slot.extra">
|
||||
<slot name="extra"></slot>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
|
@ -1 +1 @@
|
||||
export type CardShadow = "always" | "hover" | "never";
|
||||
export type CardShadow = "always" | "hover" | "never";
|
@ -22,7 +22,8 @@ const getStyle = computed<any>(() => {
|
||||
let allChild = item.value.parentNode.children;
|
||||
let allChildNum = allChild.length;
|
||||
|
||||
let activeIndex, currentIndex = 0;
|
||||
let activeIndex,
|
||||
currentIndex = 0;
|
||||
for (let index = 0; index < allChild.length; index++) {
|
||||
const element = allChild[index];
|
||||
// @ts-ignore
|
||||
|
@ -55,7 +55,6 @@ const changeLocales = (lang: string, locales: any, merge: boolean) => {
|
||||
};
|
||||
|
||||
const changeTheme = (theme: string) => {
|
||||
|
||||
const defaultPartial: Partial<Theme> = {
|
||||
mode: 1,
|
||||
brightness: 100,
|
||||
|
Loading…
Reference in New Issue
Block a user