Skip to content

Commit

Permalink
fix(calendar): demo拆解与规范 (#2137)
Browse files Browse the repository at this point in the history
* fix(calendar): demo拆解与规范

* fix(calendar): 修改demo规范,抽离公共类型

* chore: update

* chore: update

---------

Co-authored-by: oasis-cloud <[email protected]>
  • Loading branch information
mikasayw and oasis-cloud authored Mar 28, 2024
1 parent 9d60842 commit e9928f5
Show file tree
Hide file tree
Showing 32 changed files with 1,533 additions and 3,405 deletions.
10 changes: 3 additions & 7 deletions src/packages/calendar/__tests__/calendar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as React from 'react'
import { render, fireEvent } from '@testing-library/react'
import '@testing-library/jest-dom'
import { CalendarDay } from '@/packages/calendar/types'

import { Calendar } from '../calendar'

interface Day {
day: string | number
type: string
}

test('show-title prop', async () => {
const { container, rerender } = render(
<Calendar
Expand Down Expand Up @@ -93,11 +89,11 @@ test('should render slot correctly', async () => {
return <div className="d_div"> 最近七天</div>
}

const renderDay = (date: Day) => {
const renderDay = (date: CalendarDay) => {
return <span>custom{date.day}</span>
}

const renderDayBottom = (date: Day) => {
const renderDayBottom = (date: CalendarDay) => {
return <span>{Number(date.day) <= 10 ? '上旬' : '下旬'}</span>
}

Expand Down
6 changes: 1 addition & 5 deletions src/packages/calendar/calendar.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import Popup from '@/packages/popup/index.taro'
import CalendarItem from '@/packages/calendaritem/index.taro'
import { Utils } from '@/utils/date'
import { useConfig } from '@/packages/configprovider/configprovider.taro'
import type { CalendarDay, CalendarType } from './types'
import type { CalendarDay, CalendarType, CalendarRef } from './types'
import { ComponentDefaults } from '@/utils/typings'

type CalendarRef = {
scrollToDate: (date: string) => void
}

export interface CalendarProps {
type?: CalendarType
autoBackfill?: boolean
Expand Down
6 changes: 1 addition & 5 deletions src/packages/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import Popup from '@/packages/popup'
import CalendarItem from '@/packages/calendaritem'
import { Utils } from '@/utils/date'
import { useConfig } from '@/packages/configprovider'
import type { CalendarDay, CalendarType } from './types'
import type { CalendarDay, CalendarType, CalendarRef } from './types'
import { ComponentDefaults } from '@/utils/typings'

type CalendarRef = {
scrollToDate: (date: string) => void
}

export interface CalendarProps {
type?: CalendarType
autoBackfill?: boolean
Expand Down
Loading

0 comments on commit e9928f5

Please sign in to comment.