Skip to content

feat(calendar-view): [calendar-view]add attributes #3525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/sites/demos/apis/calendar-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ export default {
'en-US': 'Should the upper left button be displayed, Default Display'
},
meta: {
stable: '3.22.0'
stable: '3.25.0'
},
mode: ['mobile-first'],
mode: ['pc', 'mobile-first'],
pcDemo: 'calendar-mode',
mfDemo: 'calendar-mode'
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<tiny-calendar-view :events="eventslist" :year="2023" :month="6" :modes="['month', 'timeline', 'schedule']">
<tiny-calendar-view
:events="eventslist"
:year="2023"
:month="6"
:modes="['month', 'timeline', 'schedule']"
:show-back-today="false"
>
</tiny-calendar-view>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ test('显示模式', async ({ page }) => {
const dmonthDom = page.locator('.tiny-calendar-view-month__main')
const timelineDom = page.locator('.tiny-calendar-view-week__timeline')
const scheduleDom = page.locator('.tiny-calendar-view-week__schedule')

const calendarHeader = page.locator('.tiny-calendar-view__header')
await expect(calendarHeader.locator('div').first()).not.toHaveClass('.tiny-button .tiny-button--default')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the CSS selector syntax in the test assertion.

The selector .tiny-button .tiny-button--default uses descendant selector syntax (space-separated), but you likely want to check that the element doesn't have both classes. Consider using .tiny-button.tiny-button--default (dot-separated) or check for individual classes separately.

-  await expect(calendarHeader.locator('div').first()).not.toHaveClass('.tiny-button .tiny-button--default')
+  await expect(calendarHeader.locator('div').first()).not.toHaveClass(/tiny-button/)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await expect(calendarHeader.locator('div').first()).not.toHaveClass('.tiny-button .tiny-button--default')
await expect(calendarHeader.locator('div').first()).not.toHaveClass(/tiny-button/)
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/calendar-view/calendar-mode.spec.ts at line 14,
the CSS selector in the test assertion incorrectly uses a descendant selector
'.tiny-button .tiny-button--default' to check for classes on a single element.
Replace the selector with '.tiny-button.tiny-button--default' to correctly check
that the element does not have both classes simultaneously.

// 验证按钮是否选中,验证时间组件页面是否正确
await expect(monthBtn.locator('.tiny-svg')).toHaveClass(/fill-brand/)
await expect(dmonthDom).toBeVisible()
Expand Down
8 changes: 7 additions & 1 deletion examples/sites/demos/pc/app/calendar-view/calendar-mode.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<tiny-calendar-view :events="eventslist" :year="2023" :month="6" :modes="['month', 'timeline', 'schedule']">
<tiny-calendar-view
:events="eventslist"
:year="2023"
:month="6"
:modes="['month', 'timeline', 'schedule']"
:show-back-today="false"
>
</tiny-calendar-view>
</template>

Expand Down
11 changes: 7 additions & 4 deletions packages/vue/src/calendar-view/src/pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="tiny-calendar-view" :style="{ 'height': typeof height === 'number' ? height + 'px' : height }">
<div class="tiny-calendar-view__header">
<div>
<tiny-button @click="toToday">{{ t('ui.calendarView.backToday') }}</tiny-button>
<tiny-button v-if="showBackToday" @click="toToday">{{ t('ui.calendarView.backToday') }}</tiny-button>
</div>
<tiny-date-picker
v-model="state.currentDate"
Expand Down Expand Up @@ -123,9 +123,11 @@
:class="[date.value.split('-')[2] > 9 ? 'is-two-digit' : '', markColor ? `mark-${markColor}` : '']"
></span>
</span>
<span class="week-day" :class="[dateIsToday(date.value) && 'is-today', { current: computedSelectDay(date) }]">{{
dateIsToday(date.value) ? t('ui.datepicker.today') : t(`ui.calendarView.weekDays.${index}`)
}}</span>
<span
class="week-day"
:class="[dateIsToday(date.value) && 'is-today', { current: computedSelectDay(date) }]"
>{{ dateIsToday(date.value) ? t('ui.datepicker.today') : t(`ui.calendarView.weekDays.${index}`) }}</span
>
</slot>
</li>
</ul>
Expand Down Expand Up @@ -285,6 +287,7 @@ export default defineComponent({
'height',
'markColor',
'multiSelect',
'showBackToday',
'showTipTime'
],
setup(props, context) {
Expand Down
Loading