-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
7095e34
commit e2915f6
Showing
14 changed files
with
135 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters