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

fix: improve text prompts of empty group components #982

Merged
merged 1 commit into from
Jan 16, 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
9 changes: 8 additions & 1 deletion packages/form-js-editor/assets/form-js-editor-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,19 @@
height: 80px;
width: calc(100% - 4rem);
position: absolute;
container-type: size;
}

.fjs-editor-container .fjs-empty-component span {
.fjs-editor-container .fjs-empty-component .fjs-empty-component-text {
color: var(--cds-text-disabled, var(--color-grey-225-10-55));
}

@container (width < 100px) {
.fjs-empty-component-text {
display: none;
}
}

.fjs-editor-container .fjs-empty-editor {
display: flex;
align-items: center;
Expand Down
28 changes: 19 additions & 9 deletions packages/form-js-editor/src/render/components/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,34 @@ function ContextPad(props) {
);
}

function Empty(props) {
if (props.field.type === 'default') {
return <div class="fjs-empty-editor">
function EmptyGroup() {
return (
<div class="fjs-empty-component">
<span class="fjs-empty-component-text">Drag and drop components here.</span>
</div>
);
}

function EmptyForm() {
return (
<div class="fjs-empty-editor">
<div class="fjs-empty-editor-card">
<EmptyFormIcon />
<h2>Build your form</h2>
<span>Drag and drop components here to start designing.</span>
<span>Use the preview window to test your form.</span>
</div>
</div>;
}
</div>
);
}

if (props.field.type === 'group') {
return <div class="fjs-empty-component"><span>Drag and drop components here.</span></div>;
function Empty(props) {
if ([ 'group', 'dynamiclist' ].includes(props.field.type)) {
return <EmptyGroup />;
}

if (props.field.type === 'dynamiclist') {
return <div class="fjs-empty-component"><span>Drag and drop components here <br /> to create a repeatable list item.</span></div>;
if (props.field.type === 'default') {
return <EmptyForm />;
}

return null;
Expand Down
Loading