Skip to content

Commit

Permalink
chore: rm today style of other panel (#745)
Browse files Browse the repository at this point in the history
* chore: rm today style

* test: update snapshot
  • Loading branch information
zombieJ committed Jan 26, 2024
1 parent bbc3160 commit 23c3016
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/PickerPanel/DecadePanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import type { DisabledDate, SharedPanelProps } from '../../interface';
import { formatValue, isSameDecade } from '../../utils/dateUtil';
import { formatValue } from '../../utils/dateUtil';
import { PanelContext, useInfo } from '../context';
import PanelBody from '../PanelBody';
import PanelHeader from '../PanelHeader';
Expand All @@ -14,7 +14,7 @@ export default function DecadePanel<DateType extends object = any>(
const panelPrefixCls = `${prefixCls}-decade-panel`;

// ========================== Base ==========================
const [info, now] = useInfo(props, 'decade');
const [info] = useInfo(props, 'decade');
const startYear = Math.floor(generateConfig.getYear(pickerValue) / 100) * 100;
const endYear = startYear + 99;

Expand Down Expand Up @@ -49,7 +49,6 @@ export default function DecadePanel<DateType extends object = any>(
const dateYear = generateConfig.getYear(date);
return {
[`${prefixCls}-cell-in-view`]: startYear <= dateYear && dateYear <= endYear,
[`${prefixCls}-cell-today`]: isSameDecade(generateConfig, date, now),
};
};

Expand Down
7 changes: 3 additions & 4 deletions src/PickerPanel/MonthPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import type { DisabledDate, SharedPanelProps } from '../../interface';
import { formatValue, isSameMonth } from '../../utils/dateUtil';
import { formatValue } from '../../utils/dateUtil';
import { PanelContext, useInfo } from '../context';
import PanelBody from '../PanelBody';
import PanelHeader from '../PanelHeader';
Expand All @@ -21,7 +21,7 @@ export default function MonthPanel<DateType extends object = any>(
const panelPrefixCls = `${prefixCls}-month-panel`;

// ========================== Base ==========================
const [info, now] = useInfo(props, 'month');
const [info] = useInfo(props, 'month');
const baseDate = generateConfig.setMonth(pickerValue, 0);

// ========================= Month ==========================
Expand All @@ -48,9 +48,8 @@ export default function MonthPanel<DateType extends object = any>(
: monthsLocale[month];
};

const getCellClassName = (date: DateType) => ({
const getCellClassName = () => ({
[`${prefixCls}-cell-in-view`]: true,
[`${prefixCls}-cell-today`]: isSameMonth(generateConfig, date, now),
});

// ======================== Disabled ========================
Expand Down
7 changes: 3 additions & 4 deletions src/PickerPanel/QuarterPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import type { SharedPanelProps } from '../../interface';
import { formatValue, isSameQuarter } from '../../utils/dateUtil';
import { formatValue } from '../../utils/dateUtil';
import { PanelContext, useInfo } from '../context';
import PanelBody from '../PanelBody';
import PanelHeader from '../PanelHeader';
Expand All @@ -14,7 +14,7 @@ export default function QuarterPanel<DateType extends object = any>(
const panelPrefixCls = `${prefixCls}-quarter-panel`;

// ========================== Base ==========================
const [info, now] = useInfo(props, 'quarter');
const [info] = useInfo(props, 'quarter');
const baseDate = generateConfig.setMonth(pickerValue, 0);

// ========================= Cells ==========================
Expand All @@ -30,9 +30,8 @@ export default function QuarterPanel<DateType extends object = any>(
});
};

const getCellClassName = (date: DateType) => ({
const getCellClassName = () => ({
[`${prefixCls}-cell-in-view`]: true,
[`${prefixCls}-cell-today`]: isSameQuarter(generateConfig, date, now),
});

// ========================= Header =========================
Expand Down
5 changes: 2 additions & 3 deletions src/PickerPanel/YearPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import type { DisabledDate, SharedPanelProps } from '../../interface';
import { formatValue, isSameYear } from '../../utils/dateUtil';
import { formatValue } from '../../utils/dateUtil';
import { PanelContext, useInfo } from '../context';
import PanelBody from '../PanelBody';
import PanelHeader from '../PanelHeader';
Expand All @@ -21,7 +21,7 @@ export default function YearPanel<DateType extends object = any>(
const panelPrefixCls = `${prefixCls}-year-panel`;

// ========================== Base ==========================
const [info, now] = useInfo(props, 'year');
const [info] = useInfo(props, 'year');
const startYear = Math.floor(generateConfig.getYear(pickerValue) / 10) * 10;
const endYear = startYear + 9;

Expand All @@ -47,7 +47,6 @@ export default function YearPanel<DateType extends object = any>(
const dateYear = generateConfig.getYear(date);
return {
[`${prefixCls}-cell-in-view`]: startYear <= dateYear && dateYear <= endYear,
[`${prefixCls}-cell-today`]: isSameYear(generateConfig, date, now),
};
};

Expand Down
20 changes: 10 additions & 10 deletions tests/__snapshots__/panel.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ exports[`Picker.Panel append cell with cellRender in decade 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
>
<div
class="rc-picker-cell-inner customInner"
Expand Down Expand Up @@ -1073,7 +1073,7 @@ exports[`Picker.Panel append cell with cellRender in month 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-09"
>
<div
Expand Down Expand Up @@ -1214,7 +1214,7 @@ exports[`Picker.Panel append cell with cellRender in quarter 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-Q3"
>
<div
Expand Down Expand Up @@ -4139,7 +4139,7 @@ exports[`Picker.Panel append cell with cellRender in year 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990"
>
<div
Expand Down Expand Up @@ -4363,7 +4363,7 @@ exports[`Picker.Panel monthCellRender 1`] = `
1990-08
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-09"
>
1990-09
Expand Down Expand Up @@ -5060,7 +5060,7 @@ exports[`Picker.Panel override cell with cellRender in decade 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
>
<div
class="customWrapper"
Expand Down Expand Up @@ -5217,7 +5217,7 @@ exports[`Picker.Panel override cell with cellRender in month 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-09"
>
<div
Expand Down Expand Up @@ -5334,7 +5334,7 @@ exports[`Picker.Panel override cell with cellRender in quarter 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-Q3"
>
<div
Expand Down Expand Up @@ -7503,7 +7503,7 @@ exports[`Picker.Panel override cell with cellRender in year 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990"
>
<div
Expand Down Expand Up @@ -9722,7 +9722,7 @@ exports[`Picker.Panel pass dateRender when picker is month 1`] = `
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-09"
>
<div
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/range.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ exports[`Picker.Range use dateRender and monthCellRender in month range picker 1
</div>
</td>
<td
class="rc-picker-cell rc-picker-cell-in-view rc-picker-cell-today"
class="rc-picker-cell rc-picker-cell-in-view"
title="1990-09"
>
<div>
Expand Down

1 comment on commit 23c3016

@vercel
Copy link

@vercel vercel bot commented on 23c3016 Jan 26, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.