-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expand object & DZ fields via renderer settings
BREAKING CHANGE: none Refs: #4109
- Loading branch information
Showing
4 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/app-headless-cms/src/admin/plugins/fieldRenderers/AccordionRenderSettings.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,39 @@ | ||
import React from "react"; | ||
import { Bind } from "@webiny/form"; | ||
import { Cell } from "@webiny/ui/Grid"; | ||
import { Switch } from "@webiny/ui/Switch"; | ||
import { | ||
CmsModelField, | ||
CmsModelFieldRendererSettingsProps | ||
} from "@webiny/app-headless-cms-common/types"; | ||
|
||
export interface IAccordionRenderSettings { | ||
open: boolean; | ||
} | ||
|
||
const DEFAULT_ACCORDION_RENDER_SETTINGS: IAccordionRenderSettings = { | ||
open: false | ||
}; | ||
|
||
export const getAccordionRenderSettings = (field: CmsModelField) => { | ||
if (typeof field.renderer === "function") { | ||
return DEFAULT_ACCORDION_RENDER_SETTINGS; | ||
} | ||
|
||
return field.renderer.settings as IAccordionRenderSettings; | ||
}; | ||
|
||
export const AccordionRenderSettings = ({ field }: CmsModelFieldRendererSettingsProps) => { | ||
return ( | ||
<> | ||
<Cell span={12}> | ||
<Bind name={"renderer.settings.open"} defaultValue={false}> | ||
<Switch | ||
label={"Expand Accordion"} | ||
description={`Enable if "${field.label}" is to be expanded by default.`} | ||
/> | ||
</Bind> | ||
</Cell> | ||
</> | ||
); | ||
}; |
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