Skip to content

Commit

Permalink
fix: enlarge calendar day hover area (#7750)
Browse files Browse the repository at this point in the history
* fix(Calendar): fix hover/active calendar day states

* fix(CalendarDay): fix calendar days hover

* fix: fix lint error

* test(CalendarDay): fix tests

---------

Co-authored-by: Victoria Zhizhonkova <indarklight@gmail.com>
  • Loading branch information
EldarMuhamethanov and BlackySoul authored Oct 16, 2024
1 parent 975878d commit 2848015
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 48 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions packages/vkui/src/components/CalendarDay/CalendarDay.module.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
.host {
.content {
border-radius: 0;
font-size: 14px;
color: var(--vkui--color_text_primary);
font-family: var(--vkui--font_family_base);
block-size: 100%;
}

.hidden,
.host {
block-size: 36px;
.host,
.hidden {
border-radius: 0;
flex-basis: calc(100% / 7);
flex-grow: 0;
}

.hiddenSizeS,
.hidden,
.content {
block-size: 36px;
}

.sizeS {
block-size: 34px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('CalendarDay', () => {
});
it('check hinted className', () => {
render(<CalendarDayTest hinted data-testid="day" />);
const calendarDay = screen.getByTestId('day').firstElementChild!;
const calendarDay = screen.getByTestId('day').firstElementChild!.firstElementChild!;
expect(calendarDay).toHaveClass(styles.hintedActive);
});

Expand Down
39 changes: 21 additions & 18 deletions packages/vkui/src/components/CalendarDay/CalendarDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,12 @@ export const CalendarDay: React.FC<CalendarDayProps> = React.memo(
}, [renderDayContent, day, children, label]);

if (hidden) {
return <div className={styles.hidden} />;
return <div className={classNames(styles.hidden, size === 's' && styles.sizeS)} />;
}

return (
<Tappable
className={classNames(
styles.host,
size === 's' && styles.sizeS,
today && styles.today,
selected && !disabled && styles.selected,
selectionStart && styles.selectionStart,
selectionEnd && styles.selectionEnd,
disabled && styles.disabled,
!sameMonth && styles.notSameMonth,
className,
)}
className={classNames(styles.host, size === 's' && styles.sizeS, className)}
hoverMode={styles.hostHovered}
activeMode={styles.hostActivated}
hasActive={false}
Expand All @@ -122,14 +112,27 @@ export const CalendarDay: React.FC<CalendarDayProps> = React.memo(
>
<div
className={classNames(
styles.hinted,
hinted && styles.hintedActive,
hintedSelectionStart && styles.hintedSelectionStart,
hintedSelectionEnd && styles.hintedSelectionEnd,
styles.content,
size === 's' && styles.sizeS,
today && styles.today,
selected && !disabled && styles.selected,
selectionStart && styles.selectionStart,
selectionEnd && styles.selectionEnd,
disabled && styles.disabled,
!sameMonth && styles.notSameMonth,
)}
>
<div className={classNames(styles.inner, active && !disabled && styles.innerActive)}>
{content}
<div
className={classNames(
styles.hinted,
hinted && styles.hintedActive,
hintedSelectionStart && styles.hintedSelectionStart,
hintedSelectionEnd && styles.hintedSelectionEnd,
)}
>
<div className={classNames(styles.inner, active && !disabled && styles.innerActive)}>
{content}
</div>
</div>
</div>
</Tappable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
flex-grow: 1;
}

.row:not(:last-child) {
.row:first-child:not(.rowSizeS) {
margin-block-end: 4px;
}

.rowSizeS:not(:last-child) {
margin-block-end: 0;
.row:not(:last-child):not(.rowSizeS) .rowDay {
padding-block-end: 2px;
}

.row:not(:nth-child(2)):not(.rowSizeS) .rowDay {
padding-block-start: 2px;
}

.weekday {
Expand Down
1 change: 1 addition & 0 deletions packages/vkui/src/components/CalendarDays/CalendarDays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const CalendarDays = ({
size={size}
renderDayContent={renderDayContent}
{...dayProps}
className={classNames(dayProps?.className, styles.rowDay)}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('CalendarRange', () => {
};

const getCalendarDayBlock = (part: HTMLElement, date: string) => {
return getByText(part, date).closest(`.${dayStyles.host}`) as HTMLElement;
return getByText(part, date).closest(`.${dayStyles.content}`) as HTMLElement;
};

const getLeftPart = () => {
Expand Down

0 comments on commit 2848015

Please sign in to comment.