Skip to content
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

feat(Calendar2): 支持主题配置 #5010

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .fusion
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@
"input": "lib/input/scss/variable.scss",
"select": "lib/select/scss/variable.scss",
"calendar": "lib/calendar/scss/variable.scss",
"calendar2": "lib/calendar2/scss/variable.scss",
"card": "lib/card/scss/variable.scss",
"cascader": "lib/cascader/scss/variable.scss",
"cascader-select": "lib/cascader-select/scss/variable.scss",
"collapse": "lib/collapse/scss/variable.scss",
"time-picker": "lib/time-picker/scss/variable.scss",
"date-picker": "lib/date-picker/scss/variable.scss",
"date-picker2": "lib/date-picker2/scss/variable.scss",
"drawer": "lib/drawer/scss/variable.scss",
"message": "lib/message/scss/variable.scss",
"dialog": "lib/dialog/scss/variable.scss",
Expand Down
123 changes: 123 additions & 0 deletions components/calendar2/__docs__/theme/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import dayjs, { type Dayjs } from 'dayjs';
import React from 'react';
import ReactDOM from 'react-dom';
import { Demo, DemoGroup, initDemo } from '../../../demo-helper';
import Calendar from '../../index';
import type { CalendarProps } from '../../types';
import ConfigProvider from '../../../config-provider';
import zhCN from '../../../locale/zh-cn';
import enUS from '../../../locale/en-us';
import '../../../demo-helper/style';
import '../../style';

const i18nMap = {
'zh-cn': {
dateFullscreenCalendar: '全屏日历',
cardCalendar: '卡片日历',
panelCalendar: '面板日历',
month: '月',
year: '年',

normal: '普通',
},
'en-us': {
dateFullscreenCalendar: 'Fullscreen',
cardCalendar: 'Card',
panelCalendar: 'Panel',

month: 'Month',
year: 'Year',

normal: 'Normal',
},
};

const wrappedCalendarStyle = {
width: '320px',
overflow: 'hidden',
};

const wrappedRangeCalendarStyle = {
width: '600px',
overflow: 'hidden',
};

function render(i18n: any, lang: string) {
const currentDate = dayjs();
const calendarValue = currentDate.clone().add(1, 'days');

const disabledDate: CalendarProps['disabledDate'] = function (date: Dayjs) {
return date.valueOf() > currentDate.clone().add(3, 'days').valueOf();
};

ReactDOM.render(
<ConfigProvider locale={lang === 'en-us' ? enUS : zhCN}>
<div className="demo-container">
<Demo title={i18n.dateFullscreenCalendar}>
<Demo title={i18n.month}>
<DemoGroup label={i18n.normal}>
<Calendar
disabledDate={disabledDate}
value={calendarValue.clone().add(-1, 'months')}
mode="month"
/>
</DemoGroup>
</Demo>
</Demo>

<Demo title={i18n.cardCalendar}>
<Demo title={i18n.month}>
<DemoGroup label={i18n.normal}>
<div style={wrappedCalendarStyle}>
<Calendar
shape="card"
disabledDate={disabledDate}
value={calendarValue.clone().add(-1, 'months')}
mode="month"
/>
</div>
</DemoGroup>
</Demo>
</Demo>

<Demo title={i18n.panelCalendar}>
<Demo title={i18n.month}>
<DemoGroup label={i18n.normal}>
<div style={wrappedCalendarStyle}>
<Calendar
shape="panel"
disabledDate={disabledDate}
value={calendarValue.clone().add(-1, 'months')}
mode="month"
/>
</div>
</DemoGroup>
</Demo>

<Demo title={i18n.year}>
<DemoGroup label={i18n.normal}>
<div style={wrappedCalendarStyle}>
<Calendar
shape="panel"
disabledDate={disabledDate}
value={calendarValue.clone().add(-1, 'years')}
mode="year"
/>
</div>
</DemoGroup>
</Demo>
</Demo>
</div>
</ConfigProvider>,
document.getElementById('container')
);
}

window.renderDemo = function (lang = 'en-us') {
dayjs.locale(lang);
render(i18nMap[lang], lang);
};

renderDemo();

initDemo('calendar2');
Loading
Loading