Skip to content

Commit

Permalink
Merge branch 'main' into all-search
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpmccormick committed Jan 29, 2025
2 parents 4e9bb5d + 706ae48 commit 369354c
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 51 deletions.
11 changes: 10 additions & 1 deletion common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ This contains some code which is shared among the front-end apps.
Of particular interest:

* The `data` directory holds most the hard-coded data for the site (e.g. microcopy, error messages, contact information). We keep it in one place so it can be easily reviewed and updated across the site.
* The `customtypes` and `views/slices` directories contain the Prismic model data which is created locally using (SliceMachine)[https://prismic.io/slice-machine]. When creating new custom types, slices, or fields, refer to the (API ID name casing docs in Gitbook)[https://app.gitbook.com/o/-LumfFcEMKx4gYXKAZTQ/s/451yLOIRTl5YiAJ88yIL/api-id-name-casing]
* The `customtypes` and `views/slices` directories contain the Prismic model data which is created locally using (SliceMachine)[https://prismic.io/slice-machine]. When creating new custom types, slices, or fields, refer to the (API ID name casing docs in Gitbook)[https://app.gitbook.com/o/-LumfFcEMKx4gYXKAZTQ/s/451yLOIRTl5YiAJ88yIL/api-id-name-casing]


## Bundle analysis
Previously stored in S3 and displayed on dash.wellcomecollection.org, you can still run it locally.
It currently only is set-up for `content/`, as it's using the `next/next.config.js`. Other repos could be made to use it.
Example of how to use:
1. `cd content/webapp`
2. `BUNDLE_ANALYZE=true yarn build`
3. It'll render new files, you're probably interested in the one at: `/content/webapp/.dist/content.client.test.html`.
3 changes: 3 additions & 0 deletions common/data/segment-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ImagesLinkSource =
| `concept/images_about_${string}`
| `concept/images_by_${string}`
| `concept/images_in_${string}`
| `images_all_${string}`
| 'images_search_context'
| 'work_details/images'
| 'unknown';
Expand Down Expand Up @@ -80,6 +81,8 @@ export type WorksLinkSource =
| 'concept/works_by'
| 'concept/works_in'
| `works_search_context_${string}`
| `works_workType_${string}`
| `works_all_${string}`
| `work_details/contributors_${string}`
| 'work_details/genres'
| `work_details/subjects_${string}`
Expand Down
10 changes: 10 additions & 0 deletions common/prismicio-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6582,6 +6582,16 @@ export interface GuideTextItemSliceDefaultPrimary {
* - **Documentation**: https://prismic.io/docs/field#rich-text-title
*/
additional_notes: prismic.RichTextField;

/**
* Transcript field in *GuideTextItem → Default → Primary*
*
* - **Field Type**: Rich Text
* - **Placeholder**: *None*
* - **API ID Path**: guide_text_item.default.primary.transcript
* - **Documentation**: https://prismic.io/docs/field#rich-text-title
*/
transcript: prismic.RichTextField;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions common/views/slices/GuideTextItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ const GuideTextItem: FunctionComponent<GuideTextItemProps> = ({
slice,
index,
}) => {
const transformedSlice = transformGuideTextItemSlice(slice);
const { additional_notes: additionalNotes, ...transformedSlice } =
transformGuideTextItemSlice(slice);

return (
<TextItem
key={index}
number={transformedSlice.number}
title={transformedSlice.title}
tombstone={transformedSlice.tombstone}
caption={transformedSlice.caption}
additionalNotes={transformedSlice.additional_notes}
{...transformedSlice}
additionalNotes={additionalNotes}
/>
);
};
Expand Down
11 changes: 11 additions & 0 deletions common/views/slices/GuideTextItem/mocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@
}
}
]
},
"transcript": {
"__TYPE__": "StructuredTextContent",
"value": [
{
"type": "paragraph",
"content": {
"text": "Id qui eiusmod eu et elit pariatur qui. Cillum nulla aliquip ea ad et. Duis consequat sit consectetur est adipisicing esse est sint officia est aliquip culpa."
}
}
]
}
},
"items": [
Expand Down
9 changes: 9 additions & 0 deletions common/views/slices/GuideTextItem/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"allowTargetBlank": false,
"multi": "paragraph,strong,em,hyperlink"
}
},
"transcript": {
"type": "StructuredText",
"config": {
"label": "Transcript",
"placeholder": "",
"allowTargetBlank": true,
"multi": "paragraph,heading1,heading2,heading3,heading4,heading5,strong,em"
}
}
},
"items": {}
Expand Down
1 change: 0 additions & 1 deletion common/views/slices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const components = {
infoBlock: dynamic(() => import('./InfoBlock')),
map: dynamic(() => import('./Map')),
quote: dynamic(() => import('./Quote')),
quoteV2: dynamic(() => import('./Quote')),
searchResults: dynamic(() => import('./SearchResults')),
standfirst: dynamic(() => import('./Standfirst')),
tagList: dynamic(() => import('./TagList')),
Expand Down
16 changes: 15 additions & 1 deletion content/webapp/components/GuideTextItem/GuideTextItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as prismic from '@prismicio/client';
import { FunctionComponent } from 'react';

import { font } from '@weco/common/utils/classnames';
import { camelize } from '@weco/common/utils/grammar';
import CollapsibleContent from '@weco/common/views/components/CollapsibleContent';
import PrismicHtmlBlock from '@weco/common/views/components/PrismicHtmlBlock/PrismicHtmlBlock';
import { Container } from '@weco/common/views/components/styled/Container';
import Space from '@weco/common/views/components/styled/Space';
Expand All @@ -18,7 +20,8 @@ const GuideTextItem: FunctionComponent<{
tombstone?: prismic.RichTextField;
caption?: prismic.RichTextField;
additionalNotes?: prismic.RichTextField;
}> = ({ number, title, tombstone, caption, additionalNotes }) => {
transcript?: prismic.RichTextField;
}> = ({ number, title, tombstone, caption, additionalNotes, transcript }) => {
return (
<Space
id={number ? `stop-${number}` : undefined}
Expand All @@ -43,6 +46,17 @@ const GuideTextItem: FunctionComponent<{
<PrismicHtmlBlock html={caption} />
</Caption>
)}

{transcript && (
<Space $v={{ size: 'xl', properties: ['margin-top'] }}>
<CollapsibleContent
id={number ? `${number}` : camelize(title)}
controlText={{ defaultText: 'Read transcript' }}
>
<PrismicHtmlBlock html={transcript} />
</CollapsibleContent>
</Space>
)}
</Wrapper>
)}
</Container>
Expand Down
2 changes: 1 addition & 1 deletion content/webapp/components/ImageCard/ImageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
workId: string;
image: ImageType;
layout: 'raw' | 'fixed';
onClick: (event: SyntheticEvent<HTMLAnchorElement>) => void;
onClick?: (event: SyntheticEvent<HTMLAnchorElement>) => void;
background?: string;
};

Expand Down
3 changes: 1 addition & 2 deletions content/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"dev": "NODE_ENV=development nodemon --watch server.ts --watch app.ts --exec ts-node --project tsconfig.server.json server",
"start": "NODE_ENV=production ts-node-transpile-only --project tsconfig.server.json server",
"test": "NODE_ENV=test jest --no-cache",
"test:watch": "yarn test -- --watchAll",
"deployBundleAnalysis": "aws s3 sync .dist s3://dash.wellcomecollection.org/bundles --only-show-errors --acl public-read"
"test:watch": "yarn test -- --watchAll"
},
"dependencies": {
"@iiif/presentation-3": "^2.1.3",
Expand Down
Loading

0 comments on commit 369354c

Please sign in to comment.