Skip to content

Commit c9d31a3

Browse files
committed
Merge branch 'bose/3854' into staging
2 parents f5bf0e0 + a48fc60 commit c9d31a3

9 files changed

Lines changed: 79 additions & 64 deletions

File tree

studio/schemas/objects/textBlock.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { text_field } from '@equinor/eds-icons'
22
import {
3+
defineArrayMember,
34
defineField,
45
type PortableTextBlock,
56
type Reference,
67
type Rule,
78
} from 'sanity'
9+
import { Flags } from '@/src/lib/datasetHelpers'
810
import blocksToText from '../../helpers/blocksToText'
911
import { EdsIcon } from '../../icons'
1012
import type { ColorSelectorValue } from '../components/ColorSelector'
@@ -114,7 +116,16 @@ export default {
114116
name: 'text',
115117
title: 'Text content',
116118
type: 'array',
117-
of: [configureBlockContent({ variant: 'textBlock' })],
119+
of: [
120+
configureBlockContent({ variant: 'textBlock' }),
121+
// This enables the image upload/paste block
122+
Flags.IS_DEV
123+
? defineArrayMember({
124+
type: 'image',
125+
options: { hotspot: true },
126+
})
127+
: false,
128+
],
118129
},
119130
{
120131
name: 'action',

web/app/globals.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import "tailwindcss" source("../");
22
@import '@energyvision/shared/brand.css';
3-
/* @source '../styles/components/imagezoom.css'; */
43
@source '../styles/components/cookiebot.css';
54

65
/* Custom theme for web, not common brand */

web/core/Image/Image.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
getPxLgSizes,
1111
getPxSmSizes,
1212
getSmallerThanPxLgSizes,
13-
getTwAspectRatioUtilityOnRatio,
1413
type ImageProps,
1514
mapSanityImageRatio,
1615
} from './imageUtilities'
@@ -55,15 +54,8 @@ export const Image = ({
5554
attribution,
5655
figCaptionClassName = '',
5756
keepRatioOnMobile = false,
58-
hasImageZoom = false,
5957
}: ImageProps) => {
60-
let isLargerDisplays = useMediaQuery(`(min-width: 800px)`)
61-
62-
if (hasImageZoom) {
63-
//Override max sizes for mobile since zoom
64-
//grid is set to sm in FigureWithLayout when zoom is enabled.
65-
isLargerDisplays = true
66-
}
58+
const isLargerDisplays = useMediaQuery(`(min-width: 800px)`)
6759

6860
if (!image || !image?.asset) return null
6961

@@ -83,9 +75,6 @@ export const Image = ({
8375
if ('alt' in image && image?.alt) {
8476
altText = image.alt
8577
}
86-
/* const aspectRatioClass = getTwAspectRatioUtilityOnRatio(
87-
isLargerDisplays ? aspectRatio : '4:3',
88-
) */
8978

9079
const nextImage = url ? (
9180
<NextImage
@@ -107,7 +96,6 @@ export const Image = ({
10796
<div
10897
className={twMerge(
10998
`relative h-full max-h-full w-full max-w-full`,
110-
//fill && aspectRatioClass - why did i, Borghild, add this?,
11199
className,
112100
)}
113101
>

web/core/Image/imageUtilities.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
SanityImageCrop,
3-
SanityImageHotspot,
4-
SanityImageObject,
5-
} from '@sanity/image-url'
1+
import type { SanityImageObject } from '@sanity/image-url'
62
import type { ImageProps as NextImageProps } from 'next/image'
73

84
export const ImageRatios = {
@@ -163,7 +159,7 @@ export const getTwAspectRatioUtilityOnRatio = (ratio: ImageRatioKeys) => {
163159
export type Image = {
164160
alt?: string
165161
asset: SanityImageObject
166-
extension: string
162+
extension?: string
167163
}
168164

169165
export type Figure = {
@@ -209,6 +205,4 @@ export type ImageProps = Omit<NextImageProps, 'src' | 'alt' | 'sizes'> & {
209205
figCaptionClassName?: string
210206
/** Ignores 4:3 ratio on mobile */
211207
keepRatioOnMobile?: boolean
212-
/** Enables image zoom functionality on image */
213-
hasImageZoom?: boolean
214208
}

web/core/Typography/Typography.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,21 @@ const findTypography = (
7373

7474
export type TypographyProps = {
7575
/** Typography variants, specifies which variant to use.
76+
*
77+
* Quick variants can be used without providing `group`.
78+
* These are the variants merged into `quickVariants` from the `heading`,
79+
* `paragraph`, `marks`, and `plain` groups in `variants.ts`.
80+
*
81+
* Variants that only exist in grouped collections, such as `display` or `card`,
82+
* should be paired with the matching `group` prop so the class lookup resolves correctly.
7683
* @default body
7784
*/
7885
variant?: TypographyVariants
79-
/** Typography groups, specifies which group to use. */
86+
/** Typography groups, specifies which group to use.
87+
*
88+
* Optional when `variant` is a quick variant.
89+
* Required in practice for grouped-only variants such as `h1_base`, `h2_lg`, or card-specific styles.
90+
*/
8091
group?: TypographyGroups
8192
/** Override the element type */
8293
as?: ElementType
@@ -96,12 +107,31 @@ export type TypographyProps = {
96107

97108
/**
98109
* Typography used for common text styles
110+
*
111+
* When `group` is omitted, the component first resolves `variant` against the shared
112+
* quick variant map. That supports the common heading, paragraph, marks, and plain variants
113+
* without extra configuration.
114+
*
115+
* Use `group` when selecting a variant that belongs to a specific collection such as
116+
* `display`, `card`, or `article`.
117+
*
99118
* @example
100119
* ```jsx
101120
* <Typography variant="h6" as="h2" className="text-moss-green-100">
102121
* I am a h2 heading with h6 styling with classname override
103122
* </Typography>
104123
* ```
124+
*
125+
* @example
126+
* ```jsx
127+
* <Typography variant="body">
128+
* Quick variants like body resolve without a group.
129+
* </Typography>
130+
*
131+
* <Typography variant="h2_base" group="display">
132+
* Display variants should be used with their group.
133+
* </Typography>
134+
* ```
105135
*/
106136
export const Typography: OverridableComponent<TypographyProps, HTMLElement> =
107137
forwardRef(function Typography(
@@ -123,9 +153,7 @@ export const Typography: OverridableComponent<TypographyProps, HTMLElement> =
123153

124154
if (typeof typography === 'undefined') {
125155
console.warn(
126-
`Typography variant not found for variant "${variant}" ("${variant}") & group "${
127-
group || ''
128-
}"`,
156+
`Typography variant not found for variant "${variant}" & group "${group ?? ''}"`,
129157
)
130158
}
131159
const TypographyTag = as ?? (`p` as React.ElementType)

web/portableText/Blocks.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
} from '@portabletext/types'
1414
import dynamic from 'next/dynamic'
1515
import type { ElementType } from 'react'
16+
import { Image } from '@/core/Image/Image'
1617
import DownloadableLink from '@/core/Link/DownloadableLink'
1718
import { Link as CoreLink } from '@/core/Link/Link'
1819
import type { TypographyProps } from '@/core/Typography'
@@ -408,25 +409,8 @@ export default function Blocks({
408409
if (inlineBlockTypes.includes(blocks[i + 1]?._type)) return null
409410
// Otherwise, render the group of text blocks we have
410411
const value = div
411-
//const CustomElementType = as ?? (`div` as React.ElementType)
412412
div = []
413413

414-
/*
415-
Find out why i, borghild put asOneElementTYpe
416-
return asOneElementType && as ? (
417-
<CustomElementType key={block._key} className={className} id={id}>
418-
<PortableText
419-
value={value}
420-
components={componentsProps}
421-
onMissingComponent={(message, options) => {
422-
console.warn(
423-
`${message},type:${options.type},nodeType:${options.nodeType}`,
424-
)
425-
return false
426-
}}
427-
/>
428-
</CustomElementType>
429-
) : ( */
430414
return (
431415
<div
432416
key={block._key}
@@ -445,7 +429,6 @@ export default function Blocks({
445429
/>
446430
</div>
447431
)
448-
/* ) */
449432
}
450433
/** Factbox block */
451434
if (block._type === 'factbox') {
@@ -508,11 +491,25 @@ export default function Blocks({
508491
}
509492
// Non-text blocks (modules, sections, etc.) — note that these can recursively render text
510493
// blocks again
494+
511495
return (
512496
<PortableText
513497
key={block._key}
514498
value={block}
515499
components={{
500+
types: {
501+
image: ({ value }) => {
502+
//@ts-ignore
503+
return (
504+
<Image
505+
aspectRatio='original'
506+
image={value}
507+
useFitMax={true}
508+
className='my-8 border border-gray-50 drop-shadow-md'
509+
/>
510+
)
511+
},
512+
},
516513
...components,
517514
}}
518515
/>

web/portableText/components/news/FigureWithLayout.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import type { PortableTextBlock } from '@portabletext/types'
2-
//Add to packagejson later after upgrade
3-
//import Zoom from 'react-medium-image-zoom'
42
import { twMerge } from 'tailwind-merge'
53
import { FigureCaption } from '@/core/FigureCaption/FigureCaption'
64
import { Image } from '@/core/Image/Image'
@@ -19,16 +17,13 @@ type FigureNode = {
1917
caption?: string
2018
image: ImageType
2119
layout: LayoutAlignment
22-
//Hold until upgrade is done
23-
//enableImageZoom?: boolean
2420
imageOrientation?: 'portrait' | 'landscape' | 'square'
2521
centerImageLayout?: 'left' | 'right'
2622
centerCaptionAlignment?: 'top' | 'center' | 'bottom'
2723
landscapeRatio?: Extract<ImageRatioKeys, '21:9' | 'original' | '16:9'>
2824
}
2925

3026
type BlockProps = {
31-
isInline: boolean
3227
value: FigureNode
3328
} & PortableTextBlock
3429

@@ -39,7 +34,6 @@ export const FigureWithLayout = (block: BlockProps) => {
3934
caption,
4035
attribution,
4136
layout = 'full',
42-
//enableImageZoom = false,
4337
imageOrientation = 'landscape',
4438
centerImageLayout = 'left',
4539
centerCaptionAlignment = 'bottom',

web/sections/AnchorSearch/AnchorSearch.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const AnchorSearch = forwardRef<HTMLDivElement, AnchorSearchProps>(
124124
</ul>
125125
<div
126126
tabIndex={0}
127-
className='flex max-h-[50vh] flex-col overflow-auto border-neutral-400 border-y'
127+
className='flex max-h-[50vh] flex-col gap-4 overflow-auto border-neutral-400 border-y py-4'
128128
>
129129
{letters?.map(contentLetter => {
130130
const content = anchors?.filter(
@@ -137,15 +137,8 @@ const AnchorSearch = forwardRef<HTMLDivElement, AnchorSearchProps>(
137137
return (
138138
<div
139139
key={contentLetter as string}
140-
className='grid auto-cols-min grid-flow-col border-neutral-400 border-b py-8 last:border-none'
140+
className='grid auto-cols-min grid-flow-col gap-4'
141141
>
142-
<Typography
143-
group='plain'
144-
variant='div'
145-
className='w-fit ps-4 pe-20 font-semibold text-2xl'
146-
>
147-
{contentLetter as string}
148-
</Typography>
149142
<div className='grid auto-cols-[500px] grid-flow-col'>
150143
{chunks?.map((chunk: any) => {
151144
return (
@@ -162,6 +155,7 @@ const AnchorSearch = forwardRef<HTMLDivElement, AnchorSearchProps>(
162155
className='text-base hover:underline'
163156
onClick={() => setOpen(false)}
164157
>
158+
{`# `}
165159
{Array.isArray(anchor?.label) ? (
166160
<Blocks value={anchor?.label} />
167161
) : (

web/templates/shared/ErrorBoundaryClient.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,33 @@ export const ErrorBoundaryClient = ({
1919
<ErrorBoundary
2020
fallbackRender={({ error }) => {
2121
console.error(
22-
`Error in component ${c.type}: ${
22+
`Error in component ${c.type} with title: ${
2323
c?.title ? toPlainText(c.title) : ''
2424
}`,
2525
error,
2626
)
2727
return (
2828
<div
2929
role='alert'
30-
className={`mx-layout-sm mb-page-content flex flex-col items-center gap-8 rounded-card bg-gray-20 px-6 py-8 lg:mx-layout-lg`}
30+
className={`mx-layout-sm mb-page-content flex flex-col items-center rounded-card bg-gray-20 px-6 py-8 lg:mx-layout-lg`}
3131
>
3232
<TbFaceIdError size={64} />
33-
<Typography as='h2' variant='h3' className='text-center'>
33+
<Typography as='h2' variant='h4' className='text-center'>
3434
{dataset === 'global-development'
35-
? `Error in component ${c.type}: ${c?.title ? toPlainText(c.title) : ''}`
35+
? `Error in ${c.type}`
3636
: (t('sectionRenderError') ??
3737
`This section could not be shown`)}
3838
</Typography>
39+
{dataset === 'global-development' && (
40+
<>
41+
<Typography as='h3' variant='h5' className='text-center'>
42+
{`Title: ${c?.title ? toPlainText(c.title) : ''}`}
43+
</Typography>
44+
<Typography variant='body' className='pt-2 text-center'>
45+
{error.message}
46+
</Typography>
47+
</>
48+
)}
3949
</div>
4050
)
4151
}}

0 commit comments

Comments
 (0)