2023-03-06 15:24:17 +08:00
|
|
|
/**
|
|
|
|
* {卡片组件}
|
|
|
|
* @author yutent<yutent.io@gmail.com>
|
|
|
|
* @date 2023/03/06 15:17:25
|
|
|
|
*/
|
|
|
|
|
2023-03-15 11:27:16 +08:00
|
|
|
import { css, html, Component } from '@bd/core'
|
2023-03-06 15:24:17 +08:00
|
|
|
|
|
|
|
class Card extends Component {
|
|
|
|
static props = {
|
2023-03-15 11:27:16 +08:00
|
|
|
header: ''
|
2023-03-06 15:24:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static styles = css`
|
|
|
|
:host {
|
|
|
|
display: flex;
|
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.card-box {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
border: 1px solid var(--color-plain-2);
|
2023-03-15 11:27:16 +08:00
|
|
|
border-radius: inherit;
|
2023-03-06 15:24:17 +08:00
|
|
|
background: #fff;
|
|
|
|
color: var(--color-dark-1);
|
|
|
|
transition: box-shadow 0.2s ease-in-out;
|
|
|
|
box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
|
|
|
|
|
2023-03-15 11:27:16 +08:00
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
width: 100%;
|
|
|
|
min-height: 52px;
|
|
|
|
padding: var(--card-padding, 8px 16px);
|
|
|
|
border-bottom: 1px solid var(--color-plain-2);
|
|
|
|
font-size: 16px;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
.content {
|
|
|
|
flex: 1;
|
|
|
|
min-height: 64px;
|
|
|
|
padding: var(--card-padding, 8px 16px);
|
|
|
|
font-size: 14px;
|
|
|
|
color: var(--color-dark-1);
|
|
|
|
}
|
2023-03-06 15:24:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
:host([shadow='never']) .card-box,
|
|
|
|
:host([shadow='hover']) .card-box {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
:host([shadow='hover']:hover) .card-box {
|
|
|
|
box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return html`
|
|
|
|
<div class="card-box">
|
2023-04-19 16:03:06 +08:00
|
|
|
<div class="header"><slot name="header">${this.header}</slot></div>
|
2023-03-27 19:34:30 +08:00
|
|
|
<div class="content"><slot></slot></div>
|
2023-03-06 15:24:17 +08:00
|
|
|
</div>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 16:50:02 +08:00
|
|
|
Card.reg('card')
|