-
Notifications
You must be signed in to change notification settings - Fork 832
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
Better recognition of touch devices #1653
Changes from all commits
ab5c99b
77ff855
ee842a5
b2c78b6
b09ae11
7c61217
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,27 +1,27 @@ | ||||||
import * as React from 'react'; | ||||||
import useMediaQuery from '@material-ui/core/useMediaQuery'; | ||||||
import { useTheme } from '@material-ui/core/styles'; | ||||||
import { IS_TOUCH_DEVICE_MEDIA } from '../constants/dimensions'; | ||||||
import { MobileWrapperProps, MobileWrapper } from './MobileWrapper'; | ||||||
import { DesktopWrapperProps, DesktopWrapper } from './DesktopWrapper'; | ||||||
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints'; | ||||||
import { DesktopPopperWrapperProps, DesktopPopperWrapper } from './DesktopPopperWrapper'; | ||||||
|
||||||
export interface ResponsiveWrapperProps | ||||||
extends DesktopWrapperProps, | ||||||
DesktopPopperWrapperProps, | ||||||
MobileWrapperProps { | ||||||
/** Breakpoint when `Desktop` mode will be changed to `Mobile` | ||||||
* @default 'md' | ||||||
/** Css media query when `Mobile` mode will be changed to `Desktop` | ||||||
* @default "@media (pointer: fine)" | ||||||
* @example "@media (min-width: 720px)" or theme.breakpoints.up("sm") | ||||||
*/ | ||||||
desktopModeBreakpoint?: Breakpoint; | ||||||
desktopModeMediaQuery?: string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you considered a shorter name for the prop?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the shorter variant is less expressive. What "desktop" means? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be interpreted as "a media query for desktop", definitely not as good as the information we can provide in a description. Adding mode definitely provide extra context. I don't know. I was wondering about this tradeoff of information vs length for the props, e.g. |
||||||
} | ||||||
|
||||||
export const makeResponsiveWrapper = ( | ||||||
DesktopWrapperComponent: React.FC<DesktopWrapperProps | DesktopPopperWrapperProps>, | ||||||
MobileWrapperComponent: React.FC<MobileWrapperProps> | ||||||
) => { | ||||||
const ResponsiveWrapper: React.FC<ResponsiveWrapperProps> = ({ | ||||||
desktopModeBreakpoint = 'md', | ||||||
desktopModeMediaQuery = IS_TOUCH_DEVICE_MEDIA, | ||||||
okLabel, | ||||||
cancelLabel, | ||||||
clearLabel, | ||||||
|
@@ -35,8 +35,7 @@ export const makeResponsiveWrapper = ( | |||||
displayStaticWrapperAs, | ||||||
...other | ||||||
}) => { | ||||||
const theme = useTheme(); | ||||||
const isDesktop = useMediaQuery(theme.breakpoints.up(desktopModeBreakpoint)); | ||||||
const isDesktop = useMediaQuery(desktopModeMediaQuery); | ||||||
|
||||||
return isDesktop ? ( | ||||||
<DesktopWrapperComponent | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of this variation to better match the style of the mono-repository for the description of the props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mobile
andDesktop
are used as prefixes for specific components (e.g.MobileDatePicker
) so it should be more clear for users. Isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mobile
andDesktop
are used as prefixes for specific components (e.g.MobileDatePicker
) so it should be more clear for users. Isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
Mobile
feels like it's a piece of code that can be used on its own. What about 1.MobileDatePicker
or 2. "mobile", I think that we would lose value if we try to compromise between these two options.