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

[DatePicker] smaller static date picker on desktop #27700

Open
1 task done
scottlamb opened this issue Aug 11, 2021 · 2 comments
Open
1 task done

[DatePicker] smaller static date picker on desktop #27700

scottlamb opened this issue Aug 11, 2021 · 2 comments
Labels
component: date picker This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@scottlamb
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

I'd like the static date picker to be smaller on desktop, perhaps matching the material ui specification:

image

The specification describes a total width of 256 pixels. material-ui's implementation is 320 pixels wide. This is wide enough to be problematic for my layout.

I'd prefer smaller by default, but a well-supported way to customize sizing would also be fine with me.

Examples 🌈

https://codesandbox.io/s/relaxed-fermat-o3htk?file=/src/Demo.tsx shows both the original formatting and roughly the formatting I'd like. The latter I managed to get with <Box sx={{...}}> (quoting the relevant part below). Unfortunately, it's ridiculously fragile. Eg, I had to adapt it when upgrading from 5.0.0-alpha.26 to 5.0.0-beta.3.

      <Box
        sx={{
          "& > div": {
            minWidth: 256
          },
          "& > div > div, & > div > div > div, & .MuiCalendarPicker-root": {
            width: 256
          },
          "& .MuiTypography-caption": {
            width: DATE_SIZE,
            margin: 0
          },
          "& .PrivatePickersSlideTransition-root": {
            minHeight: DATE_SIZE * 6
          },
          '& .PrivatePickersSlideTransition-root [role="row"]': {
            margin: 0
          },
          "& .MuiPickersDay-dayWithMargin": {
            margin: 0
          },
          "& .MuiPickersDay-root": {
            width: DATE_SIZE,
            height: DATE_SIZE
          }
        }}
      >
        <StaticDatePicker ... />
      </Box>

Motivation 🔦

I'm writing a network video recorder and want a design with a static datepicker in a column. It's static rather than a pop-up because it displays useful context about what dates have video/motion/etc. But space is precious; I have a large main column of video (or tabular data or whatever) to show. So I don't want big touch-friendly targets when I'm on desktop with a mouse or trackpad available.

@scottlamb scottlamb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 11, 2021
@eps1lon eps1lon added component: date picker This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 12, 2021
@oliviertassinari oliviertassinari changed the title smaller static date picker on desktop [DatePicker] smaller static date picker on desktop Aug 21, 2021
@oliviertassinari
Copy link
Member

Agree, we didn't solve it in the original repo, see the same unresolved issue: mui/material-ui-pickers#1648.

@Mheaus
Copy link

Mheaus commented Jan 18, 2023

<Box
        sx={{
          "& > div": {
            minWidth: 256
          },
          "& > div > div, & > div > div > div, & .MuiCalendarPicker-root": {
            width: 256
          },
          "& .MuiTypography-caption": {
            width: DATE_SIZE,
            margin: 0
          },
          "& .PrivatePickersSlideTransition-root": {
            minHeight: DATE_SIZE * 6
          },
          '& .PrivatePickersSlideTransition-root [role="row"]': {
            margin: 0
          },
          "& .MuiPickersDay-dayWithMargin": {
            margin: 0
          },
          "& .MuiPickersDay-root": {
            width: DATE_SIZE,
            height: DATE_SIZE
          }
        }}
      >

Thank you very much, today it seems like there's still zero options to change the size of a static picker in a simple way.
At least it works with your sx definition.

I changed the classnames with the classes exported from mui packages.
I'm using @mui/x-date-pickers@5.0.9 StaticDatePicker and PickerDay component.

Here's mine :

sx={{
  '& > div > div': {
    minWidth: 256,
  },
  [`& > div > div, & > div > div > div, & > div > div > div > div, & .${calendarPickerClasses.root}`]: {
    width: 256,
  },
  [`& .${pickersCalendarHeaderClasses.root}`]: {
    minHeight: '34px',
    maxHeight: '34px',
    paddingLeft: '16px',
    paddingRight: '8px',
  },
  [`& .${pickersCalendarHeaderClasses.labelContainer}`]: {
    maxHeight: '34px',
  },
  [`& .${typographyClasses.caption}`]: {
    width: DATE_SIZE,
    margin: 0,
  },
  [`& .${pickersSlideTransitionClasses.root}`]: {
    minHeight: DATE_SIZE * 6,
  },
  [`& .${pickersSlideTransitionClasses.root} [role="row"]`]: {
    margin: 0,
  },
  [`& .${pickersDayClasses.root}`]: {
    width: DATE_SIZE,
    height: DATE_SIZE,
  },
  [`& .${pickersDayClasses.dayWithMargin}`]: {
    margin: 0,
  },
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: date picker This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants