Skip to content

Expose mobile{Keyboard,Default}ViewIcon props from PickerToolbar #1706

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

Closed
wants to merge 2 commits into from

Conversation

Philipp91
Copy link
Contributor

This PR closes #1693.

@vercel vercel bot temporarily deployed to Preview April 24, 2020 19:40 Inactive
@vercel
Copy link

vercel bot commented Apr 24, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/mui-org/material-ui-pickers/ex6xx9xsz
✅ Preview: https://material-ui-pickers-git-fork-philipp91-iconprop.mui-org.now.sh

The button should be identified by its functionality and not be its icon (also the pen icon is only one of the two icons used on that button).
…ses #1693)

To make the previously hard-coded icons configurable.
@cypress
Copy link

cypress bot commented Apr 24, 2020



Test summary

73 0 1 0


Run details

Project material-ui-pickers
Status Passed
Commit 7b9a510
Started Apr 24, 2020 7:47 PM
Ended Apr 24, 2020 7:48 PM
Duration 01:27 💡
OS Linux Debian - 9.11
Browser Chrome 78

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@@ -95,16 +99,12 @@ const PickerToolbar: React.SFC<PickerToolbarProps> = ({
{children}
<IconButton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we need to also expose props that passing directly to this component.

MobileKeyboardButtonProps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. At that point, maybe we should remove mobileKeyboardViewButtonClassName? To me it seems like it's just yet another prop on that component -- or are classNames worth treating explicitly in general?

The onClick={toggleMobileKeyboardView} is probably worth keeping as a separate prop, as it must be implemented by the user of the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well, mobileKeyboardViewButtonClassName is used by all the Toolbar implementations, so let's keep it.

Copy link
Contributor Author

@Philipp91 Philipp91 Apr 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you proposed "MobileKeyboardButtonProps". I called it "mobileKeyboardViewButtonClassName" so far. Now I realised that there's already "getMobileKeyboardInputViewButtonText = defaultGetKeyboardInputSwitchingButtonText" in the code. Probably we shouldn't have 4 different terms for the same button.

Currently, the DateTimePicker also shows this button on desktop (because it uses the toolbar in its popover, because it has so many different views). Is that desired and will stay like that (then I'd propose to not have "mobile" in the name of this button), or should the desktop DateTimePicker not have the button (then I can send a separate PR to hide it there).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmtrKovalenko @oliviertassinari Any opinions on whether the view switching button should be shown on desktop at all?

And what's the proper name for this button?

Comment on lines 4 to +5
import ClockIcon from '@material-ui/icons/AccessTime';
import PenIcon from '@material-ui/icons/Edit';
Copy link
Member

@oliviertassinari oliviertassinari Apr 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the two imports above?

Suggested change
import ClockIcon from '@material-ui/icons/AccessTime';
import PenIcon from '@material-ui/icons/Edit';
import AccessTimeIcon from '@material-ui/icons/AccessTime';
import EditIcon from '@material-ui/icons/Edit';

@@ -35,6 +35,8 @@ export type ToolbarComponentProps<
timeIcon?: React.ReactNode;
isLandscape: boolean;
ampmInClock?: boolean;
mobileKeyboardViewIcon?: React.ReactNode;
mobileDefaultViewIcon?: React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better name will be

Suggested change
mobileDefaultViewIcon?: React.ReactNode;
mobilePickerViewIcon?: React.ReactNode;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also if it is a public API it should be documented in jsdoc. I am not sure where we are documenting props for Toolbar but please try just adding here a comment with description

dmtrKovalenko added a commit that referenced this pull request Jul 14, 2020
@dmtrKovalenko dmtrKovalenko mentioned this pull request Jul 14, 2020
1 task
@oliviertassinari
Copy link
Member

@Philipp91 Thanks for the pull request. Unfortunately, we can't accept it here. On-going work was moved to v5 in the main repository: https://next.material-ui.com/components/date-picker/.

I have transferred the linked issue to mui/material-ui#23604.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants