Skip to content

Commit

Permalink
DatePicker: better hover/focus styles (#65117)
Browse files Browse the repository at this point in the history
* DatePicker: better hover/focus styles

* CHANGELOG

* Use after pseudo-element to avoid conflict with calendar event dot

* Make event dots compatible with high contrast mode

* Apply box sizing utility

* Use themed colors

* Use translate to prevent event dot from jumping

---

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
5 people authored Sep 11, 2024
1 parent 2f939a7 commit 20ca80f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

- `Modal`: Decrease close button size and remove horizontal offset ([#65131](https://github.com/WordPress/gutenberg/pull/65131)).

### Bug Fixes

- `DatePicker`: better hover/focus styles ([#65117](https://github.com/WordPress/gutenberg/pull/65117)).

### Internal

- `Composite`: Remove from private APIs ([#63569](https://github.com/WordPress/gutenberg/pull/63569)).
Expand Down
42 changes: 31 additions & 11 deletions packages/components/src/date-time/date/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import styled from '@emotion/styled';
* Internal dependencies
*/
import Button from '../../button';
import { COLORS, CONFIG } from '../../utils';
import { boxSizingReset, COLORS, CONFIG } from '../../utils';
import { HStack } from '../../h-stack';
import { Heading } from '../../heading';
import { space } from '../../utils/space';

export const Wrapper = styled.div`
box-sizing: border-box;
${ boxSizingReset }
`;

export const Navigator = styled( HStack )`
Expand All @@ -38,7 +38,7 @@ export const Calendar = styled.div`
`;

export const DayOfWeek = styled.div`
color: ${ COLORS.gray[ 700 ] };
color: ${ COLORS.theme.gray[ 700 ] };
font-size: ${ CONFIG.fontSize };
line-height: ${ CONFIG.fontLineHeightBase };
Expand Down Expand Up @@ -90,31 +90,51 @@ export const DayButton = styled( Button, {
${ ( props ) =>
props.isSelected &&
`
background: ${ COLORS.theme.accent };
color: ${ COLORS.white };
background: ${ COLORS.theme.accent };
&,
&:hover:not(:disabled, [aria-disabled=true]) {
color: ${ COLORS.theme.accentInverted };
}
&:focus:not(:disabled),
&:focus:not(:disabled) {
border: ${ CONFIG.borderWidthFocus } solid currentColor;
}
/* Highlight the selected day for high-contrast mode */
&::after {
content: '';
position: absolute;
pointer-events: none;
inset: 0;
border-radius: inherit;
border: 1px solid transparent;
}
` }
${ ( props ) =>
! props.isSelected &&
props.isToday &&
`
background: ${ COLORS.gray[ 200 ] };
background: ${ COLORS.theme.gray[ 200 ] };
` }
}
${ ( props ) =>
props.hasEvents &&
`
::before {
background: ${ props.isSelected ? COLORS.white : COLORS.theme.accent };
border: 2px solid ${
props.isSelected
? COLORS.theme.accentInverted
: COLORS.theme.accent
};
border-radius: ${ CONFIG.radiusRound };
bottom: 2px;
content: " ";
height: 4px;
left: 50%;
margin-left: -2px;
position: absolute;
width: 4px;
transform: translate(-50%, 9px);
}
` }
`;

0 comments on commit 20ca80f

Please sign in to comment.