-
Notifications
You must be signed in to change notification settings - Fork 37
TAN-5512 - Added title into the folder description #12419
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Box, Spinner, Title } from '@citizenlab/cl2-component-library'; | ||
| import { Box, Spinner } from '@citizenlab/cl2-component-library'; | ||
| import { isEmpty } from 'lodash-es'; | ||
| import { Multiloc } from 'typings'; | ||
|
|
||
| import useContentBuilderLayout from 'api/content_builder/useContentBuilderLayout'; | ||
|
|
||
| import useLocalize from 'hooks/useLocalize'; | ||
|
|
||
| import { IMAGES_LOADED_EVENT } from 'components/admin/ContentBuilder/constants'; | ||
| import ContentBuilderFrame from 'components/admin/ContentBuilder/Frame'; | ||
| import Editor from 'components/DescriptionBuilder/Editor'; | ||
|
|
@@ -24,11 +22,7 @@ const handleLoadImages = () => { | |
| eventEmitter.emit(IMAGES_LOADED_EVENT); | ||
| }; | ||
|
|
||
| const FolderContentViewer = ({ | ||
| folderId, | ||
| folderTitle, | ||
| }: FolderContentViewerProps) => { | ||
| const localize = useLocalize(); | ||
| const FolderContentViewer = ({ folderId }: FolderContentViewerProps) => { | ||
| const { data: descriptionBuilderLayout, isInitialLoading } = | ||
| useContentBuilderLayout('folder', folderId); | ||
|
|
||
|
|
@@ -49,9 +43,6 @@ const FolderContentViewer = ({ | |
| <Spinner /> | ||
| ) : ( | ||
| <Box data-testid="descriptionBuilderFolderPreviewContent"> | ||
| <Title color="tenantText" variant="h1"> | ||
| {localize(folderTitle)} | ||
| </Title> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jamesspeake I'm not sure about making this an optional widget in the content builder 🤔 If they forget or choose not to add it, I think we end up with a page with bad accessibility/incorrect html hierarchy right? Since we won't have an h1 title? Or maybe I've misunderstood how this works? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would indeed be possible to not have the project title in the page, but it felt odd laying out the rest of the page without having the title as part of the layout. Kind of why I added it as a separate PR as I was not totally sure. Good point about accessibility, but this is also possible on the homepage builder already. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point about the homepage builder - in that case, I think this is fine then indeed 👍 |
||
| <Box id={`project-folder-description-${folderId}`} mb="24px"> | ||
| <Editor isPreview={true}> | ||
| <ContentBuilderFrame | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Title } from '@citizenlab/cl2-component-library'; | ||
| import { UserComponent } from '@craftjs/core'; | ||
|
|
||
| import useProjectFolderById from 'api/project_folders/useProjectFolderById'; | ||
|
|
||
| import useLocalize from 'hooks/useLocalize'; | ||
|
|
||
| import useCraftComponentDefaultPadding from 'components/admin/ContentBuilder/useCraftComponentDefaultPadding'; | ||
|
|
||
| import messages from './messages'; | ||
|
|
||
| interface Props { | ||
| folderId: string; | ||
| } | ||
| const FolderTitle: UserComponent = ({ folderId }: Props) => { | ||
| const localize = useLocalize(); | ||
| const { data: projectFolder } = useProjectFolderById(folderId); | ||
| const craftComponentDefaultPadding = useCraftComponentDefaultPadding(); | ||
|
|
||
| if (!projectFolder) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <Title color="tenantText" variant="h1" px={craftComponentDefaultPadding}> | ||
| {localize(projectFolder.data.attributes.title_multiloc)} | ||
| </Title> | ||
| ); | ||
| }; | ||
|
|
||
| FolderTitle.craft = { | ||
| custom: { | ||
| title: messages.folderTitle, | ||
| }, | ||
| }; | ||
|
|
||
| export const folderTitleTitle = messages.folderTitle; | ||
|
|
||
| export default FolderTitle; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineMessages } from 'react-intl'; | ||
|
|
||
| export default defineMessages({ | ||
| folderTitle: { | ||
| id: 'app.containers.admin.ContentBuilder.folderTitle', | ||
| defaultMessage: 'Folder title', | ||
| }, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.