Skip to content
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

fix: editor overflow & change elements type #11

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dashboard/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const initialElements: OGElement[] = [
{
id: createElementId(),
tag: 'div',
name: 'Box',
x: 0,
y: 0,
width: 1200,
Expand Down
5 changes: 5 additions & 0 deletions apps/dashboard/src/components/EditorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function EditorToolbar() {
<div className="rounded-md border border-gray-100 bg-white z-10 flex flex-row items-center">
<ToolbarButton element={{
tag: 'p',
name: 'Text',
width: 100,
height: 50,
visible: true,
Expand All @@ -46,6 +47,7 @@ export function EditorToolbar() {
<div className="w-[1px] h-4 bg-gray-100" />
<ToolbarButton element={{
tag: 'div',
name: 'Box',
width: 200,
height: 200,
visible: true,
Expand All @@ -58,6 +60,7 @@ export function EditorToolbar() {
<div className="w-[1px] h-4 bg-gray-100" />
<ToolbarButton element={{
tag: 'div',
name: 'Rounded box',
width: 150,
height: 150,
visible: true,
Expand All @@ -71,6 +74,7 @@ export function EditorToolbar() {
<div className="w-[1px] h-4 bg-gray-100" />
<ToolbarButton element={{
tag: 'div',
name: 'Image',
width: 200,
height: 150,
visible: true,
Expand All @@ -85,6 +89,7 @@ export function EditorToolbar() {
<div className="w-[1px] h-4 bg-gray-100" />
<ToolbarButton element={{
tag: 'span',
name: 'Dynamic text',
width: 312,
height: 50,
visible: true,
Expand Down
51 changes: 21 additions & 30 deletions apps/dashboard/src/components/LeftPanel/ElementRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,27 @@ export function ElementRow({ element }: ElementRowProps) {
onClick={() => { setSelectedElement(element.id); }}
type="button"
>
{element.tag === 'p' ? (
<>
<TextIcon height="1.4em" width="1.4em" />
{element.content.slice(0, 25)}
</>
) : null}
{element.tag === 'div' && element.backgroundImage ? (
<>
<ImageIcon height="1.4em" width="1.4em" />
Image
</>
) : null}
{element.tag === 'div' && !element.backgroundImage && !element.radius ? (
<>
<BoxIcon height="1.4em" width="1.4em" />
Box
</>
) : null}
{element.tag === 'div' && !element.backgroundImage && element.radius ? (
<>
<CircleIcon height="1.4em" width="1.4em" />
Rounded box
</>
) : null}
{element.tag === 'span' ? (
<>
<MagicWandIcon height="1.4em" width="1.4em" />
Dynamic text
</>
) : null}
{element.tag === 'p'
? <TextIcon height="1.4em" width="1.4em" />
: null
}
{element.tag === 'div' && element.backgroundImage
? <ImageIcon height="1.4em" width="1.4em" />
: null
}
{element.tag === 'div' && !element.backgroundImage && !element.radius
? <BoxIcon height="1.4em" width="1.4em" />
: null
}
{element.tag === 'div' && !element.backgroundImage && element.radius
? <CircleIcon height="1.4em" width="1.4em" />
: null
}
{element.tag === 'span'
? <MagicWandIcon height="1.4em" width="1.4em" />
: null
}
{element.name}
</button>
<button
className="text-gray-600 hover:text-gray-900"
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/OgEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function OgEditor({ initialElements, width, height }: OgProviderProps) {

return (
<OgContext.Provider value={value}>
<div className="w-screen h-screen flex flex-row justify-between items-center bg-gray-50">
<div className="w-screen h-screen flex flex-row justify-between items-center bg-gray-50 overflow-hidden">
<div className="w-[300px] h-screen flex flex-col border-r border-gray-100 shadow-lg shadow-gray-100 bg-white z-10">
<LeftPanel />
</div>
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Font } from "./fonts"
export type OGElement = (OGPElement | OGDynamicElement | OGDivElement)
& {
id: string
name: string
x: number
y: number
width: number
Expand Down