-
Notifications
You must be signed in to change notification settings - Fork 327
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
Functionality for switching between editing and interactive mode #674
base: main
Are you sure you want to change the base?
Changes from 3 commits
6dbe4a0
e6077d8
f3640c6
418e058
5c1e30b
c0d8607
e7127ac
fd41596
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,8 @@ export type AppContext< | |
plugins: Plugin[]; | ||
overrides: Partial<Overrides>; | ||
history: Partial<PuckHistory>; | ||
isInteractive: boolean; | ||
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. Any ideas for how you could add this to the 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. Is there any information about future release? How soon can I start using this changes? 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. done |
||
setIsInteractive: React.Dispatch<SetStateAction<boolean>> | ||
viewports: Viewports; | ||
zoomConfig: ZoomConfig; | ||
setZoomConfig: (zoomConfig: ZoomConfig) => void; | ||
|
@@ -90,10 +92,12 @@ const defaultContext: AppContext = { | |
dispatch: () => null, | ||
config: { components: {} }, | ||
componentState: {}, | ||
setComponentState: () => {}, | ||
resolveData: () => {}, | ||
setComponentState: () => { }, | ||
resolveData: () => { }, | ||
plugins: [], | ||
overrides: {}, | ||
isInteractive: false, | ||
setIsInteractive: () => { }, | ||
history: {}, | ||
viewports: defaultViewports, | ||
zoomConfig: { | ||
|
@@ -127,12 +131,15 @@ export const AppProvider = ({ | |
| "componentState" | ||
| "setComponentState" | ||
| "resolveData" | ||
| "setIsInteractive" | ||
>; | ||
}) => { | ||
const [zoomConfig, setZoomConfig] = useState(defaultContext.zoomConfig); | ||
|
||
const [status, setStatus] = useState<Status>("LOADING"); | ||
|
||
const [isInteractive, setIsInteractive] = useState(false); | ||
|
||
// App is ready when client has loaded, after initial render | ||
// This triggers DropZones to activate | ||
useEffect(() => { | ||
|
@@ -222,6 +229,8 @@ export const AppProvider = ({ | |
componentState, | ||
setComponentState, | ||
resolveData, | ||
isInteractive, | ||
setIsInteractive, | ||
}} | ||
> | ||
{children} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,19 +195,19 @@ export function Puck< | |
// Store categories under componentList on state to allow render functions and plugins to modify | ||
componentList: config.categories | ||
? Object.entries(config.categories).reduce( | ||
(acc, [categoryName, category]) => { | ||
return { | ||
...acc, | ||
[categoryName]: { | ||
title: category.title, | ||
components: category.components, | ||
expanded: category.defaultExpanded, | ||
visible: category.visible, | ||
}, | ||
}; | ||
}, | ||
{} | ||
) | ||
(acc, [categoryName, category]) => { | ||
return { | ||
...acc, | ||
[categoryName]: { | ||
title: category.title, | ||
components: category.components, | ||
expanded: category.defaultExpanded, | ||
visible: category.visible, | ||
}, | ||
}; | ||
}, | ||
{} | ||
) | ||
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 your local prettier is conflicting with the shared prettier. Can you run 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. done |
||
: {}, | ||
}, | ||
} as G["UserAppState"]; | ||
|
@@ -412,6 +412,7 @@ export function Puck< | |
config, | ||
plugins: plugins || [], | ||
overrides: loadedOverrides, | ||
isInteractive: false, | ||
history, | ||
viewports, | ||
iframe, | ||
|
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.
These would probably be better as a CSS class, passed to the
getClassName
function here.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.
done