-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: templates * refactor: single page * fix: fully static * feat: improve splash
- Loading branch information
Showing
21 changed files
with
337 additions
and
93 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function Templates() { | ||
return ( | ||
<p>Todo</p> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,32 +1,12 @@ | ||
'use client' | ||
import { OgEditor } from "../components/OgEditor"; | ||
import { createElementId } from "../lib/elements"; | ||
import type { OGElement } from "../lib/types"; | ||
|
||
/** | ||
* The initial elements to render in the editor. | ||
* | ||
* It only contains a single element, a white background that | ||
* takes the entire width and height of the editor. | ||
*/ | ||
const initialElements: OGElement[] = [ | ||
{ | ||
id: createElementId(), | ||
tag: 'div', | ||
name: 'Box', | ||
x: 0, | ||
y: 0, | ||
width: 1200, | ||
height: 630, | ||
visible: true, | ||
rotate: 0, | ||
opacity: 100, | ||
backgroundColor: '#ffffff', | ||
}, | ||
] | ||
import { Suspense } from "react"; | ||
import { OgSplash } from "../components/OgSplash"; | ||
|
||
export default function Home() { | ||
return ( | ||
<OgEditor height={630} initialElements={initialElements} width={1200} /> | ||
// OgSplash uses `useSearchParams()` so we need to wrap it in a Suspense | ||
// to allow to statically render the page: https://nextjs.org/docs/app/building-your-application/rendering/server-components#dynamic-functions | ||
<Suspense> | ||
<OgSplash /> | ||
</Suspense> | ||
) | ||
} |
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,5 @@ | ||
export default function Templates() { | ||
return ( | ||
<p>Todo</p> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Link from "next/link" | ||
import type { ReactNode } from "react" | ||
|
||
interface CustomLinkProps { | ||
icon?: ReactNode | ||
iconPosition?: 'left' | 'right' | ||
href: string | ||
children: ReactNode | ||
} | ||
|
||
export function CustomLink({ icon, iconPosition = 'left', href, children }: CustomLinkProps) { | ||
return ( | ||
<Link className="flex gap-2 items-center px-3 py-1 rounded-full text-gray-600 hover:text-gray-900 hover:bg-gray-50" href={href}> | ||
{icon && iconPosition === 'left' ? icon : null} | ||
{children} | ||
{icon && iconPosition === 'right' ? icon : null} | ||
</Link> | ||
) | ||
} | ||
|
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
2 changes: 1 addition & 1 deletion
2
apps/dashboard/src/components/LeftPanel/ModificationsSection.tsx
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,12 @@ | ||
import { CustomLink } from "../CustomLink"; | ||
import { ArrowLeftIcon } from "../icons/ArrowLeftIcon"; | ||
|
||
export function SplashSection() { | ||
return ( | ||
<CustomLink href="/" icon={<ArrowLeftIcon />}> | ||
Back | ||
</CustomLink> | ||
) | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import usePromise from "react-promise-suspense" | ||
import { createElementStyle } from "../lib/elements" | ||
import { exportToSvg } from "../lib/export" | ||
import { loadFonts } from "../lib/fonts" | ||
import type { OGElement } from "../lib/types" | ||
|
||
async function loadOgImage(elements: OGElement[]) { | ||
const fonts = await loadFonts(elements) | ||
const reactLike = { | ||
type: 'div', | ||
props: { | ||
style: { | ||
display: 'flex', | ||
width: '100%', | ||
height: '100%', | ||
}, | ||
children: elements.map(element => ({ | ||
type: element.tag, | ||
props: { | ||
style: createElementStyle(element), | ||
...(element.tag === 'p' ? { children: element.content } : {}), | ||
}, | ||
})) | ||
} | ||
} | ||
|
||
const svg = await exportToSvg(reactLike, fonts) | ||
return `data:image/svg+xml;base64,${btoa(svg)}` | ||
} | ||
|
||
interface OgImageProps { | ||
elements: OGElement[] | ||
} | ||
|
||
export function OgImage({ elements }: OgImageProps) { | ||
const src = usePromise(loadOgImage, [elements]) | ||
|
||
return <img alt="" src={src} /> | ||
} |
Oops, something went wrong.