Skip to content

Commit

Permalink
✨ Upgrade newsroom #2433 (#2448)
Browse files Browse the repository at this point in the history
* 🎨 start fetching on selection

* ✨ Index news hero image #2433

* 🎨 updated newsroom

* 🎨 lint errors and algolia for newsroom

* 🎨 transient props

* :Art new player

* 🎨 add pagination and translations,degrade next and next sanity

* 🎨 delete new provider since downgrade

* 🎨 responsive versions

* 🎨 look over packages

* 🎨 adjustments to max w

* 🐛 fix lg padding

* 🎨 update

* 🎨 design changes and added radix ui accordion

* 🎨 add max w

* 🎨 update

* 🎨 more accessibility

* 🎨 wrong hook

* 🎨 make algolia search box to core comp

* 🎨 fix thumbnail images

* 🎨 specify no end border

* 🐛 fix console logs and revert sanity client

* 🐛 fix responsive bugs

* 🎨 allow a bit bigger images

* 🎨 change initial load and refinements to sanity

* 🎨 sanity pagination

* 🎨 update queries

* 🎨 update groqs

* 🎨 take some algolia back

* 🎨 revert to algolia

* 🎨 add skeleton to newsroom

* 🎨 remove unused

---------

Co-authored-by: Padmaja <[email protected]>
  • Loading branch information
BorghildSelle and padms authored Nov 4, 2024
1 parent eaa9ceb commit 7deaafe
Show file tree
Hide file tree
Showing 89 changed files with 9,049 additions and 9,334 deletions.
387 changes: 215 additions & 172 deletions e2e/pnpm-lock.yaml

Large diffs are not rendered by default.

1,139 changes: 713 additions & 426 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

5,775 changes: 2,247 additions & 3,528 deletions sanityv3/pnpm-lock.yaml

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions sanityv3/schemas/documents/newsroom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { file } from '@equinor/eds-icons'
import { EdsIcon } from '../../icons'
import type { PortableTextBlock, Rule } from 'sanity'
import { lang } from './langField'
import routes from '../routes'
import { filterByRoute } from '../../helpers/referenceFilters'

const titleContentType = configureTitleBlockContent()
const textContentType = configureBlockContent({
Expand Down Expand Up @@ -66,6 +68,42 @@ export default {
type: 'array',
of: [textContentType],
},
{
name: 'subscriptionLink',
title: 'Link to the email subscription page',
type: 'reference',
to: routes,
options: {
filter: filterByRoute,
},
},
{
name: 'subscriptionLinkTitle',
title: 'Title for the subscription link',
type: 'string',
},
{
title: 'List of local news pages',
name: 'localNewsPages',
type: 'array',
of: [{ type: 'linkSelector', title: 'Link' }],
},
{
title: 'Image thumbnail fallbacks',
name: 'imageThumbnailFallbacks',
type: 'array',
of: [
{
type: 'image',
title: 'Fallback image',
options: {
hotspot: true,
collapsed: false,
},
},
],
validation: (Rule: Rule) => Rule.max(3),
},
],
preview: {
select: {
Expand Down
80 changes: 80 additions & 0 deletions sanityv3/schemas/textSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ const snippets: textSnippet = {
defaultValue: 'Search',
group: groups.search,
},
search_quick_search: {
title: 'Quick search',
defaultValue: 'Quick search',
group: groups.search,
},
search_quick_search_label: {
title: 'Quick search label',
defaultValue: 'Search among Equinor corporate-level news releases',
group: groups.search,
},
search_news_tab: {
title: 'News tab name',
defaultValue: 'News',
Expand Down Expand Up @@ -116,6 +126,31 @@ const snippets: textSnippet = {
defaultValue: 'Sorry, no results were found. Please try again with some different keywords.',
group: groups.search,
},
search_submit: {
title: 'Submit search',
defaultValue: 'Submit search',
group: groups.search,
},
search_reset: {
title: 'Reset',
defaultValue: 'Reset',
group: groups.search,
},
search_filter_by: {
title: 'Filter by',
defaultValue: 'Filter by',
group: groups.search,
},
search_pagination_first_page: {
title: 'First page',
defaultValue: 'First page',
group: groups.search,
},
search_pagination_last_page: {
title: 'Last page',
defaultValue: 'Last page',
group: groups.search,
},
copyright: {
title: 'Copyright',
defaultValue: 'Copyright 2022 Equinor ASA',
Expand Down Expand Up @@ -689,6 +724,21 @@ const snippets: textSnippet = {
defaultValue: 'Topic',
group: groups.newsroom,
},
newsroom_filters_label: {
title: 'Filters label',
defaultValue: 'Filter by:',
group: groups.newsroom,
},
newsroom_filters_selected: {
title: 'Selected',
defaultValue: 'Selected',
group: groups.newsroom,
},
newsroom_filters_clear_all: {
title: 'Clear all',
defaultValue: 'Clear all',
group: groups.newsroom,
},
newsroom_country_filter: {
title: 'Country filter heading',
defaultValue: 'Country',
Expand Down Expand Up @@ -720,6 +770,16 @@ const snippets: textSnippet = {
defaultValue: 'Your search returned no results',
group: groups.newsroom,
},
newsroom_related_links: {
title: 'Related links',
defaultValue: 'Related links',
group: groups.newsroom,
},
newsroom_skip_to_news: {
title: 'Skip to list of news',
defaultValue: 'Skip to list of news',
group: groups.newsroom,
},
magazineindex_list_header: {
title: 'Magazine index: Stories list heading',
defaultValue: 'Stories',
Expand Down Expand Up @@ -766,6 +826,26 @@ const snippets: textSnippet = {
defaultValue: 'Switch to',
group: groups.others,
},
next: {
title: 'Next',
defaultValue: 'Next',
group: groups.others,
},
previous: {
title: 'Previous',
defaultValue: 'Previous',
group: groups.others,
},
page: {
title: 'Page',
defaultValue: 'Page',
group: groups.others,
},
remove: {
title: 'Remove',
defaultValue: 'Remove',
group: groups.others,
},
}

type textSnippetGroup = { title: string; hidden?: boolean }
Expand Down
2 changes: 2 additions & 0 deletions search/IndexSanityContent/common/news/SharedNewsFields.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page } from '../../../common'
import { ImageWithAltAndCaption } from '../types'

export type SharedNewsFields = Page & {
title: string
Expand All @@ -18,4 +19,5 @@ export type SharedNewsFields = Page & {
text: string
}[]
_id: string
heroImage?: ImageWithAltAndCaption
}
30 changes: 30 additions & 0 deletions search/IndexSanityContent/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export type ImageWithAlt = {
_type: 'imageWithAlt'
alt: string
isDecorative?: boolean
asset: {
_ref: string
_type: 'reference'
}
crop?: {
_type: 'sanity.imageCrop'
bottom: number
left: number
right: number
top: number
}
hotspot?: {
_type: 'sanity.imageHotspot'
height: number
width: number
x: number
y: number
}
}

export type ImageWithAltAndCaption = {
_type: 'imageWithAltAndCaption'
attribution?: string
caption?: string
image: ImageWithAlt
}
1 change: 1 addition & 0 deletions search/IndexSanityContent/localNews/sanity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const query = /* groq */ `*[_type == "localNews" && lang == $lang && !(_i
title,
"text": pt::text(content)
},
heroImage,
"docToClear": _id match $id
}
`
Expand Down
3 changes: 2 additions & 1 deletion search/IndexSanityContent/magazine/mapper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { pipe } from 'fp-ts/lib/function'
import * as A from 'fp-ts/lib/Array'
import * as O from 'fp-ts/lib/Option'
import { ImageWithAlt, MagazineArticle } from './sanity'
import { MagazineArticle } from './sanity'
import { AccordionIndex, MagazineIndex, TextBlockIndex } from '../../common'
import { mappedAccordions, mappedTextBlocks } from '../common/mappers'
import { ImageWithAlt } from '../common/types'

const getHeroImage = (article: MagazineArticle): ImageWithAlt | null => {
if (article?.heroFigure?.image?.asset) {
Expand Down
32 changes: 1 addition & 31 deletions search/IndexSanityContent/magazine/sanity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SanityClient } from '@sanity/client'
import { Language } from '../../common'
import { MappableAccordionType, MappableTextBlockType } from '../common/mappers'
import { plainTextExcludingStrikeThrough } from '../../common/queryHelpers'
import { ImageWithAlt, ImageWithAltAndCaption } from '../common/types'

export enum HeroTypes {
DEFAULT = 'default',
Expand Down Expand Up @@ -62,37 +63,6 @@ const getQueryParams = (language: Language, id: string) => ({
id: id,
})

export type ImageWithAlt = {
_type: 'imageWithAlt'
alt: string
isDecorative?: boolean
asset: {
_ref: string
_type: 'reference'
}
crop?: {
_type: 'sanity.imageCrop'
bottom: number
left: number
right: number
top: number
}
hotspot?: {
_type: 'sanity.imageHotspot'
height: number
width: number
x: number
y: number
}
}

export type ImageWithAltAndCaption = {
_type: 'imageWithAltAndCaption'
attribution?: string
caption?: string
image: ImageWithAlt
}

export type MagazineArticle = {
slug: string
title: string
Expand Down
4 changes: 3 additions & 1 deletion search/IndexSanityContent/news/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NewsArticle } from './sanity'

type MapDataType = (article: NewsArticle) => NewsIndex[]
export const mapData: MapDataType = (article) => {
const { publishDateTime, topicTags, countryTags, title, ingress, slug, factboxes } = article
const { publishDateTime, topicTags, countryTags, title, ingress, slug, factboxes, heroImage } = article
// Hu hei hvor det går
const year = publishDateTime ? new Date(publishDateTime).getFullYear() : ''
return pipe(
Expand All @@ -24,6 +24,7 @@ export const mapData: MapDataType = (article) => {
topicTags,
countryTags,
year,
heroImage,
} as NewsIndex),
),
A.concat(
Expand All @@ -40,6 +41,7 @@ export const mapData: MapDataType = (article) => {
topicTags,
countryTags,
year,
heroImage,
} as NewsIndex),
),
),
Expand Down
1 change: 1 addition & 0 deletions search/IndexSanityContent/news/sanity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const query = /* groq */ `*[_type == "news" && lang == $lang && !(_id in
title,
"text": pt::text(content)
},
heroImage,
"docToClear": _id match $id
}
`
Expand Down
1 change: 1 addition & 0 deletions search/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type NewsIndex = {
countryTags: string[]
thumbnailUrl: string
localNewsTag: string
heroImage: object
}

export type MagazineIndex = {
Expand Down
Loading

0 comments on commit 7deaafe

Please sign in to comment.