-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add gb * chore: add story * fix: add missing msw handler for story * chore: update link category on dropdown click * chore: add type * chore: add more stories
- Loading branch information
Showing
9 changed files
with
179 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const BANNER_FEATURE_KEY = "isomer-next-banner" | ||
export const ISOMER_ADMIN_FEATURE_KEY = "isomer_admins" | ||
export const CATEGORY_DROPDOWN_FEATURE_KEY = "category-dropdown" |
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
71 changes: 71 additions & 0 deletions
71
apps/studio/src/stories/Page/EditPage/components/JsonFormsCategoryControl.stories.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { Type } from "@sinclair/typebox" | ||
import { pageHandlers } from "tests/msw/handlers/page" | ||
|
||
import { | ||
JsonFormsCategoryControl, | ||
jsonFormsCategoryControlTester, | ||
} from "~/features/editing-experience/components/form-builder/renderers/controls/JsonFormsCategoryControl" | ||
import { createDropdownGbParameters } from "~/stories/utils/growthbook" | ||
import { FormBuilder } from "./formBuilder" | ||
|
||
const meta: Meta<typeof FormBuilder> = { | ||
title: "Pages/Edit Page/components/JsonFormsCategoryControl", | ||
component: FormBuilder, | ||
parameters: { | ||
msw: { | ||
handlers: [pageHandlers.getCategories.default()], | ||
}, | ||
nextjs: { | ||
router: { | ||
query: { | ||
siteId: "1", | ||
pageId: "1", | ||
}, | ||
pathname: "/sites/[siteId]/pages/[pageId]", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof JsonFormsCategoryControl> | ||
|
||
const schema = Type.Object({ | ||
category: Type.String({ | ||
title: "Article category", | ||
format: "category", | ||
description: | ||
"The category is used for filtering in the parent collection page", | ||
}), | ||
}) | ||
|
||
export const Default: Story = { | ||
args: { | ||
schema, | ||
renderers: [ | ||
{ | ||
tester: jsonFormsCategoryControlTester, | ||
renderer: JsonFormsCategoryControl, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export const Dropdown: Story = { | ||
parameters: { | ||
growthbook: [createDropdownGbParameters("1")], | ||
msw: { | ||
handlers: [pageHandlers.getCategories.default()], | ||
}, | ||
}, | ||
args: { | ||
schema, | ||
renderers: [ | ||
{ | ||
tester: jsonFormsCategoryControlTester, | ||
renderer: JsonFormsCategoryControl, | ||
}, | ||
], | ||
}, | ||
} |
23 changes: 23 additions & 0 deletions
23
apps/studio/src/stories/Page/EditPage/components/formBuilder.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { JsonForms } from "@jsonforms/react" | ||
import { type TSchema } from "@sinclair/typebox" | ||
import Ajv from "ajv" | ||
|
||
import { renderers } from "~/features/editing-experience/components/form-builder/FormBuilder" | ||
|
||
const ajv = new Ajv({ | ||
useDefaults: true, | ||
allErrors: true, | ||
strict: false, | ||
logger: false, | ||
}) | ||
|
||
interface FormBuilderProps { | ||
schema: TSchema | ||
data: unknown | ||
} | ||
|
||
export function FormBuilder({ schema, data }: FormBuilderProps): JSX.Element { | ||
return ( | ||
<JsonForms schema={schema} data={data} renderers={renderers} ajv={ajv} /> | ||
) | ||
} |
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