Skip to content

Commit

Permalink
fix(DatePicker,DateRangePicker): fix the background color error when …
Browse files Browse the repository at this point in the history
…the cell is hovered (#3018)
  • Loading branch information
simonguo committed Jan 12, 2023
1 parent d8b7d15 commit 9d6f43e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/Calendar/TableHeaderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const TableHeaderRow: RsRefForwardingComponent<'div', TableHeaderRowProps> = Rea

return (
<Component role="row" {...rest} ref={ref} className={classes}>
{showWeekNumbers && <div className={prefix('cell')} role="columnheader" />}
{showWeekNumbers && <div className={prefix('header-cell')} role="columnheader" />}
{items.map(key => (
<div key={key} className={prefix('cell')} role="columnheader">
<span className={prefix('cell-content')}>{locale?.[key]}</span>
<div key={key} className={prefix('header-cell')} role="columnheader">
<span className={prefix('header-cell-content')}>{locale?.[key]}</span>
</div>
))}
</Component>
Expand Down
31 changes: 15 additions & 16 deletions src/Calendar/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@
}
}

.rs-calendar-table-cell {
.rs-calendar-table-cell,
.rs-calendar-table-header-cell {
display: table-cell;
width: 1%;
padding: @calendar-table-cell-padding 0;
Expand Down Expand Up @@ -418,21 +419,19 @@
}

// Table header row
.rs-calendar-table-header-row {
.rs-calendar-table-cell-content {
color: var(--rs-text-secondary);
font-size: @font-size-small;
line-height: @line-height-small;
padding-top: 2px;
padding-bottom: 2px;

&,
&:hover,
&:focus,
&:hover:focus {
background: none;
cursor: auto;
}
.rs-calendar-table-header-cell-content {
color: var(--rs-text-secondary);
font-size: @font-size-small;
line-height: @line-height-small;
padding-top: 2px;
padding-bottom: 2px;

&,
&:hover,
&:focus,
&:hover:focus {
background: none;
cursor: auto;
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/DatePicker/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import '../../styles/mixins/listbox';
@import '../../Button/styles/mixin';
@import '../../Picker/styles/mixin';
@import 'mixin';

// DatePicker Picker
// ----------------------
Expand Down Expand Up @@ -91,6 +92,10 @@
.listbox-option-active();
}

.rs-calendar-month-dropdown-cell-active .rs-calendar-month-dropdown-cell-content:hover {
.calendar-cell-selected-hover();
}

.rs-calendar-table-header-row .rs-calendar-table-cell-content {
height: 24px;
padding-top: 0;
Expand All @@ -109,6 +114,10 @@
.listbox-option-active();
}

.rs-calendar-table-cell-selected:hover .rs-calendar-table-cell-content {
.calendar-cell-selected-hover();
}

.rs-calendar-month-dropdown-scroll {
height: 227px;
}
Expand Down
8 changes: 8 additions & 0 deletions src/DatePicker/styles/mixin.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.calendar-cell-selected-hover() {
background-color: var(--rs-calendar-cell-selected-hover-bg);
color: var(--rs-calendar-date-selected-text);

.high-contrast-mode({
color: var(--rs-calendar-date-selected-text);
});
}
1 change: 1 addition & 0 deletions src/styles/color-modes/dark.less
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
--rs-calendar-range-bg: fade(@H900-dark, 50%);
--rs-calendar-time-unit-bg: @B600-dark;
--rs-calendar-date-selected-text: #fff;
--rs-calendar-cell-selected-hover-bg: @H700;

// Popover
--rs-popover-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
Expand Down
1 change: 1 addition & 0 deletions src/styles/color-modes/high-contrast.less
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
--rs-calendar-range-bg: fade(@H900-high-contrast, 50%);
--rs-calendar-time-unit-bg: @B900-high-contrast;
--rs-calendar-date-selected-text: @B900-high-contrast;
--rs-calendar-cell-selected-hover-bg: @B050-high-contrast;

// Popover
--rs-popover-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
Expand Down
1 change: 1 addition & 0 deletions src/styles/color-modes/light.less
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
--rs-calendar-range-bg: fade(@H100, 50%);
--rs-calendar-time-unit-bg: @B050;
--rs-calendar-date-selected-text: #fff;
--rs-calendar-cell-selected-hover-bg: @H700;

// Popover
--rs-popover-shadow: 0 1px 8px rgba(0, 0, 0, 0.12);
Expand Down

1 comment on commit 9d6f43e

@vercel
Copy link

@vercel vercel bot commented on 9d6f43e Jan 12, 2023

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.