Skip to content

Commit

Permalink
chore: getting ready for device controll container
Browse files Browse the repository at this point in the history
  • Loading branch information
henrynoowah committed Feb 10, 2025
1 parent 913c77e commit cc44b28
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/docs/data/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const data: Page = {
},
style: {
width: "100%",
maxWidth: "100%",
maxWidth: "1920px",
display: "flex",
flexDirection: "column",
gap: "24px",
Expand Down
19 changes: 15 additions & 4 deletions packages/ui/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,18 @@ Editor_.displayName = "Editor";
export default Editor;

const EditorContextMenu = ({ children }: { children: React.ReactNode }) => {
const { insertSection, addBlock, updateSelectedSection, selectedSectionRef } =
useEditorContext();
const {
insertSection,
addBlock,
updateSelectedSection,
selectedSectionRef,
themes,
} = useEditorContext();

const {
colors: { highlight },
} = themes;

return (
<ContextMenu
items={[
Expand Down Expand Up @@ -395,7 +405,7 @@ const EditorContextMenu = ({ children }: { children: React.ReactNode }) => {
style: {
width: "50%",
height: "50%",
backgroundColor: "white",
backgroundColor: highlight,
borderRadius: "12px",
display: "flex",
justifyContent: "center",
Expand Down Expand Up @@ -430,8 +440,9 @@ const EditorContextMenu = ({ children }: { children: React.ReactNode }) => {
content: `<h1>New Block ${nextIndex}</h1>`,
style: {
padding: "24px",
backgroundColor: "red",
backgroundColor: highlight,
zIndex: nextIndex,
borderRadius: "12px",
},
order: nextIndex,
};
Expand Down
33 changes: 25 additions & 8 deletions packages/ui/src/components/editor/EditorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EditorContext = ({
view = "web",
containerName = "content-container",
data,
children
children,
}: EditorContextProps) => {
const editorRef: MutableRefObject<Editor | null> = useRef(null);

Expand Down Expand Up @@ -84,9 +84,9 @@ export const EditorContext = ({
containerName,
themes: {
colors: {
highlight: COLORS.highlight
}
}
highlight: COLORS.highlight,
},
},
}}
>
<EditorContainer data={data} view={view} containerName={containerName}>
Expand All @@ -113,13 +113,30 @@ const EditorContainer = ({
return (
<div
style={{
...data?.style,
containerName,
width: "100%",
maxWidth: view === "web" ? undefined : "768px",
maxWidth: view === "web" ? "1920px" : "768px",
margin: "0 auto",
position: "relative",
}}
>
{children}
<div className="nwcb-flex nwcb-justify-between nwcb-items-center nwcb-w-full nwcb-h-12 nwcb-bg-white nwcb-p-4">
<div className="nwcb-flex nwcb-gap-2">
<button className="nwcb-w-8 nwcb-h-8 nwcb-bg-gray-200 nwcb-rounded-full nwcb-flex nwcb-justify-center nwcb-items-center">
{"<-"}
</button>
<button className="nwcb-w-8 nwcb-h-8 nwcb-bg-gray-200 nwcb-rounded-full nwcb-flex nwcb-justify-center nwcb-items-center">
{"->"}
</button>
</div>
</div>
<div
style={{
...data?.style,
containerName,
}}
>
{children}
</div>
</div>
);
};

0 comments on commit cc44b28

Please sign in to comment.