From 65812ec311da593ae545df1ff77e676d6637da20 Mon Sep 17 00:00:00 2001 From: dcshzj <27919917+dcshzj@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:35:24 +0800 Subject: [PATCH] fix: add placeholder info box for index page editing --- .../components/RootStateDrawer.tsx | 211 ++++++++++-------- 1 file changed, 114 insertions(+), 97 deletions(-) diff --git a/apps/studio/src/features/editing-experience/components/RootStateDrawer.tsx b/apps/studio/src/features/editing-experience/components/RootStateDrawer.tsx index 8310107a9..4d449d1c9 100644 --- a/apps/studio/src/features/editing-experience/components/RootStateDrawer.tsx +++ b/apps/studio/src/features/editing-experience/components/RootStateDrawer.tsx @@ -2,7 +2,7 @@ import type { DropResult } from "@hello-pangea/dnd" import { useCallback } from "react" import { Box, Button, Flex, Icon, Text, VStack } from "@chakra-ui/react" import { DragDropContext, Droppable } from "@hello-pangea/dnd" -import { useToast } from "@opengovsg/design-system-react" +import { Infobox, useToast } from "@opengovsg/design-system-react" import { BiPin, BiPlus, BiPlusCircle } from "react-icons/bi" import { BlockEditingPlaceholder } from "~/components/Svg" @@ -155,107 +155,124 @@ export default function RootStateDrawer() { )} - - {/* Custom Blocks Section */} - - - Custom blocks - - Use blocks to display your content in various ways + {pageLayout === "index" && savedPageState.content.length === 0 ? ( + + + + Why can’t I add anything else to this page? - - - - - - {(provided) => ( - - - {((isHeroFixedBlock && savedPageState.content.length === 1) || - savedPageState.content.length === 0) && ( - <> - - - - Blocks you add will appear here - - + Content for this page is auto-generated. We’re introducing editing + for this page type soon, so that you can add custom content + alongside the page links. + + + + ) : ( + + {/* Custom Blocks Section */} + + + Custom blocks + + Use blocks to display your content in various ways + + + + + + + {(provided) => ( + + + {((isHeroFixedBlock && + savedPageState.content.length === 1) || + savedPageState.content.length === 0) && ( + <> + - Click the ‘Add block’ button above to add blocks to - this page - - + + + Blocks you add will appear here + + + Click the ‘Add block’ button above to add blocks to + this page + + - - - )} + + + )} - - {savedPageState.content.map((block, index) => { - if (isHeroFixedBlock && index === 0) { - return <> - } + + {savedPageState.content.map((block, index) => { + if (isHeroFixedBlock && index === 0) { + return <> + } - return ( - { - setCurrActiveIdx(index) - // TODO: we should automatically do this probably? - const nextState = - savedPageState.content[index]?.type === "prose" - ? "nativeEditor" - : "complexEditor" - // NOTE: SNAPSHOT - setDrawerState({ state: nextState }) - }} - /> - ) - })} - - - {provided.placeholder} - - )} - - - + return ( + { + setCurrActiveIdx(index) + // TODO: we should automatically do this probably? + const nextState = + savedPageState.content[index]?.type === "prose" + ? "nativeEditor" + : "complexEditor" + // NOTE: SNAPSHOT + setDrawerState({ state: nextState }) + }} + /> + ) + })} + + + {provided.placeholder} + + )} + + + + )} ) }