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

chore: rm today style of other panel #745

Merged
merged 2 commits into from
Jan 26, 2024
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: 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
Loading