diff --git a/components/paths/PathsPageContent.tsx b/components/paths/PathsPageContent.tsx index 9acc5658..0b331128 100644 --- a/components/paths/PathsPageContent.tsx +++ b/components/paths/PathsPageContent.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { GetContentPageQuery } from 'common/__generated__/graphql'; import StreamField from 'components/paths/StreamField'; -import { Container } from 'reactstrap'; import styled, { css } from 'styled-components'; import { ActionListPage } from '@/app/[domain]/[lang]/[plan]/(with-layout-elements)/actions/ActionListPage'; @@ -62,14 +61,12 @@ const PathsPageContent = ({ {isCategoryPage && ( - - - {page.body && } - + + {page.body && } )} diff --git a/components/paths/StreamField.tsx b/components/paths/StreamField.tsx index 77966efc..6038526e 100644 --- a/components/paths/StreamField.tsx +++ b/components/paths/StreamField.tsx @@ -1,13 +1,15 @@ import React from 'react'; -import { ColProps } from 'reactstrap'; +import { Col, ColProps, Container, Row } from 'reactstrap'; import type { StreamFieldFragmentFragment } from '@/common/__generated__/graphql'; import { ErrorBoundary } from '@/components/common/ErrorBoundary'; import { ErrorPage } from '@/components/common/ErrorPage'; +import RichText from '@/components/common/RichText'; import ActionCategoryFilterCardsBlock from '@/components/contentblocks/ActionCategoryFilterCardsBlock'; import ActionListBlock from '@/components/contentblocks/ActionListBlock'; import IndicatorGroupBlock from '@/components/contentblocks/IndicatorGroupBlock'; +import QuestionAnswerBlock from '@/components/contentblocks/QuestionAnswerBlock'; import CategoryListBlock from '@/components/paths/contentblocks/CategoryListBlock'; import CategoryTypeListBlock from '@/components/paths/contentblocks/CategoryTypeListBlock'; import PathsOutcomeBlock from '@/components/paths/contentblocks/PathsOutcomeBlock'; @@ -116,8 +118,39 @@ function StreamFieldBlock(props: StreamFieldBlockProps) { ); } - case 'RichTextBlock': - case 'QuestionAnswerBlock': + case 'RichTextBlock': { + const { value } = block; + const COLLAPSIBLE_BREAKPOINT = 1200; + const isCollapsible = + page.__typename === 'CategoryPage' && + value.length > COLLAPSIBLE_BREAKPOINT; + return ( + + + + + + + + ); + } + case 'QuestionAnswerBlock': { + const { heading, questions } = block; + + return ( + + ); + } case 'CharBlock': case 'FrontPageHeroBlock': case 'LargeImageBlock': diff --git a/components/paths/contentblocks/CategoryListBlock.tsx b/components/paths/contentblocks/CategoryListBlock.tsx index 090fb2ab..b6d52f2c 100644 --- a/components/paths/contentblocks/CategoryListBlock.tsx +++ b/components/paths/contentblocks/CategoryListBlock.tsx @@ -135,56 +135,54 @@ const CategoryList = (props) => { //console.log('categoryData', categoryData); return ( - - - {categories - ?.filter((cat) => cat?.categoryPage?.live) - .map( - (cat) => - cat.categoryPage && ( - - - - -
- - {!cat?.type.hideCategoryIdentifiers && ( - {cat.identifier}. - )} - {cat.name} - - {cat.leadParagraph &&

{cat.leadParagraph}

} - {cat.pathsAction && ( -
- {yearRange ? ( - beautifyValue( - cat.pathsAction.getYearlyImpact(yearRange[1]) - ) - ) : ( - --- - )} - {cat.pathsAction.getUnit()} -
+ + {categories + ?.filter((cat) => cat?.categoryPage?.live) + .map( + (cat) => + cat.categoryPage && ( + + +
+ +
+ + {!cat?.type.hideCategoryIdentifiers && ( + {cat.identifier}. )} -
-
-
- - - ) - )} - - + {cat.name} + + {cat.leadParagraph &&

{cat.leadParagraph}

} + {cat.pathsAction && ( +
+ {yearRange ? ( + beautifyValue( + cat.pathsAction.getYearlyImpact(yearRange[1]) + ) + ) : ( + --- + )} + {cat.pathsAction.getUnit()} +
+ )} +
+ + + + + ) + )} +
); }; @@ -201,10 +199,12 @@ const CategoryListBlock = (props: CategoryListBlockProps) => { //console.log('CategoryListBlock', props); return ( - {heading &&

{heading}

} - Loading...}> - - + + {heading &&

{heading}

} + Loading...}> + + +
); }; diff --git a/components/paths/contentblocks/CategoryPageHeaderBlock.tsx b/components/paths/contentblocks/CategoryPageHeaderBlock.tsx index a7f48964..aeb4a70c 100644 --- a/components/paths/contentblocks/CategoryPageHeaderBlock.tsx +++ b/components/paths/contentblocks/CategoryPageHeaderBlock.tsx @@ -6,6 +6,7 @@ import { CategoryPage } from 'components/common/CategoryPageStreamField'; import { usePaths } from 'context/paths/paths'; import { usePlan } from 'context/plan'; import { useTranslations } from 'next-intl'; +import { Container } from 'reactstrap'; import styled, { useTheme } from 'styled-components'; import { gql } from '@apollo/client'; @@ -30,6 +31,11 @@ export const GET_CATEGORY_ATTRIBUTE_TYPES = gql` } `; +const Background = styled.div` + padding: 4rem 0 2em; + background-color: ${(props) => props.theme.brandDark}; +`; + const PathsActionImpact = styled.div` display: flex; margin-right: 1rem; @@ -92,57 +98,61 @@ function CategoryPageHeaderBlock(props: Props) { level && !theme.settings.categories.categoryPageHideCategoryLabel; return ( - - -

- {identifier && {identifier}.} {title} -

- {hasPaths && ( - -
-

Emissions (2022)

-
-
- Direct emissions
XXX
-
-
- Indirect emissions
XXX
-
-
-
-
-

Emissions target (2024)

-
+ + + + +

+ {identifier && {identifier}.} {title} +

+ {hasPaths && ( +
- Direct emissions
XXX
+

Emissions (2022)

+
+
+ Direct emissions
XXX
+
+
+ Indirect emissions
XXX
+
+
- Indirect emissions
XXX
+

Emissions target (2024)

+
+
+ Direct emissions
XXX
+
+
+ Indirect emissions
XXX
+
+
-
-
-
- )} - {lead &&

{lead}

} -
+ + )} + {lead &&

{lead}

} + +
+ ); } diff --git a/components/paths/contentblocks/CategoryTypeListBlock.tsx b/components/paths/contentblocks/CategoryTypeListBlock.tsx index df02e2c1..2882c478 100644 --- a/components/paths/contentblocks/CategoryTypeListBlock.tsx +++ b/components/paths/contentblocks/CategoryTypeListBlock.tsx @@ -5,8 +5,9 @@ import { MultiUseImageFragmentFragment } from 'common/__generated__/graphql'; import { CommonContentBlockProps } from 'common/blocks.types'; import { useTranslations } from 'next-intl'; import { readableColor } from 'polished'; +import ContentLoader from 'react-content-loader'; import { Col, Container, FormGroup, Input, Label, Row } from 'reactstrap'; -import styled from 'styled-components'; +import styled, { useTheme } from 'styled-components'; import { getDeepParents } from '@/common/categories'; import { usePaths } from '@/context/paths/paths'; @@ -48,28 +49,49 @@ const GET_CATEGORIES_FOR_CATEGORY_TYPE_LIST = gql` ${RECURSIVE_CATEGORY_FRAGMENT} `; -const GroupHeader = styled.h4` - border-left: 6px solid ${(props) => props.$color}; - margin-bottom: 24px; +const CategoryListContentLoader = (props) => { + const theme = useTheme(); + return ( + + + + + + + ); +}; + +const HeaderSection = styled.div` + padding: 4rem 0; + margin-bottom: 2rem; + background-color: ${(props) => props.theme.brandDark}; + color: ${(props) => props.theme.themeColors.white}; `; -const CategoryListSection = styled.div` - background-color: ${({ theme }) => getBackgroundColor(theme)}; - padding: ${(props) => - `${props.theme.spaces.s400} 0 ${props.theme.spaces.s100} 0`}; - color: ${({ theme }) => getColor(theme)}; - - h2 { - font-size: ${(props) => props.theme.fontSizeLg}; - color: ${({ theme }) => getColor(theme, theme.headingsColor)}; - } +const StyledTitle = styled.h1` + margin-bottom: 2rem; + font-size: ${(props) => props.theme.fontSizeLg}; + color: inherit; @media (min-width: ${(props) => props.theme.breakpointMd}) { - h2 { - font-size: ${(props) => props.theme.fontSizeXl}; - } + font-size: ${(props) => props.theme.fontSizeXl}; } +`; +const GroupHeader = styled.h4` + border-left: 6px solid ${(props) => props.$color}; + margin-bottom: 24px; +`; + +const CategoryListSection = styled.div` + padding-bottom: 6rem; a.card-wrapper { display: flex; width: 100%; @@ -180,25 +202,31 @@ const CategoryList = (props) => { return ( <> - - - handleChangeSort(e.target.value as SortActionsBy)} - value={sortBy.key} - > - {sortOptions.map( - (sortOption) => - !sortOption.isHidden && ( - - ) - )} - - + + + + + + handleChangeSort(e.target.value as SortActionsBy) + } + value={sortBy.key} + > + {sortOptions.map( + (sortOption) => + !sortOption.isHidden && ( + + ) + )} + + + + {groups?.map((group) => ( {group?.id !== 'all' && ( @@ -285,26 +313,31 @@ const CategoryTypeListBlock = (props: CategoryTypeListBlockProps) => { } ); - if (loading) { - return
Loading...
; // Or any loading indicator you prefer - } if (error) { return
Error: {error.message}
; } - const categories = data.planCategories.filter( - (cat) => cat.level.id === listByLevel - ); + const categories = data + ? data.planCategories.filter((cat) => cat.level.id === listByLevel) + : []; + const groups = getParentCategoriesOfLevel(categories, groupByLevel); return ( + + + + + {heading && {heading}} + + + + - - {heading &&

{heading}

} -
- + {loading ? ( + + ) : ( + + )}
);