Skip to content

Commit

Permalink
🎨 Change footer headings to h2 and some spacing #2579 (#2585)
Browse files Browse the repository at this point in the history
* 🎨 initial

* 🎨 upgrade textwithicon and its array to tw and with title

* 🎨 remove inline styles

* 🎨 change to h2 and some spacing
  • Loading branch information
BorghildSelle authored Nov 4, 2024
1 parent 7095e34 commit e2915f6
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 160 deletions.
18 changes: 18 additions & 0 deletions sanityv3/schemas/objects/textWithIconArray.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { view_module } from '@equinor/eds-icons'
import blocksToText from '../../helpers/blocksToText'
import { EdsIcon } from '../../icons'
import CompactBlockEditor from '../components/CompactBlockEditor'
import { SchemaType } from '../../types'
import { configureTitleBlockContent } from '../editors'

const titleContentType = configureTitleBlockContent()

export default {
type: 'object',
Expand All @@ -14,6 +18,20 @@ export default {
},
],
fields: [
{
name: 'title',
type: 'array',
inputComponent: CompactBlockEditor,
of: [titleContentType],
title: 'Title',
description: 'The list of icon/text should have a heading, can be hidden below',
},
{
name: 'hideTitle',
type: 'boolean',
title: 'Hide title',
description: 'Hides title, but is available for screen readers and gives an meaningful heading for the list',
},
{
type: 'array',
name: 'group',
Expand Down
14 changes: 0 additions & 14 deletions web/components/src/TextWithIcon/Media.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions web/components/src/TextWithIcon/Text.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions web/components/src/TextWithIcon/TextWithIcon.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions web/components/src/TextWithIcon/Title.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions web/components/src/TextWithIcon/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion web/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export * from './Teaser'
export * from './Eyebrow'
export * from './Backgrounds'
export * from './FigureCaption'
export * from './TextWithIcon'
export * from './Accordion'
export * from './Menu'
export * from './Heading'
Expand Down
51 changes: 51 additions & 0 deletions web/core/TextWithIcon/TextWithIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { HTMLAttributes, forwardRef } from 'react'
import envisTwMerge from '../../twMerge'
import { IconData } from '@equinor/eds-icons'
import { TransformableIcon } from '../../icons/TransformableIcon'
import { ImageWithAlt } from '../../types'
import Img from 'next/image'
import { urlFor } from '../../common/helpers'
import { PortableTextBlock } from '@portabletext/types'
import { Typography } from '@core/Typography'
import Blocks from '../../pageComponents/shared/portableText/Blocks'

export type TextWithIconProps = {
title?: string
content?: PortableTextBlock[]
iconData?: IconData
image?: ImageWithAlt
/** Icondata or imageUrl styling */
iconClassName?: string
} & HTMLAttributes<HTMLDivElement>

export const TextWithIcon = forwardRef<HTMLDivElement, TextWithIconProps>(
({ title, content, iconData, className = '', image, iconClassName = '', ...rest }, ref) => {
return (
<div ref={ref} className={envisTwMerge(`flex flex-col gap-2 items-center`, className)} {...rest}>
{iconData && <TransformableIcon iconData={iconData} className={iconClassName} />}
{image && image?.asset && (
<Img
src={urlFor(image).size(150, 150).auto('format').toString()}
width="150"
height="150"
alt={image?.isDecorative ? '' : image?.alt || ''}
role={image?.isDecorative ? 'presentation' : undefined}
className={envisTwMerge(
`size-[150px]
m-auto
self-center
`,
iconClassName,
)}
/>
)}
{title && (
<Typography as="h2" variant="h3">
{title}
</Typography>
)}
{content && <Blocks value={content} className="text-pretty text-center" />}
</div>
)
},
)
5 changes: 5 additions & 0 deletions web/lib/queries/common/pageContentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ _type == "keyNumbers" =>{
_type == "textWithIconArray"=>{
"type": _type,
"id": _key,
title[]{
...,
${markDefs},
},
hideTitle,
"group": group[]{
"id": _key,
title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import TextBlock from '../../topicPages/TextBlock'
import FullWidthImage from '../../topicPages/FullWidthImage'
import FullWidthVideo from '../../topicPages/FullWidthVideo'
import Figure from '../../topicPages/Figure'
import TextWithIconArray from '../../topicPages/TextWithIconArray'
import PageQuote from '../../topicPages/PageQuote'
import AccordionBlock from '../../topicPages/Accordion/AccordionBlock'
import PromoTileArray from '../../../sections/PromoTiles/PromoTileArray'
Expand Down Expand Up @@ -63,6 +62,7 @@ import VideoPlayerCarousel from '@sections/VideoPlayerCarousel/VideoPlayerCarous
import ImageCarousel from '@sections/ImageCarousel/ImageCarousel'
import { AnchorLinkList } from '@sections/AnchorLinkList'
import ImageForText from '@sections/ImageForText/ImageForText'
import TextWithIconArray from '@sections/TextWithIconArray/TextWithIconArray'

type DefaultComponent = {
id?: string
Expand Down
7 changes: 3 additions & 4 deletions web/pageComponents/shared/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Facebook, Instagram, Linkedin, Twitter, Youtube } from '../../icons'
import type { FooterLinkData, SomeType, FooterColumns } from '../../types/index'
import { default as NextLink } from 'next/link'


function getSomeSvg(someType: SomeType) {
const iconMap = {
facebook: <Facebook width={12} />,
Expand Down Expand Up @@ -32,9 +31,9 @@ const Footer = forwardRef<HTMLDivElement, FooterProps>(function Footer({ footerD
<footer className="min-h-12 clear-both text-white-100 bg-slate-blue-95 py-4 px-0" ref={ref} {...rest}>
<div className="flex flex-row flex-wrap my-0 mx-auto justify-between px-layout-sm pb-2 max-w-screen-2xl max-md:flex-col">
{footerData?.footerColumns?.map(({ header, linkList }) => (
<section className="flex flex-col max-md:py-4 max-md:w-4/5" key={header}>
<h3 className="text-md font-medium text-white-100 px-0 py-2 leading-1">{header}</h3>
<div className="grid grid-cols-2 gap-y-2 gap-x-4 items-start md:flex md:flex-col md:grid-y-0">
<section className="flex flex-col max-md:py-4 max-md:w-4/5" key={header}>
<h2 className="text-md font-medium text-white-100 px-0 py-2 leading-planetary">{header}</h2>
<div className="grid grid-cols-2 gap-y-2 gap-x-8 items-start md:flex md:flex-col md:grid-y-0">
{linkList?.map((link: FooterLinkData) => {
const { id, type, someType, label, url } = link
const icon = type === 'someLink' && someType ? getSomeSvg(someType) : null
Expand Down
79 changes: 0 additions & 79 deletions web/pageComponents/topicPages/TextWithIconArray.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions web/sections/TextWithIconArray/TextWithIconArray.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { BackgroundContainer } from '@components'
import type { TextWithIconArrayData, TextWithIconItem } from '../../types/index'
import { twMerge } from 'tailwind-merge'
import { TextWithIcon } from '@core/TextWithIcon/TextWithIcon'
import { Heading } from '@core/Typography'

type TextWithIconArrayProps = {
data: TextWithIconArrayData
anchor?: string
className?: string
listClassName?: string
}

const TextWithIconArray = ({ data, anchor, className = '', listClassName = '' }: TextWithIconArrayProps) => {
const { designOptions, group, title, hideTitle } = data

if (!group) return null

return (
<BackgroundContainer
{...designOptions}
id={anchor}
className={twMerge(
`
px-layout-sm
pb-page-content
mx-auto
flex
flex-col
items-center`,
className,
)}
>
{title && <Heading value={title} variant="h2" className={`${hideTitle ? 'sr-only' : ''}`} />}
<ul
className={twMerge(
`w-full flex flex-col gap-12 lg:grid ${group.length % 2 === 0 ? 'lg:grid-cols-2' : 'lg:grid-cols-3'}`,
listClassName,
)}
>
{group.map((item: TextWithIconItem) => {
const { icon, title, text, id } = item
return (
<li key={id}>
{/*@ts-ignore: TODO check why content?: PortableTextBlock[] does not match text: PortableTextBlock[] */}
<TextWithIcon image={icon} title={title} content={text} />
</li>
)
})}
</ul>
</BackgroundContainer>
)
}

export default TextWithIconArray
2 changes: 2 additions & 0 deletions web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export type TextWithIconItem = {
export type TextWithIconArrayData = {
type: string
id: string
title?: PortableTextBlock[]
hideTitle?: boolean
group: TextWithIconItem[]
designOptions: DesignOptions
}
Expand Down

0 comments on commit e2915f6

Please sign in to comment.