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

chore: add default blocks contents #343

Merged
merged 2 commits into from
Jul 23, 2024
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
148 changes: 138 additions & 10 deletions apps/studio/src/components/PageEditor/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,143 @@ export const DEFAULT_BLOCKS: Record<
},
],
},
accordion: undefined,
button: undefined,
callout: undefined,
accordion: {
type: "accordion",
summary: "Title for the accordion item",
details: {
type: "prose",
content: [
{
type: "paragraph",
content: [
{
type: "text",
text: "Enter content for the accordion here.",
},
],
},
],
},
},
button: {
type: "button",
label: "Button label",
href: "/button-url",
colorScheme: "black",
variant: "solid",
size: "base",
rightIcon: "right-arrow",
},
callout: {
type: "callout",
variant: "info",
content: {
type: "prose",
content: [
{
type: "paragraph",
content: [
{
type: "text",
text: "Callout content",
},
],
},
],
},
},
hero: undefined,
iframe: undefined,
image: undefined,
infobar: undefined,
infocards: undefined,
infocols: undefined,
infopic: undefined,
keystatistics: undefined,
iframe: {
type: "iframe",
title: "YouTube embed",
content:
'<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?si=ggGGn4uvFWAIelWD" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>',
},
image: {
type: "image",
src: "/images/1.png",
alt: "Add your alt text here",
},
infobar: {
type: "infobar",
title: "This is the main title",
description: "This is an optional description",
},
infocards: {
type: "infocards",
variant: "top",
title: "This is an optional title of the Infocards component",
subtitle: "This is an optional subtitle for the Infocards component",
cards: [
{
title: "This is the first card",
url: "https://www.google.com",
imageUrl: "https://placehold.co/200x200",
imageAlt: "This is the alt text",
},
{
title: "This is the second card",
url: "https://www.google.com",
imageUrl: "https://placehold.co/400x200",
imageAlt: "This is the alt text",
},
{
title: "This is the third card",
url: "https://www.google.com",
imageUrl: "https://placehold.co/500x200",
imageAlt: "This is the alt text",
},
],
},
infocols: {
type: "infocols",
title: "This is the main title of the InfoCols component",
subtitle: "This is an optional subtitle for the InfoCols component.",
infoBoxes: [
{
title: "This is the title of the first column",
description: "You can also add additional description here",
icon: "office-building",
},
{
title: "This is the title of the second column",
description: "You can also add additional description here",
icon: "stars",
},
{
title: "This is the title of the third column",
description: "You can also add additional description here",
icon: "globe",
},
],
},
infopic: {
type: "infopic",
title: "This is an infopic",
description: "This is the description for the infopic component",
imageSrc: "https://placehold.co/600x400",
},
keystatistics: {
type: "keystatistics",
variant: "top",
title: "Irrationality in numbers",
statistics: [
{
label: "Average all nighters pulled in a typical calendar month",
value: "3",
},
{
label: "Growth in tasks assigned Q4 2024 (YoY)",
value: "+12.2%",
},
{
label: "Creative blocks met per single evening",
value: "89",
},
{
value: "4.0",
label: "Number of lies in this stat block",
},
],
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import ComplexEditorStateDrawer from "./ComplexEditorStateDrawer"
import RootStateDrawer from "./RootStateDrawer"
import TipTapComponent from "./TipTapComponent"

const proseSchema = getComponentSchema("prose")
const ajv = new Ajv({ allErrors: true, strict: false, logger: false })
const validate = ajv.compile<ProseProps>(proseSchema)

export function EditPageDrawer() {
const {
previewPageState,
drawerState: currState,
currActiveIdx,
} = useEditorDrawerContext()

const proseSchema = getComponentSchema("prose")

const ajv = new Ajv({ allErrors: true, strict: false })
const validate = ajv.compile<ProseProps>(proseSchema)

const inferAsProse = (
component?: (typeof previewPageState)[number],
): ProseProps => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const renderers: JsonFormsRendererRegistryEntry[] = [
renderer: jsonFormsVerticalLayoutRenderer,
},
]
const ajv = new Ajv({ strict: false, logger: false })

export default function FormBuilder(): JSX.Element {
const {
Expand All @@ -76,7 +77,6 @@ export default function FormBuilder(): JSX.Element {

const subSchema = getComponentSchema(component.type)
const data = previewPageState[currActiveIdx]
const ajv = new Ajv({ strict: false })
const validateFn = ajv.compile<IsomerComponent>(subSchema)

return (
Expand All @@ -91,7 +91,7 @@ export default function FormBuilder(): JSX.Element {
setPreviewPageState(newPageState)
}
}}
ajv={new Ajv({ strict: false })}
ajv={ajv}
/>
)
}
2 changes: 1 addition & 1 deletion apps/studio/src/server/modules/page/page.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { getSiteConfig } from "../site/site.service"
import { createDefaultPage } from "./page.service"

const ajv = new Ajv({ allErrors: true, strict: false })
const ajv = new Ajv({ allErrors: true, strict: false, logger: false })
const schemaValidator = ajv.compile<IsomerSchema>(schema)

// TODO: Need to do validation like checking for existence of the page
Expand Down
Loading