Files
react-test/docs/data/material/getting-started/templates/dashboard/theme/customizations/datePickers.ts
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

174 lines
6.1 KiB
TypeScript

import { alpha, Theme } from '@mui/material/styles';
import type { PickersProComponents } from '@mui/x-date-pickers-pro/themeAugmentation';
import type { PickerComponents } from '@mui/x-date-pickers/themeAugmentation';
import { menuItemClasses } from '@mui/material/MenuItem';
import { pickersDayClasses, yearCalendarClasses } from '@mui/x-date-pickers';
import { gray, brand } from '../../../shared-theme/themePrimitives';
/* eslint-disable import/prefer-default-export */
export const datePickersCustomizations: PickersProComponents<Theme> & PickerComponents<Theme> = {
MuiPickerPopper: {
styleOverrides: {
paper: ({ theme }) => ({
marginTop: 4,
borderRadius: theme.shape.borderRadius,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
backgroundImage: 'none',
background: 'hsl(0, 0%, 100%)',
boxShadow:
'hsla(220, 30%, 5%, 0.07) 0px 4px 16px 0px, hsla(220, 25%, 10%, 0.07) 0px 8px 16px -5px',
[`& .${menuItemClasses.root}`]: {
borderRadius: 6,
margin: '0 6px',
},
...theme.applyStyles('dark', {
background: gray[900],
boxShadow:
'hsla(220, 30%, 5%, 0.7) 0px 4px 16px 0px, hsla(220, 25%, 10%, 0.8) 0px 8px 16px -5px',
}),
}),
},
},
MuiPickersArrowSwitcher: {
styleOverrides: {
spacer: { width: 16 },
button: ({ theme }) => ({
backgroundColor: 'transparent',
color: (theme.vars || theme).palette.grey[500],
...theme.applyStyles('dark', {
color: (theme.vars || theme).palette.grey[400],
}),
}),
},
},
MuiPickersCalendarHeader: {
styleOverrides: {
switchViewButton: {
padding: 0,
border: 'none',
},
},
},
MuiMonthCalendar: {
styleOverrides: {
button: ({ theme }) => ({
fontSize: theme.typography.body1.fontSize,
color: (theme.vars || theme).palette.grey[600],
padding: theme.spacing(0.5),
borderRadius: theme.shape.borderRadius,
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${yearCalendarClasses.selected}`]: {
backgroundColor: gray[700],
fontWeight: theme.typography.fontWeightMedium,
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${yearCalendarClasses.selected}`]: { backgroundColor: gray[700] },
},
...theme.applyStyles('dark', {
color: (theme.vars || theme).palette.grey[300],
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${yearCalendarClasses.selected}`]: {
color: (theme.vars || theme).palette.common.black,
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: gray[300],
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${yearCalendarClasses.selected}`]: { backgroundColor: gray[300] },
},
}),
}),
},
},
MuiYearCalendar: {
styleOverrides: {
button: ({ theme }) => ({
fontSize: theme.typography.body1.fontSize,
color: (theme.vars || theme).palette.grey[600],
padding: theme.spacing(0.5),
borderRadius: theme.shape.borderRadius,
height: 'fit-content',
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${yearCalendarClasses.selected}`]: {
backgroundColor: gray[700],
fontWeight: theme.typography.fontWeightMedium,
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${yearCalendarClasses.selected}`]: { backgroundColor: gray[700] },
},
...theme.applyStyles('dark', {
color: (theme.vars || theme).palette.grey[300],
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${yearCalendarClasses.selected}`]: {
color: (theme.vars || theme).palette.common.black,
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: gray[300],
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${yearCalendarClasses.selected}`]: { backgroundColor: gray[300] },
},
}),
}),
},
},
MuiPickersDay: {
styleOverrides: {
root: ({ theme }) => ({
fontSize: theme.typography.body1.fontSize,
color: (theme.vars || theme).palette.grey[600],
padding: theme.spacing(0.5),
borderRadius: theme.shape.borderRadius,
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${pickersDayClasses.selected}`]: {
backgroundColor: gray[700],
fontWeight: theme.typography.fontWeightMedium,
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${pickersDayClasses.selected}`]: { backgroundColor: gray[700] },
},
...theme.applyStyles('dark', {
color: (theme.vars || theme).palette.grey[300],
'&:hover': {
backgroundColor: (theme.vars || theme).palette.action.hover,
},
[`&.${pickersDayClasses.selected}`]: {
color: (theme.vars || theme).palette.common.black,
fontWeight: theme.typography.fontWeightMedium,
backgroundColor: gray[300],
},
'&:focus': {
outline: `3px solid ${alpha(brand[500], 0.5)}`,
outlineOffset: '2px',
backgroundColor: 'transparent',
[`&.${pickersDayClasses.selected}`]: { backgroundColor: gray[300] },
},
}),
}),
},
},
};