-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Extract shell state into separate context #1824
Merged
pfrazee
merged 6 commits into
main
from
eric/app-906-extract-shell-state-into-separate-statecontext
Nov 7, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
10f5261
WIP
estrattonbailey 48c466f
Add shell state
estrattonbailey 703e7c2
Integrate new shell state for drawer and minimal shell mode
estrattonbailey c8161ff
Replace isDrawerSwipeDisabled
estrattonbailey 6a00424
Split shell state into separate contexts to avoid needless re-renders
pfrazee 262ae46
Fix typo
pfrazee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
|
||
type StateContext = boolean | ||
type SetContext = (v: boolean) => void | ||
|
||
const stateContext = React.createContext<StateContext>(false) | ||
const setContext = React.createContext<SetContext>((_: boolean) => {}) | ||
|
||
export function Provider({children}: React.PropsWithChildren<{}>) { | ||
const [state, setState] = React.useState(false) | ||
return ( | ||
<stateContext.Provider value={state}> | ||
<setContext.Provider value={setState}>{children}</setContext.Provider> | ||
</stateContext.Provider> | ||
) | ||
} | ||
|
||
export function useIsDrawerOpen() { | ||
return React.useContext(stateContext) | ||
} | ||
|
||
export function useSetDrawerOpen() { | ||
return React.useContext(setContext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
|
||
type StateContext = boolean | ||
type SetContext = (v: boolean) => void | ||
|
||
const stateContext = React.createContext<StateContext>(false) | ||
const setContext = React.createContext<SetContext>((_: boolean) => {}) | ||
|
||
export function Provider({children}: React.PropsWithChildren<{}>) { | ||
const [state, setState] = React.useState(false) | ||
return ( | ||
<stateContext.Provider value={state}> | ||
<setContext.Provider value={setState}>{children}</setContext.Provider> | ||
</stateContext.Provider> | ||
) | ||
} | ||
|
||
export function useIsDrawerSwipeDisabled() { | ||
return React.useContext(stateContext) | ||
} | ||
|
||
export function useSetDrawerSwipeDisabled() { | ||
return React.useContext(setContext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import {Provider as DrawerOpenProvider} from './drawer-open' | ||
import {Provider as DrawerSwipableProvider} from './drawer-swipe-disabled' | ||
import {Provider as MinimalModeProvider} from './minimal-mode' | ||
|
||
export {useIsDrawerOpen, useSetDrawerOpen} from './drawer-open' | ||
export { | ||
useIsDrawerSwipeDisabled, | ||
useSetDrawerSwipeDisabled, | ||
} from './drawer-swipe-disabled' | ||
export {useMinimalShellMode, useSetMinimalShellMode} from './minimal-mode' | ||
|
||
export function Provider({children}: React.PropsWithChildren<{}>) { | ||
return ( | ||
<DrawerOpenProvider> | ||
<DrawerSwipableProvider> | ||
<MinimalModeProvider>{children}</MinimalModeProvider> | ||
</DrawerSwipableProvider> | ||
</DrawerOpenProvider> | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
autorun
here doesn't make sense anymore.