feat(Calendar): add color prop

This commit is contained in:
陈嘉涵
2019-12-27 18:01:51 +08:00
committed by neverland
parent 56e450f29e
commit 3250804791
10 changed files with 203 additions and 5 deletions
+14 -3
View File
@@ -8,6 +8,7 @@ export default createComponent({
props: {
date: Date,
type: String,
color: String,
minDate: Date,
maxDate: Date,
showMark: Boolean,
@@ -129,7 +130,7 @@ export default createComponent({
}
},
getDayStyle(index) {
getDayStyle(type, index) {
const style = {};
if (index === 0) {
@@ -140,6 +141,14 @@ export default createComponent({
style.height = `${this.rowHeight}px`;
}
if (this.color) {
if (type === 'start' || type === 'end') {
style.background = this.color;
} else if (type === 'middle') {
style.color = this.color;
}
}
return style;
},
@@ -168,7 +177,7 @@ export default createComponent({
genDay(item, index) {
const { type, topInfo, bottomInfo } = item;
const style = this.getDayStyle(index);
const style = this.getDayStyle(type, index);
const onClick = () => {
if (type !== 'disabled') {
@@ -179,7 +188,9 @@ export default createComponent({
if (type === 'selected') {
return (
<div style={style} class={bem('day')} onClick={onClick}>
<div class={bem('selected-day')}>{item.text}</div>
<div class={bem('selected-day')} style={{ background: this.color }}>
{item.text}
</div>
</div>
);
}