From 686f5bbe1847cb2a92678e7cfdbb51ecf6bbe2b6 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Mon, 8 May 2023 18:04:43 +0200 Subject: [PATCH] feat(frontend): app modal (#1518) * feat(frontend): app modal wip * feat(frontend): Modal * feat(frontend): fix modal title * feat(frontend): Merge main * feat(frontend): fix build * feat(frontend): use ResolveConfig + rename prop * feat(frontend): use ResolveConfig + rename prop --- .../apps/components/layout/AppModal.svelte | 157 ++++++++++++++++++ .../apps/editor/component/Component.svelte | 12 +- .../apps/editor/component/components.ts | 56 +++++++ .../components/apps/editor/component/sets.ts | 1 + .../componentsPanel/quickStyleProperties.ts | 11 +- 5 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 frontend/src/lib/components/apps/components/layout/AppModal.svelte diff --git a/frontend/src/lib/components/apps/components/layout/AppModal.svelte b/frontend/src/lib/components/apps/components/layout/AppModal.svelte new file mode 100644 index 0000000000..e858c5220a --- /dev/null +++ b/frontend/src/lib/components/apps/components/layout/AppModal.svelte @@ -0,0 +1,157 @@ + + +
+ + + +
+ +{#each Object.keys(components['modalcomponent'].initialData.configuration) as key (key)} + +{/each} + + + + + + +
+
{ + if ($mode !== 'dnd') { + closeDrawer() + } + }} + > +
+
{resolvedConfig.modalTitle}
+
+ +
+
+
{ + e?.stopPropagation() + if (!$connectingInput.opened) { + $selectedComponent = [id] + $focusedGrid = { + parentComponentId: id, + subGridIndex: 0 + } + } + }} + > + {#if $app.subgrids?.[`${id}-0`]} + { + if (!$connectingInput.opened) { + $selectedComponent = [id] + $focusedGrid = { + parentComponentId: id, + subGridIndex: 0 + } + } + }} + /> + {/if} +
+
+
+
diff --git a/frontend/src/lib/components/apps/editor/component/Component.svelte b/frontend/src/lib/components/apps/editor/component/Component.svelte index 24f963f77e..26eb33f937 100644 --- a/frontend/src/lib/components/apps/editor/component/Component.svelte +++ b/frontend/src/lib/components/apps/editor/component/Component.svelte @@ -39,8 +39,9 @@ AppPdf } from '../../components' import AppMultiSelect from '../../components/inputs/AppMultiSelect.svelte' - import AppStepper from '../../components/layout/AppStepper.svelte' + import AppModal from '../../components/layout/AppModal.svelte' import AppSchemaForm from '../../components/buttons/AppSchemaForm.svelte' + import AppStepper from '../../components/layout/AppStepper.svelte' export let component: AppComponent export let selected: boolean @@ -471,6 +472,15 @@ customCss={component.customCss} {render} /> + {:else if component.type === 'modalcomponent'} + {:else if component.type === 'schemaformcomponent'} +export type ModalComponent = BaseComponent<'modalcomponent'> export type StepperComponent = BaseComponent<'steppercomponent'> & { tabs: string[] } @@ -150,6 +151,7 @@ export type TypedComponent = | VerticalSplitPanesComponent | HorizontalSplitPanesComponent | PdfComponent + | ModalComponent | StepperComponent | Schemaformcomponent @@ -1687,6 +1689,60 @@ Hello \${ctx.username} } } }, + modalcomponent: { + name: 'Modal', + icon: SidebarClose, + dims: '1:1-2:1' as AppComponentDimensions, + customCss: { + button: { class: '', style: '' }, + popup: { class: '', style: '' } + }, + initialData: { + horizontalAlignment: 'center', + verticalAlignment: 'center', + configuration: { + modalTitle: { + type: 'static', + fieldType: 'text', + value: 'Modal title', + onlyStatic: true + }, + buttonLabel: { + type: 'static', + fieldType: 'text', + value: 'Press me' + }, + buttonColor: { + fieldType: 'select', + type: 'static', + onlyStatic: true, + selectOptions: buttonColorOptions, + value: 'blue' + }, + buttonSize: { + fieldType: 'select', + type: 'static', + onlyStatic: true, + selectOptions: selectOptions.buttonSizeOptions, + value: 'xs' + }, + buttonFillContainer: { + fieldType: 'boolean', + type: 'static', + onlyStatic: true, + value: false + }, + buttonDisabled: { + fieldType: 'boolean', + type: 'static', + value: false + } + }, + componentInput: undefined, + + numberOfSubgrids: 1 + } + }, schemaformcomponent: { name: 'Schema Form', icon: FileText, diff --git a/frontend/src/lib/components/apps/editor/component/sets.ts b/frontend/src/lib/components/apps/editor/component/sets.ts index 904939388b..9c7fe511ef 100644 --- a/frontend/src/lib/components/apps/editor/component/sets.ts +++ b/frontend/src/lib/components/apps/editor/component/sets.ts @@ -10,6 +10,7 @@ const layout: ComponentSet = { 'drawercomponent', 'verticalsplitpanescomponent', 'horizontalsplitpanescomponent', + 'modalcomponent', 'steppercomponent' ] } as const diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts index fcb68d004d..1b8ad79bba 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts +++ b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts @@ -556,10 +556,6 @@ export const quickStyleProperties: Record< pdfcomponent: { container: containerDefaultProps }, - schemaformcomponent: { - container: containerDefaultProps, - button: buttonDefaultProps - }, formcomponent: { container: containerDefaultProps, button: buttonDefaultProps @@ -616,6 +612,9 @@ export const quickStyleProperties: Record< drawercomponent: { container: containerDefaultProps }, + modalcomponent: { + container: containerDefaultProps + }, plotlycomponent: {}, selectcomponent: { input: inputDefaultProps @@ -696,5 +695,9 @@ export const quickStyleProperties: Record< }, horizontalsplitpanescomponent: { container: containerDefaultProps + }, + schemaformcomponent: { + container: containerDefaultProps, + button: buttonDefaultProps } }