Skip to content

Commit

Permalink
feat(mainui): provide hideUI status through core provider
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn authored Sep 26, 2021
1 parent 3e2365d commit 2288635
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/my-gatsby-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@chakra-ui/react": "^1.6.7",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@snek-at/jaen": "^2.0.0-beta.27",
"@snek-at/jaen": "^2.0.0-beta.28",
"@snek-at/jaen-pages": "^2.0.0-beta.45",
"framer-motion": "^4",
"gatsby": "^3.11.1",
Expand Down
6 changes: 4 additions & 2 deletions examples/my-gatsby-site/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ const links = [

// markup
const IndexPage = () => {
const {toggleUI} = useJaenCoreContext()
const {toggleHideUI, hideUI} = useJaenCoreContext()

return (
<main style={pageStyles}>
<Button onClick={toggleUI}>Bye bye snek</Button>
<Button onClick={toggleHideUI}>
{hideUI ? 'Hi Hi - ' : 'Bye bye - '}snek
</Button>
{/* <fields.ImageField
fieldName="imagefield1"
initValue={{
Expand Down
2 changes: 1 addition & 1 deletion packages/jaen-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@loadable/component": "^5.15.0",
"@react-icons/all-files": "^4.1.0",
"@reduxjs/toolkit": "^1.6.1",
"@snek-at/jaen": "^2.0.0-beta.27",
"@snek-at/jaen": "^2.0.0-beta.28",
"@snek-at/jaen-shared-ui": "2.0.0-beta.20",
"@snek-at/snek-finder": "^1.0.0-beta.15",
"deepmerge": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/jaen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snek-at/jaen",
"version": "2.0.0-beta.27",
"version": "2.0.0-beta.28",
"main": "index.js",
"types": "src/index.ts",
"license": "EUPL-1.2",
Expand Down
7 changes: 4 additions & 3 deletions packages/jaen/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {PluginCallbacks, getPublishValue, getUI, Plugin} from './plugin'
import {store} from './store/index'

export type JaenCoreContextType = {
toggleUI: () => void
toggleHideUI: () => void
hideUI: boolean
remote: string
} & PluginCallbacks
export const JaenCoreContext = React.createContext<
Expand Down Expand Up @@ -63,7 +64,7 @@ export const JaenCoreProvider: React.FC<JaenCoreProviderProps> = ({
}
}, [hideUI])

const toggleUI = () => {
const toggleHideUI = () => {
if (typeof window !== 'undefined') {
// check current main ui status in local storage and reverse it

Expand All @@ -77,7 +78,7 @@ export const JaenCoreProvider: React.FC<JaenCoreProviderProps> = ({

return (
<JaenCoreContext.Provider
value={{onPublish, getAuthState, toggleUI, remote}}>
value={{onPublish, getAuthState, toggleHideUI, hideUI, remote}}>
{!hideUI && <MainUI ui={ui} />}
{children}
</JaenCoreContext.Provider>
Expand Down

0 comments on commit 2288635

Please sign in to comment.