Skip to content

Commit

Permalink
feat: support config of emphasisWeek
Browse files Browse the repository at this point in the history
  • Loading branch information
todrfu committed Oct 16, 2020
1 parent 5db503b commit f9ad3e3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/v2/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const conf = {
inverse: true, // 单选模式下是否支持取消选中,
markToday: '', // 当天日期展示不使用默认数字,用特殊文字标记
takeoverTap: true, // 是否完全接管日期点击事件(日期不会选中)
emphasisWeek: true, // 是否高亮显示周末日期
chooseAreaMode: true, // 开启日期范围选择模式,该模式下只可选择时间段
showHolidays: true, // 显示法定节假日班/休情况,需引入holidays插件
showFestival: true, // 显示节日信息(如教师节等),需引入holidays插件
Expand Down
4 changes: 2 additions & 2 deletions src/component/v2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function calculatePrevMonthGrids(year, month, config) {
empytGrids.push({
...YMInfo,
date: i,
day: week || 7
week
})
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ function calculateNextMonthGrids(year, month, config) {
id: i - 1,
...YMInfo,
date: i,
day: week || 7
week: week || 7
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/v2/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</view>
<!-- 本月日期格子 -->
<view wx:for="{{calendar.dates}}" wx:key="index" data-idx="{{index}}" data-info="{{item}}" bindtap="tapDate" class="grid {{item.class ? item.class : ''}} {{config.theme}}_normal-date b ac pc">
<view class="date-wrap b cc {{(item.week === 0 || item.week === 6) ? config.theme + '_weekend-color' : ''}}">
<view class="date-wrap b cc {{config.emphasisWeek && (item.week === 0 || item.week === 6) ? config.theme + '_weekend-color' : ''}}">
<view class="date b ac pc {{item.class ? item.class : ''}} {{item.isToday && config.highlightToday ? config.theme + '_today' : ''}} {{item.choosed ? config.theme + '_choosed' : ''}} {{item.disable ? config.theme + '_date-disable' : ''}} {{config.chooseAreaMode ? 'date-area-mode' : ''}}">
{{config.markToday && item.isToday ? config.markToday : item.date}}
<view
Expand Down
4 changes: 2 additions & 2 deletions src/component/v2/plugins/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function getDatesWhenTargetInFirstWeek(target, firstWeekDates) {
year: prevMonthInfo.year,
month: prevMonthInfo.month,
date: lastMonthDatsCount,
day: week
week
})
lastMonthDatsCount -= 1
}
Expand All @@ -95,7 +95,7 @@ function getDatesWhenTargetInLastWeek(target, lastWeekDates) {
year: prevMonthInfo.year,
month: prevMonthInfo.month,
date: i + 1,
day: week
week
})
}
return dates
Expand Down
2 changes: 1 addition & 1 deletion src/component/v2/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class DateUtil {
id: i - 1,
month: +month,
date: i,
day: week || 7,
week,
isToday:
+today.year === +year && +today.month === +month && i === +today.date
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/calendarV2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const conf = {
calendarConfig: {
// theme: 'elegant',
// showHolidays: true,
// emphasisWeek: true,
chooseAreaMode: true
// defaultDate: '2020-9-8',
// autoChoosedWhenJump: true
Expand Down

0 comments on commit f9ad3e3

Please sign in to comment.