Skip to content
Open
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
62 changes: 32 additions & 30 deletions src/components/form-slice/FormItemPlugins/PluginEditorDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,41 +64,43 @@ export const PluginEditorDrawer = (props: PluginEditorDrawerProps) => {
closeOnEscape={false}
opened={opened}
onClose={handleClose}
styles={{ body: { paddingTop: '18px' } }}
classNames={{
body: 'plugin-editor-drawer__body',
}}
{...(mode === 'add' && { title: t('form.plugins.addPlugin') })}
{...(mode === 'edit' && { title: t('form.plugins.editPlugin') })}
{...(mode === 'view' && { title: t('form.plugins.viewPlugin') })}
>
<Title order={3} mb={10}>
{name}
</Title>
<FormProvider {...methods}>
<form>
<FormItemEditor
name="config"
h={500}
customSchema={schema}
isLoading={!schema}
required
/>
</form>
<div className="plugin-editor-drawer__content">
<Title order={3}>{name}</Title>
<FormProvider {...methods}>
<form className="plugin-editor-drawer__form">
<FormItemEditor
name="config"
h="clamp(280px, calc(100vh - 320px), 620px)"
customSchema={schema}
isLoading={!schema}
required
/>
</form>

{mode !== 'view' && (
<Group justify="flex-end" mt={8}>
<FormSubmitBtn
size="xs"
variant="light"
onClick={methods.handleSubmit(({ config }) => {
onSave({ name, config: JSON.parse(config) });
handleClose();
})}
>
{mode === 'add' && t('form.btn.add')}
{mode === 'edit' && t('form.btn.save')}
</FormSubmitBtn>
</Group>
)}
</FormProvider>
{mode !== 'view' && (
<Group className="plugin-editor-drawer__actions" justify="flex-end">
<FormSubmitBtn
size="xs"
variant="light"
onClick={methods.handleSubmit(({ config }) => {
onSave({ name, config: JSON.parse(config) });
handleClose();
})}
>
{mode === 'add' && t('form.btn.add')}
{mode === 'edit' && t('form.btn.save')}
</FormSubmitBtn>
</Group>
)}
</FormProvider>
</div>
</Drawer>
);
};
27 changes: 27 additions & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,30 @@
color: var(--mantine-color-gray-5) !important;
}
}

.plugin-editor-drawer__body {
padding-top: 18px;
max-height: calc(100vh - 80px);
overflow-y: auto;
}

.plugin-editor-drawer__content {
min-height: 0;
display: flex;
flex-direction: column;
gap: var(--mantine-spacing-xs);
}

.plugin-editor-drawer__form {
min-height: 0;
}

.plugin-editor-drawer__actions {
position: sticky;
bottom: 0;
margin-top: var(--mantine-spacing-xs);
padding-top: var(--mantine-spacing-xs);
background: var(--mantine-color-body);
border-top: 1px solid var(--mantine-color-gray-2);
z-index: 2;
}