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

[pickers] Allow reusing Year and Month button in slots #14066

Open
Kurt2189 opened this issue Aug 1, 2024 · 5 comments
Open

[pickers] Allow reusing Year and Month button in slots #14066

Kurt2189 opened this issue Aug 1, 2024 · 5 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! customization: css Design CSS customizability enhancement This is not a bug, nor a new feature support: docs-feedback Feedback from documentation page

Comments

@Kurt2189
Copy link

Kurt2189 commented Aug 1, 2024

Related page

https://mui.com/x/react-date-pickers/date-calendar/

Kind of issue

Missing information

Issue description

I would like to know if it is possible to mark not only days, but also months and years on a calendar

Context

Dynamic year or month

Search keywords: Dynamic year or month

@Kurt2189 Kurt2189 added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Aug 1, 2024
@LukasTy
Copy link
Member

LukasTy commented Aug 1, 2024

Hello @Kurt2189.
Have you tried using monthButton or yearButton slot to achieve what you are asking? 🤔

@LukasTy LukasTy added status: waiting for author Issue with insufficient information component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 1, 2024
@Kurt2189
Copy link
Author

Kurt2189 commented Aug 1, 2024

I tried, but unfortunately I haven’t achieved any results yet. I would like to pass an array of certain years and in the calendar, if the year matches the value of my array, then somehow indicate it with a checkmark. Sorry if my question seemed stupid.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Aug 1, 2024
@LukasTy LukasTy self-assigned this Aug 1, 2024
@LukasTy
Copy link
Member

LukasTy commented Aug 1, 2024

@Kurt2189 Do you mean something like this? 🤔

Applying conditional slotProps looks easy, but if you want to create a custom component, I think that we should expose the YearCalendarButton component we use to make it easier because otherwise, everything needs to be replicated... 🤷

const YearCalendarButton = styled('button', {
name: 'MuiPickersYear',
slot: 'YearButton',
overridesResolver: (_, styles) => [
styles.yearButton,
{ [`&.${pickersYearClasses.disabled}`]: styles.disabled },
{ [`&.${pickersYearClasses.selected}`]: styles.selected },
],
})<{ ownerState: PickersYearProps }>(({ theme }) => ({
color: 'unset',
backgroundColor: 'transparent',
border: 0,
outline: 0,
...theme.typography.subtitle1,
margin: '6px 0',
height: 36,
width: 72,
borderRadius: 18,
cursor: 'pointer',
'&:focus': {
backgroundColor: theme.vars
? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.focusOpacity})`
: alpha(theme.palette.action.active, theme.palette.action.focusOpacity),
},
'&:hover': {
backgroundColor: theme.vars
? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})`
: alpha(theme.palette.action.active, theme.palette.action.hoverOpacity),
},
'&:disabled': {
cursor: 'auto',
pointerEvents: 'none',
},
[`&.${pickersYearClasses.disabled}`]: {
color: (theme.vars || theme).palette.text.secondary,
},
[`&.${pickersYearClasses.selected}`]: {
color: (theme.vars || theme).palette.primary.contrastText,
backgroundColor: (theme.vars || theme).palette.primary.main,
'&:focus, &:hover': {
backgroundColor: (theme.vars || theme).palette.primary.dark,
},
},
}));

@LukasTy LukasTy removed their assignment Aug 1, 2024
@LukasTy LukasTy added status: waiting for author Issue with insufficient information customization: css Design CSS customizability and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 1, 2024
@Kurt2189
Copy link
Author

Kurt2189 commented Aug 2, 2024

"Sometimes it may be necessary to display additional info right in the calendar. The following demo shows how to add a badge on some day based on server-side data" but how i can this for month or year picker. I want add badge on month or year.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Aug 2, 2024
@LukasTy
Copy link
Member

LukasTy commented Aug 2, 2024

@Kurt2189 To enable the exact same behavior, we would need to publicly expose the mentioned component and a similar component on the MonthCalendar.
I'm adding this issue to the grooming board to check with the team if we agree with such a solution. 😉

@LukasTy LukasTy added enhancement This is not a bug, nor a new feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 2, 2024
@LukasTy LukasTy changed the title [docs] Dynamic year or month [pickers] Allow reusing Year and Month button in slots Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! customization: css Design CSS customizability enhancement This is not a bug, nor a new feature support: docs-feedback Feedback from documentation page
Projects
None yet
Development

No branches or pull requests

2 participants