feat: 新增 card 组件 shadow 属性
This commit is contained in:
parent
ed9ebccf79
commit
65031d2507
@ -114,6 +114,9 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: title 使用插槽
|
||||||
|
:::
|
||||||
|
|
||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -153,6 +156,46 @@ export default {
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: title 边框阴影
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: demo 通过 shadow 属性设置卡片阴影出现的时机。 该属性的值可以是:always、hover或never。
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="card-container">
|
||||||
|
<lay-card>
|
||||||
|
内容
|
||||||
|
</lay-card>
|
||||||
|
<lay-card shadow="hover">
|
||||||
|
内容
|
||||||
|
</lay-card>
|
||||||
|
<lay-card shadow="never">
|
||||||
|
内容
|
||||||
|
</lay-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.card-container {
|
||||||
|
background: whitesmoke;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
::: title Card 属性
|
::: title Card 属性
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -169,11 +212,11 @@ export default {
|
|||||||
|
|
||||||
::: table
|
::: table
|
||||||
|
|
||||||
| 插槽 | 描述 | 可选值 |
|
| 插槽 | 描述 | 可选值 |
|
||||||
| ------ | -------- | ------ |
|
| ------- | -------- | ------ |
|
||||||
| default| 默认插槽 | -- |
|
| default | 默认插槽 | -- |
|
||||||
| header | 头部插槽 | -- |
|
| header | 头部插槽 | -- |
|
||||||
| body | 内容插槽 | -- |
|
| body | 内容插槽 | -- |
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
@ -7,7 +7,12 @@ export default {
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import "./index.less";
|
import "./index.less";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { ButtonBorder, ButtonNativeType, ButtonSize, ButtonType} from "./interface";
|
import {
|
||||||
|
ButtonBorder,
|
||||||
|
ButtonNativeType,
|
||||||
|
ButtonSize,
|
||||||
|
ButtonType,
|
||||||
|
} from "./interface";
|
||||||
import { BooleanOrString, String } from "src/types";
|
import { BooleanOrString, String } from "src/types";
|
||||||
|
|
||||||
export interface LayButtonProps {
|
export interface LayButtonProps {
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
border-radius: @card-border-radius;
|
border-radius: @card-border-radius;
|
||||||
background-color: @card-back-color;
|
background-color: @card-back-color;
|
||||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
||||||
.layui-card-header {
|
.layui-card-header {
|
||||||
height: 42px;
|
height: 42px;
|
||||||
line-height: 42px;
|
line-height: 42px;
|
||||||
@ -22,9 +21,9 @@
|
|||||||
border-bottom: 1px solid #f6f6f6;
|
border-bottom: 1px solid #f6f6f6;
|
||||||
color: @card-fore-color;
|
color: @card-fore-color;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
.layui-card-header-extra {
|
||||||
.layui-card-header-extra {
|
float: right;
|
||||||
float: right;
|
}
|
||||||
}
|
}
|
||||||
.layui-card-body {
|
.layui-card-body {
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
@ -35,3 +34,11 @@
|
|||||||
.layui-card:last-child {
|
.layui-card:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layui-card.is-hover-shadow:hover {
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-card.shadow {
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
@ -5,20 +5,32 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSlots } from "vue";
|
import { computed, useSlots } from "vue";
|
||||||
import "./index.less";
|
import "./index.less";
|
||||||
|
import { String } from 'src/types';
|
||||||
export interface LayCardProps {
|
import { CardShadow } from './interface';
|
||||||
title?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const slot = useSlots();
|
const slot = useSlots();
|
||||||
|
|
||||||
const props = defineProps<LayCardProps>();
|
export interface LayCardProps {
|
||||||
|
title?: String;
|
||||||
|
shadow?: CardShadow;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<LayCardProps>(), {
|
||||||
|
shadow:'always'
|
||||||
|
});
|
||||||
|
|
||||||
|
const classes = computed(() => {
|
||||||
|
return {
|
||||||
|
'shadow': props.shadow === 'always',
|
||||||
|
'is-hover-shadow': props.shadow === 'hover'
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="layui-card">
|
<div class="layui-card" :class="classes">
|
||||||
<div class="layui-card-header" v-if="slot.title || title || slot.extra">
|
<div class="layui-card-header" v-if="slot.title || title || slot.extra">
|
||||||
<span class="layui-card-header-title">
|
<span class="layui-card-header-title">
|
||||||
<slot name="title" v-if="slot.title"></slot>
|
<slot name="title" v-if="slot.title"></slot>
|
||||||
@ -34,11 +46,3 @@ const props = defineProps<LayCardProps>();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.layui-card-header-title {
|
|
||||||
}
|
|
||||||
|
|
||||||
.layui-card-header-extra {
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
export type CardShadow = 'always' | 'hover' | 'never'
|
Loading…
x
Reference in New Issue
Block a user