Skip to content
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

✨ Upgrade newsroom #2433 #2448

Merged
merged 38 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dce7a69
:art: start fetching on selection
BorghildSelle Aug 6, 2024
6a11ba1
✨ Index news hero image #2433
padms Aug 8, 2024
744c2de
:art: updated newsroom
BorghildSelle Aug 9, 2024
2aaf981
:art: lint errors and algolia for newsroom
BorghildSelle Aug 12, 2024
ae26104
:art: transient props
BorghildSelle Aug 13, 2024
7e72cc5
:Art new player
BorghildSelle Aug 14, 2024
218ed5e
:art: add pagination and translations,degrade next and next sanity
BorghildSelle Aug 14, 2024
78f24fc
Merge branch 'main' into bose/2433
BorghildSelle Aug 14, 2024
e7ea199
:art: delete new provider since downgrade
BorghildSelle Aug 14, 2024
2130ba6
:art: responsive versions
BorghildSelle Aug 15, 2024
f945746
:art: look over packages
BorghildSelle Aug 16, 2024
021e0d1
:art: adjustments to max w
BorghildSelle Aug 19, 2024
562ad57
Merge branch 'main' into bose/2433
BorghildSelle Aug 19, 2024
a1c5a24
:bug: fix lg padding
BorghildSelle Aug 19, 2024
058afa4
Merge branch 'main' into bose/2433
BorghildSelle Aug 21, 2024
cf9ad02
:art: update
BorghildSelle Aug 21, 2024
395737b
:art: design changes and added radix ui accordion
BorghildSelle Aug 22, 2024
7d724bb
:art: add max w
BorghildSelle Aug 22, 2024
f640539
:art: update
BorghildSelle Aug 26, 2024
5e35ed2
:art: more accessibility
BorghildSelle Aug 26, 2024
9cd0ea2
:art: wrong hook
BorghildSelle Aug 26, 2024
9ecd26b
:art: make algolia search box to core comp
BorghildSelle Aug 27, 2024
ef86f5a
:art: fix thumbnail images
BorghildSelle Aug 27, 2024
655b286
:art: specify no end border
BorghildSelle Aug 29, 2024
d978d9d
:bug: fix console logs and revert sanity client
BorghildSelle Sep 3, 2024
44839d2
Merge branch 'main' into bose/2433
BorghildSelle Sep 11, 2024
035990f
:bug: fix responsive bugs
BorghildSelle Sep 13, 2024
c3d7037
:art: allow a bit bigger images
BorghildSelle Sep 13, 2024
212ac18
:art: change initial load and refinements to sanity
BorghildSelle Sep 23, 2024
7ee8c08
:art: sanity pagination
BorghildSelle Sep 24, 2024
f6d7988
:art: update queries
BorghildSelle Sep 25, 2024
32596d5
:art: update groqs
BorghildSelle Sep 30, 2024
3f358ac
:art: take some algolia back
BorghildSelle Oct 3, 2024
f1375c6
:art: revert to algolia
BorghildSelle Oct 3, 2024
65df0a7
:art: add skeleton to newsroom
BorghildSelle Oct 3, 2024
804a464
remove failing deprecated tests
BorghildSelle Oct 3, 2024
a053eca
:art: remove unused
BorghildSelle Oct 3, 2024
f2540f9
Merge branch 'main' into bose/2433
BorghildSelle Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sanityv3/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 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,36 @@ export default {
type: 'array',
of: [textContentType],
},
{
name: 'subscriptionHeading',
title: 'Heading for the subscription banner',
type: 'string',
},
{
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',
},
{
name: 'localNewsPagesHeading',
title: 'Heading for the local news pages banner',
type: 'string',
},
{
title: 'List of local news pages',
name: 'localNewsPages',
type: 'array',
of: [{ type: 'linkSelector', title: 'Link' }],
},
],
preview: {
select: {
Expand Down
55 changes: 55 additions & 0 deletions sanityv3/schemas/textSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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 @@ -111,6 +121,26 @@ const snippets: textSnippet = {
defaultValue: 'Sorry, no results were found. Please try again with some different keywords.',
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 @@ -667,6 +697,16 @@ 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_country_filter: {
title: 'Country filter heading',
defaultValue: 'Country',
Expand Down Expand Up @@ -734,6 +774,21 @@ const snippets: textSnippet = {
defaultValue: 'Back to content',
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,
},
}

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
15 changes: 8 additions & 7 deletions web/common/helpers/getPaths.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { groq } from 'next-sanity'
import { getNameFromLocale } from '../../lib/localization'
import { publishDateTimeQuery } from '../../lib/queries/common/publishDateTime'
import { sanityClient } from '../../lib/sanity.server'
import { getClient } from '../../lib/sanity.server'
import { noDrafts, sameLang } from './../../lib/queries/common/langAndDrafts'

// These URLs uses SSR and thus should not be static rendered
Expand All @@ -14,7 +14,7 @@ const getTopicRoutesForLocale = async (locale: string) => {
const lang = getNameFromLocale(locale)
// Empty array as fallback for satelittes
const blacklist = topicSlugBlackList[lang as keyof typeof topicSlugBlackList] || []
const data: { slug: string; _updatedAt: string }[] = await sanityClient.fetch(
const data: { slug: string; _updatedAt: string }[] = await getClient(false).fetch(
groq`*[_type match "route_" + $lang + "*" && (!(slug.current in $blacklist)) && defined(slug.current) && !(_id in path("drafts.**"))][] {
_updatedAt,
"slug": slug.current,
Expand All @@ -30,7 +30,7 @@ const getTopicRoutesForLocaleToStaticallyBuild = async (locale: string) => {
const lang = getNameFromLocale(locale)
// Empty array as fallback for satelittes
const blacklist = topicSlugBlackList[lang as keyof typeof topicSlugBlackList] || []
const data: { slug: string; _updatedAt: string }[] = await sanityClient.fetch(
const data: { slug: string; _updatedAt: string }[] = await getClient(false).fetch(
groq`*[_type match "route_" + $lang + "*" && (!(slug.current in $blacklist)) && includeInBuild && defined(slug.current) && !(_id in path("drafts.**"))][] {
_updatedAt,
"slug": slug.current,
Expand All @@ -40,12 +40,13 @@ const getTopicRoutesForLocaleToStaticallyBuild = async (locale: string) => {
blacklist,
},
)
console.log('data', data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be here?

return data
}

const getDocumentsForLocale = async (type: 'news' | 'localNews' | 'magazine', locale: string) => {
const lang = getNameFromLocale(locale)
const data: { slug: string; _updatedAt: string }[] = await sanityClient.fetch(
const data: { slug: string; _updatedAt: string }[] = await getClient(false).fetch(
groq`*[_type == $type && defined(slug.current) && ${sameLang} && ${noDrafts}][] {
_updatedAt,
"slug": slug.current,
Expand All @@ -62,7 +63,7 @@ const getDocumentsForLocale = async (type: 'news' | 'localNews' | 'magazine', lo
// Only include drafts if preview mode is enabled
export const getDocumentBySlug = async (slug: string, isPreview = false) => {
const draft = isPreview ? `` : /* groq */ `&& ${noDrafts}`
const data: { slug: string; _updatedAt: string }[] = await sanityClient.fetch(
const data: { slug: string; _updatedAt: string }[] = await getClient(false).fetch(
groq`*[defined(slug.current) && slug.current == $slug ${draft}][0] {
_updatedAt,
"slug": slug.current,
Expand Down Expand Up @@ -148,7 +149,7 @@ export const getLocalNewsPaths = async (locales: string[]): Promise<PathType[]>
export const getNewsroomPaths = async (): Promise<PathType[]> => {
// Use last published news as updatedAt field for newsroom
const getUpdatedAt = async (lang: 'en_GB' | 'nb_NO'): Promise<{ _updatedAt: string }> =>
await sanityClient.fetch(
await getClient(false).fetch(
groq`*[_type == 'news' && ${sameLang} && ${noDrafts}] | order(${publishDateTimeQuery} desc)[0] {
_updatedAt,
}`,
Expand Down Expand Up @@ -177,7 +178,7 @@ export const getNewsroomPaths = async (): Promise<PathType[]> => {
export const getMagazineIndexPaths = async (): Promise<PathType[]> => {
// Use last published news as updatedAt field for newsroom
const getUpdatedAt = async (lang: 'en_GB' | 'nb_NO'): Promise<{ _updatedAt: string }> =>
await sanityClient.fetch(
await getClient(false).fetch(
groq`*[_type == 'magazine' && ${sameLang} && ${noDrafts}] | order(_createdAt desc)[0] {
_updatedAt,
}`,
Expand Down
8 changes: 4 additions & 4 deletions web/components/src/Accordion/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const StyledHeader = styled(Typography)`
}
`

const StyledTypography = styled(Typography)<{ isExpanded?: boolean }>`
const StyledTypography = styled(Typography)<{ $isExpanded?: boolean }>`
font-size: var(--typeScale-1);
line-height: var(--lineHeight-2);
display: inline-block;
Expand All @@ -65,8 +65,8 @@ const StyledTypography = styled(Typography)<{ isExpanded?: boolean }>`

color: var(--color-on-background);

${({ isExpanded }) =>
isExpanded && {
${({ $isExpanded }) =>
$isExpanded && {
fontWeight: 700,
}}
`
Expand All @@ -92,7 +92,7 @@ export const Header = forwardRef<HTMLButtonElement, AccordionHeaderProps>(functi
<FilledIcon size={iconSize} data={add_circle_filled} />
</StyledIcon>
)}
<StyledTypography isExpanded={isOpen} forwardedAs="span">
<StyledTypography $isExpanded={isOpen} forwardedAs="span">
{children}
</StyledTypography>
</StyledCAccordionButton>
Expand Down
Loading
Loading