-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[MediaQueryProvider] Add media query provider #2117
Conversation
9ad816a
to
821f784
Compare
import {LinkContext} from '../../../utilities/link'; | ||
import {AppProvider} from '../AppProvider'; | ||
|
||
describe('<AppProvider />', () => { | ||
beforeEach(() => { |
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.
AppProvider renders MediaQueryProvider
now which uses matchMedia and since jsdom doesn't provide it, we'll need it mock it.
const navigation = <div />; | ||
const frame = mountWithAppProvider( | ||
<Frame showMobileNavigation navigation={navigation} />, | ||
{mediaQuery: {isNavigationCollapsed: true}}, |
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.
This passes the value to PolarisTestProvider
which passes it to MediaQueryContext.Provider
to mock isNavigationCollapsed
children?: React.ReactNode; | ||
} | ||
|
||
export const MediaQueryProvider = function MediaQueryProvider({ |
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.
We check the breakpoint, when the state is initialized, after the first render and during resize.
interface State { | ||
mobileView?: boolean; | ||
} | ||
export function Header({ |
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.
After removing the breakpoint logic I was able to convert Header into a functional component 😄
a1cc5e7
to
a5807d2
Compare
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.
🎉 😅
codecov so close!
a5807d2
to
d8c0d1c
Compare
WHY are these changes introduced?
Reduce duplicated logic and add a location where we can easily add to it
WHAT is this pull request doing?
How to 🎩
You'll want to check Filters, Frame, Navigation, Page and Sheet in the deployment across screen sizes to ensure navigation collapsed is still working correctly.
🎩 checklist
README.md
with documentation changes