From e2915f6a98c3eb62ef5c1db62e46ebf1366e8986 Mon Sep 17 00:00:00 2001 From: Borghild Selle <104756130+BorghildSelle@users.noreply.github.com> Date: Mon, 4 Nov 2024 08:59:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=20Change=20footer=20headings=20?= =?UTF-8?q?to=20h2=20and=20some=20spacing=20#2579=20(#2585)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :art: initial * :art: upgrade textwithicon and its array to tw and with title * :art: remove inline styles * :art: change to h2 and some spacing --- .../schemas/objects/textWithIconArray.tsx | 18 +++++ web/components/src/TextWithIcon/Media.tsx | 14 ---- web/components/src/TextWithIcon/Text.tsx | 14 ---- .../src/TextWithIcon/TextWithIcon.tsx | 12 --- web/components/src/TextWithIcon/Title.tsx | 18 ----- web/components/src/TextWithIcon/index.ts | 17 ---- web/components/src/index.ts | 1 - web/core/TextWithIcon/TextWithIcon.tsx | 51 ++++++++++++ web/lib/queries/common/pageContentFields.ts | 5 ++ .../shared/SharedPageContent.tsx | 2 +- web/pageComponents/shared/Footer.tsx | 7 +- .../topicPages/TextWithIconArray.tsx | 79 ------------------- .../TextWithIconArray/TextWithIconArray.tsx | 55 +++++++++++++ web/types/types.ts | 2 + 14 files changed, 135 insertions(+), 160 deletions(-) delete mode 100644 web/components/src/TextWithIcon/Media.tsx delete mode 100644 web/components/src/TextWithIcon/Text.tsx delete mode 100644 web/components/src/TextWithIcon/TextWithIcon.tsx delete mode 100644 web/components/src/TextWithIcon/Title.tsx delete mode 100644 web/components/src/TextWithIcon/index.ts create mode 100644 web/core/TextWithIcon/TextWithIcon.tsx delete mode 100644 web/pageComponents/topicPages/TextWithIconArray.tsx create mode 100644 web/sections/TextWithIconArray/TextWithIconArray.tsx diff --git a/sanityv3/schemas/objects/textWithIconArray.tsx b/sanityv3/schemas/objects/textWithIconArray.tsx index 855992956..13e615a3b 100644 --- a/sanityv3/schemas/objects/textWithIconArray.tsx +++ b/sanityv3/schemas/objects/textWithIconArray.tsx @@ -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', @@ -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', diff --git a/web/components/src/TextWithIcon/Media.tsx b/web/components/src/TextWithIcon/Media.tsx deleted file mode 100644 index 21842bea8..000000000 --- a/web/components/src/TextWithIcon/Media.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { HTMLAttributes } from 'react' -import styled from 'styled-components' - -type MediaProps = HTMLAttributes - -const Img = styled.div` - align-self: center; - grid-area: media; - margin-bottom: var(--space-medium); -` - -export const Media = ({ children, ...rest }: MediaProps) => { - return {children} -} diff --git a/web/components/src/TextWithIcon/Text.tsx b/web/components/src/TextWithIcon/Text.tsx deleted file mode 100644 index 2cab9f54b..000000000 --- a/web/components/src/TextWithIcon/Text.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { HTMLAttributes } from 'react' -import styled from 'styled-components' - -type TextProps = HTMLAttributes - -const StyledText = styled.div` - p { - margin-bottom: 0; - } -` - -export const Text = ({ children, ...rest }: TextProps) => { - return {children} -} diff --git a/web/components/src/TextWithIcon/TextWithIcon.tsx b/web/components/src/TextWithIcon/TextWithIcon.tsx deleted file mode 100644 index 2c8c722e7..000000000 --- a/web/components/src/TextWithIcon/TextWithIcon.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { HTMLAttributes } from 'react' -import styled from 'styled-components' - -type TextWithIconProps = HTMLAttributes - -const Container = styled.div` - text-align: center; -` - -export const TextWithIcon = ({ children, ...rest }: TextWithIconProps) => { - return {children} -} diff --git a/web/components/src/TextWithIcon/Title.tsx b/web/components/src/TextWithIcon/Title.tsx deleted file mode 100644 index f61827243..000000000 --- a/web/components/src/TextWithIcon/Title.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { HTMLAttributes } from 'react' -import { Heading } from '../Heading' -import styled from 'styled-components' - -type TitleProps = HTMLAttributes - -const StyledTitle = styled(Heading)` - margin: 0; - text-align: center; -` - -export const Title = ({ children, ...rest }: TitleProps) => { - return ( - - {children} - - ) -} diff --git a/web/components/src/TextWithIcon/index.ts b/web/components/src/TextWithIcon/index.ts deleted file mode 100644 index 6a256b8c2..000000000 --- a/web/components/src/TextWithIcon/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TextWithIcon as TextWithIconWrapper } from './TextWithIcon' -import { Media } from './Media' -import { Title } from './Title' -import { Text } from './Text' - -type TextWithIconProps = typeof TextWithIconWrapper & { - Media: typeof Media - Title: typeof Title - Text: typeof Text -} - -const TextWithIcon = TextWithIconWrapper as TextWithIconProps -TextWithIcon.Media = Media -TextWithIcon.Title = Title -TextWithIcon.Text = Text - -export { TextWithIcon } diff --git a/web/components/src/index.ts b/web/components/src/index.ts index 63a786766..26e7c653f 100644 --- a/web/components/src/index.ts +++ b/web/components/src/index.ts @@ -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' diff --git a/web/core/TextWithIcon/TextWithIcon.tsx b/web/core/TextWithIcon/TextWithIcon.tsx new file mode 100644 index 000000000..11a718083 --- /dev/null +++ b/web/core/TextWithIcon/TextWithIcon.tsx @@ -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 + +export const TextWithIcon = forwardRef( + ({ title, content, iconData, className = '', image, iconClassName = '', ...rest }, ref) => { + return ( +
+ {iconData && } + {image && image?.asset && ( + {image?.isDecorative + )} + {title && ( + + {title} + + )} + {content && } +
+ ) + }, +) diff --git a/web/lib/queries/common/pageContentFields.ts b/web/lib/queries/common/pageContentFields.ts index 3fb169ec2..e27516cdd 100644 --- a/web/lib/queries/common/pageContentFields.ts +++ b/web/lib/queries/common/pageContentFields.ts @@ -119,6 +119,11 @@ _type == "keyNumbers" =>{ _type == "textWithIconArray"=>{ "type": _type, "id": _key, + title[]{ + ..., + ${markDefs}, + }, + hideTitle, "group": group[]{ "id": _key, title, diff --git a/web/pageComponents/pageTemplates/shared/SharedPageContent.tsx b/web/pageComponents/pageTemplates/shared/SharedPageContent.tsx index b8b49294e..41fb27160 100644 --- a/web/pageComponents/pageTemplates/shared/SharedPageContent.tsx +++ b/web/pageComponents/pageTemplates/shared/SharedPageContent.tsx @@ -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' @@ -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 diff --git a/web/pageComponents/shared/Footer.tsx b/web/pageComponents/shared/Footer.tsx index 72c5f3030..474aadb2f 100644 --- a/web/pageComponents/shared/Footer.tsx +++ b/web/pageComponents/shared/Footer.tsx @@ -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: , @@ -32,9 +31,9 @@ const Footer = forwardRef(function Footer({ footerD