mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
demo: optimize calendar demo (#48939)
This commit is contained in:
parent
356ead5919
commit
9744ab6501
@ -82,6 +82,12 @@ const useStyle = createStyles(({ token, css, cx }) => {
|
||||
opacity: 0.8;
|
||||
}
|
||||
`,
|
||||
weekend: css`
|
||||
color: ${token.colorError};
|
||||
`,
|
||||
gray: css`
|
||||
filter: grayscale(1);
|
||||
`,
|
||||
};
|
||||
});
|
||||
|
||||
@ -104,6 +110,7 @@ const App: React.FC = () => {
|
||||
const d = Lunar.fromDate(date.toDate());
|
||||
const lunar = d.getDayInChinese();
|
||||
const solarTerm = d.getJieQi();
|
||||
const isWeekend = date.day() === 6 || date.day() === 0;
|
||||
const h = HolidayUtil.getHoliday(date.get('year'), date.get('month') + 1, date.get('date'));
|
||||
const displayHoliday = h?.getTarget() === h?.getDay() ? h?.getName() : undefined;
|
||||
if (info.type === 'date') {
|
||||
@ -115,7 +122,14 @@ const App: React.FC = () => {
|
||||
}),
|
||||
children: (
|
||||
<div className={styles.text}>
|
||||
{date.get('date')}
|
||||
<span
|
||||
className={classNames({
|
||||
[styles.weekend]: isWeekend,
|
||||
[styles.gray]: !info.today.isSame(date, 'M'),
|
||||
})}
|
||||
>
|
||||
{date.get('date')}
|
||||
</span>
|
||||
{info.type === 'date' && (
|
||||
<div className={styles.lunar}>{displayHoliday || solarTerm || lunar}</div>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user