Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Added extra subtitle field for topical page in Sanity (#4485)
Browse files Browse the repository at this point in the history
* fix: added extra subtitle field for topical page in Sanity

* fix: add nullable type
  • Loading branch information
hasan-ozaynaci authored Nov 10, 2022
1 parent 28b9759 commit 16023a7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,28 @@ import { TopicalIcon } from '@corona-dashboard/common/src/types';
import DynamicIcon from '~/components/get-icon-by-name';
import theme from '~/style/theme';
import { PortableTextEntry } from '@sanity/block-content-to-react';
import { Markdown } from '~/components';
import { fontSizes } from '~/style/theme';

interface TopicalThemeHeaderProps {
title: string;
subtitle?: PortableTextEntry[] | null;
subtitleThermometer?: string | null;
icon: TopicalIcon;
}

export const TopicalThemeHeader = ({ title, subtitle, subtitleThermometer, icon }: TopicalThemeHeaderProps) => {
export const TopicalThemeHeader = ({ title, subtitle, icon }: TopicalThemeHeaderProps) => {
return (
<Box spacing={3}>
<Box display="flex" justifyContent="start" alignItems="center">
{icon && (
<TopicalThemeHeaderIcon>
<DynamicIcon name={icon} aria-hidden="true" />
</TopicalThemeHeaderIcon>
)}
<TopicalThemeHeaderIcon>
<DynamicIcon name={icon} aria-hidden="true" />
</TopicalThemeHeaderIcon>
<Heading level={2}>{title}</Heading>
</Box>
{subtitle && (
<Box fontSize={fontSizes[3]}>
<RichContent blocks={subtitle} />
</Box>
)}
{subtitleThermometer && (
<Box fontSize={3}>
<Markdown content={subtitleThermometer} />
</Box>
)}
</Box>
);
};
Expand Down
12 changes: 1 addition & 11 deletions packages/app/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,7 @@ const Home = (props: StaticProps<typeof getStaticProps>) => {

{currentSeverityLevelTexts && (
<Box marginY={space[5]} paddingX={{ _: space[3], sm: space[4] }} maxWidth={TOPICAL_SEVERITY_INDICATOR_TILE_MAX_WIDTH}>
<TopicalThemeHeader
title={thermometer.title}
subtitleThermometer={
thermometer.levelDescription &&
replaceVariablesInText(thermometer.levelDescription, {
level: currentSeverityLevel,
label: currentSeverityLevelTexts.label,
})
}
icon={THERMOMETER_ICON_NAME}
/>
<TopicalThemeHeader title={thermometer.title} subtitle={thermometer.subTitle} icon={THERMOMETER_ICON_NAME} />

<SeverityIndicatorTile
level={currentSeverityLevel}
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/queries/get-topical-structure-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function getTopicalStructureQuery(locale: string) {
_type == 'thermometer' && !(_id in path("drafts.**"))
][0]{
'title': title.${locale},
'subTitle': subTitle.${locale},
currentLevel,
'thermometerLevels': thermometerLevels[]->{
'level': level,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/queries/query-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface TopicalSanityData {

interface ThermometerConfig {
title: string;
subTitle: PortableTextEntry[] | null;
currentLevel: SeverityLevel;
datesLabel: string;
levelDescription: string;
Expand Down
5 changes: 5 additions & 0 deletions packages/cms/src/schemas/topical/thermometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export const thermometer = {
type: 'localeString',
validation: REQUIRED,
},
{
title: 'De beschrijving van de thermometer',
name: 'subTitle',
type: 'localeRichContentBlock'
},
{
title: 'Huidige stand',
name: 'currentLevel',
Expand Down

0 comments on commit 16023a7

Please sign in to comment.