优化result组件

master
yutent 2023-11-16 15:25:15 +08:00
parent a156c9a236
commit 63a7892344
1 changed files with 42 additions and 67 deletions

View File

@ -9,83 +9,68 @@ import '../icon/index.js'
class Result extends Component {
static props = {
title: {
type: String,
default: '',
attribute: false
},
subTitle: { type: String, default: '' },
type: {
type: String,
default: 'success'
},
icon: {
type: String,
default: ''
}
title: 'str!',
subTitle: '',
type: 'success',
icon: ''
}
static styles = [
css`
:host {
position: relative;
display: inline-block;
text-align: center;
display: inline-flex;
}
:host([type='success']) .icon {
background: var(--color-teal-1);
}
:host([type='warning']) .icon {
background: #e6a23c;
wc-icon {
transform: translateY(-2px);
}
background: var(--color-orange-1);
}
:host([type='error']) .icon {
--wc-icon-size: 24px;
background: #f56c6c;
background: var(--color-red-1);
}
:host([type='info']) .icon {
background: #909399;
background: var(--color-blue-1);
}
.result {
.container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
box-sizing: border-box;
padding: 40px 30px;
}
.icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
max-width: 440px;
padding: 36px 32px;
line-height: 1.5;
font-size: 14px;
color: var(--color-dark-1);
}
.icon {
display: flex;
justify-content: center;
align-items: center;
width: 53px;
height: 53px;
width: 52px;
height: 52px;
line-height: 1;
border-radius: 50%;
background: var(--wc-result-icon-color, var(--color-dark-1));
color: #fff;
background: #67c23a;
}
.title {
margin-top: 20px;
margin-top: 16px;
font-size: 18px;
}
.sub-title {
margin-top: 10px;
margin-top: 6px;
}
.extra {
margin-top: 30px;
}
span {
font-size: 14px;
color: #5e6d82;
line-height: 1.5em;
margin-top: 12px;
}
`
]
get iconName() {
get #icon() {
if (this.icon) {
return this.icon
}
@ -93,38 +78,28 @@ class Result extends Component {
return 'get'
}
if (this.type === 'error') {
return 'close'
return 'deny'
}
return this.type
}
render() {
return html`
<div class="result">
<div class="icon-wrapper">
<slot name="icon">
<div class="icon">
<wc-icon name=${this.iconName}></wc-icon>
</div>
</slot>
<main class="container">
<div class="icon">
<slot name="icon"><wc-icon name=${this.#icon}></wc-icon></slot>
</div>
<div class="title">
<slot name="title">
<span>${this.title}</span>
</slot>
</div>
<h3 class="title">
<slot name="title">${this.title}</slot>
</h3>
<div class="sub-title">
<slot name="sub-title">
<span>${this.subTitle}</span>
</slot>
</div>
<section class="sub-title">
<slot name="sub-title">${this.subTitle}</slot>
</section>
<div class="extra">
<slot name="extra"></slot>
</div>
</div>
<cite class="extra"><slot></slot></cite>
</main>
`
}
}