fix(calendar): 优化选中日期时切换按钮的显示样式和文本
- 将选中日期时的按钮文本从“选中 YYYY-MM-DD”简化为“更改日期”,提升简洁性 - 为按钮添加日历图标,并通过动态类名在选中和未选中状态间切换颜色 - 使用 flex 布局优化图标与文本的对齐,并添加状态颜色过渡效果
Showing
1 changed file
with
19 additions
and
5 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-01-25 15:34:17 | 2 | * @Date: 2025-01-25 15:34:17 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2026-01-23 10:38:40 | 4 | + * @LastEditTime: 2026-01-23 13:38:31 |
| 5 | * @FilePath: /mlaj/src/components/calendar/CollapsibleCalendar.vue | 5 | * @FilePath: /mlaj/src/components/calendar/CollapsibleCalendar.vue |
| 6 | * @Description: 可折叠日历组件 | 6 | * @Description: 可折叠日历组件 |
| 7 | --> | 7 | --> |
| ... | @@ -29,7 +29,23 @@ | ... | @@ -29,7 +29,23 @@ |
| 29 | <div class="calendar-date-display" @click="expandCalendar"> | 29 | <div class="calendar-date-display" @click="expandCalendar"> |
| 30 | <div class="calendar-date-main">{{ formattedCurrentDate }}</div> | 30 | <div class="calendar-date-main">{{ formattedCurrentDate }}</div> |
| 31 | <div class="calendar-weekday">{{ formattedWeekday }}</div> | 31 | <div class="calendar-weekday">{{ formattedWeekday }}</div> |
| 32 | - <div v-if="!isHeaderHidden" class="text-xs text-gray-500 mt-1 collapsible-text px-3 py-1 bg-white text-center rounded-full border border-gray-200 inline-block min-w-[5rem] max-w-[8rem]">{{ toggleButtonText }}</div> | 32 | + <div |
| 33 | + v-if="!isHeaderHidden" | ||
| 34 | + class="text-xs mt-1 collapsible-text px-3 py-1 text-center rounded-full border inline-flex items-center justify-center gap-1 min-w-[5rem] transition-colors duration-200" | ||
| 35 | + :class="[ | ||
| 36 | + hasSelectedDate | ||
| 37 | + ? 'text-green-600 bg-green-50 border-green-200 font-medium' | ||
| 38 | + : 'text-gray-500 bg-white border-gray-200' | ||
| 39 | + ]" | ||
| 40 | + > | ||
| 41 | + <span>{{ toggleButtonText }}</span> | ||
| 42 | + <svg width="12" height="12" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" :class="{'text-green-600': hasSelectedDate, 'text-gray-400': !hasSelectedDate}"> | ||
| 43 | + <path d="M19 4H5C3.89543 4 3 4.89543 3 6V20C3 21.1046 3.89543 22 5 22H19C20.1046 22 21 21.1046 21 20V6C21 4.89543 20.1046 4 19 4Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
| 44 | + <path d="M16 2V6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
| 45 | + <path d="M8 2V6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
| 46 | + <path d="M3 10H21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
| 47 | + </svg> | ||
| 48 | + </div> | ||
| 33 | </div> | 49 | </div> |
| 34 | <!-- <div class="calendar-action"> | 50 | <!-- <div class="calendar-action"> |
| 35 | <div class="calendar-action-text">指定日期</div> | 51 | <div class="calendar-action-text">指定日期</div> |
| ... | @@ -334,9 +350,7 @@ const formattedWeekday = computed(() => { | ... | @@ -334,9 +350,7 @@ const formattedWeekday = computed(() => { |
| 334 | 350 | ||
| 335 | const toggleButtonText = computed(() => { | 351 | const toggleButtonText = computed(() => { |
| 336 | if (!props.hasSelectedDate) return '切换日期' | 352 | if (!props.hasSelectedDate) return '切换日期' |
| 337 | - const date_val = props.modelValue || currentDate.value | 353 | + return '更改日期' |
| 338 | - const text = dayjs(date_val).format('YYYY-MM-DD') | ||
| 339 | - return `选中 ${text}` | ||
| 340 | }) | 354 | }) |
| 341 | 355 | ||
| 342 | /** | 356 | /** | ... | ... |
-
Please register or login to post a comment