Skip to content

Commit

Permalink
feat: allow to set a description to a page (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjuanes authored Nov 17, 2024
1 parent 1ebc118 commit c959e22
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/components/dialogs/page-configure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const pageEditFields = {
placeholder: "Untitled Page",
helper: "Give your page a name.",
},
description: {
type: FORM_OPTIONS.TEXTAREA,
title: "Description",
// placeholder: "Add a description",
helper: "Add a description to your page.",
},
readonly: {
type: FORM_OPTIONS.CHECKBOX,
title: "Read-Only",
Expand All @@ -29,6 +35,7 @@ export const PageConfigureDialog = props => {
const page = scene.getPage(props.page);
const [data, setData] = useFormData({
title: page.title,
description: page.description,
readonly: !!page.readonly,
});
const isSubmitEnabled = !!data.title;
Expand Down
9 changes: 9 additions & 0 deletions app/components/form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ const optionTypes = {
onChange={event => props.onChange(event.target.value)}
/>
),
[FORM_OPTIONS.TEXTAREA]: props => (
<textarea
className={themed("w-full px-2 py-1 rounded-md outline-0 text-xs", "form.text.input")}
defaultValue={props.value}
placeholder={props.placeholder}
rows={props.rows ?? 3}
onChange={event => props.onChange(event.target.value)}
/>
),
[FORM_OPTIONS.CUSTOM]: props => {
return props.render?.(props);
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/panels/pages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Page = ({title, active, editable, style, onClick, ...props}) => {
<BarsIcon />
</div>
<div className="cursor-pointer flex items-center gap-2 w-full p-0 ml-6" onClick={onClick}>
<div className="font-medium text-sm w-content max-w-32 truncate leading-none" title={title}>
<div className="font-medium text-sm w-content max-w-32 truncate" title={title}>
<span>{title}</span>
</div>
{props.readonly && (
Expand Down
1 change: 1 addition & 0 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const FORM_OPTIONS = {
SEPARATOR: "separator",
IMAGE_SELECT: "image-select",
TEXT: "text",
TEXTAREA: "textarea",
CUSTOM: "custom",
};

Expand Down
2 changes: 2 additions & 0 deletions app/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const createPage = (page, index = 0) => {
return {
id: page?.id || generateRandomId(),
title: page?.title || `Page ${index + 1}`,
description: page?.description || "",
elements: (page?.elements || []).map(element => ({
...element,
[FIELDS.SELECTED]: false,
Expand Down Expand Up @@ -279,6 +280,7 @@ export const createScene = initialData => {
pages: scene.pages.map(page => ({
id: page.id,
title: page.title,
description: page.description || "",
elements: page.elements,
readonly: !!page.readonly,
})),
Expand Down

0 comments on commit c959e22

Please sign in to comment.