diff --git a/web/components/src/Quote/Author.tsx b/web/components/src/Quote/Author.tsx deleted file mode 100644 index fd6cbff87..000000000 --- a/web/components/src/Quote/Author.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { forwardRef, HTMLAttributes } from 'react' -import styled from 'styled-components' -import { Typography } from '@equinor/eds-core-react' - -type AuthorProps = { - title?: string | null -} & HTMLAttributes - -const Row = styled.figcaption` - text-align: left; - grid-area: author; - align-self: end; - - @media (min-width: 800px) { - text-align: right; - align-self: start; - } -` - -const AuthorWrapper = styled(Typography)` - text-align: left; - display: inline-flex; - flex-direction: column; - margin-right: auto; - - color: var(--color-on-background); - - @media (min-width: 800px) { - margin-left: auto; - } -` - -const TextWrapper = styled.span` - color: var(--color-on-background); -` - -export const Author = forwardRef(function Author( - { children, title = null, ...rest }, - ref, -) { - return ( - - {title ? ( - - {children} - {title} - - ) : ( - {children} - )} - - ) -}) diff --git a/web/components/src/Quote/BlockQuote.tsx b/web/components/src/Quote/BlockQuote.tsx deleted file mode 100644 index 9f872f802..000000000 --- a/web/components/src/Quote/BlockQuote.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { forwardRef } from 'react' -import styled from 'styled-components' - -const Container = styled.div` - display: flex; - align-items: row; -` - -const Quote = styled.blockquote` - background: none; - margin: 0; - color: var(--color-on-background); -` - -const Author = styled.figcaption` - text-align: right; - margin-top: var(--space-medium); - font-style: italic; -` - -export type BlockQuoteProps = { - quote: string - author: string - image?: string | null // url -} - -export const BlockQuote = forwardRef(function BlockQuote( - { quote, author, image = null }, - ref, -) { - return ( - -
- {quote} - {author} -
- {image ? ( - <> - {/* eslint-disable-next-line @next/next/no-img-element */} - - - ) : null} -
- ) -}) diff --git a/web/components/src/Quote/Media.tsx b/web/components/src/Quote/Media.tsx deleted file mode 100644 index d728631ab..000000000 --- a/web/components/src/Quote/Media.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { forwardRef, HTMLAttributes } from 'react' -import styled from 'styled-components' - -type MediaProps = HTMLAttributes - -const Img = styled.div` - width: 100%; - align-self: center; - grid-area: media; - - img { - border-radius: 50%; - } -` - -export const Media = forwardRef(function Media({ children, ...rest }, ref) { - return ( - - {children} - - ) -}) diff --git a/web/components/src/Quote/PullQuote.tsx b/web/components/src/Quote/PullQuote.tsx deleted file mode 100644 index 3ec192a5a..000000000 --- a/web/components/src/Quote/PullQuote.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { forwardRef, HTMLAttributes, isValidElement, Children } from 'react' -import { Media } from './Media' -import styled from 'styled-components' - -type ImagePosition = 'left' | 'right' - -export type PullQuoteProps = { - imagePosition?: ImagePosition -} & HTMLAttributes - -type ContainerProps = { - $hasImage: boolean - imagePosition: ImagePosition -} - -const Container = styled.figure` - display: grid; - row-gap: var(--space-medium); - margin: 0; - position: relative; - grid-template-rows: min-content min-content; - grid-template-columns: calc(5 * var(--space-medium)) var(--space-medium) 1fr; // TODO: Inconsistent spacing - grid-template-areas: ${({ $hasImage }) => - $hasImage - ? ` - 'media spacing author' - 'quote quote quote' - ` - : ` - 'quote quote quote' - 'author author author' - `}; - - @media (min-width: 800px) { - grid-template-columns: ${({ imagePosition, $hasImage }) => - $hasImage && imagePosition === 'left' - ? `calc(11 * var(--space-medium)) var(--space-medium) 1fr` - : $hasImage - ? `1fr var(--space-medium) calc(11 * var(--space-medium))` - : `1fr var(--space-4xLarge) calc(5 * var(--space-medium))`}; - grid-template-areas: ${({ imagePosition, $hasImage }) => - $hasImage && imagePosition === 'left' - ? ` - 'media spacing quote' - 'media spacing author' - ` - : $hasImage - ? ` - 'quote spacing media' - 'author spacing media' - ` - : ` - 'quote quote quote' - 'author author author' - `}; - } -` - -export const PullQuote = forwardRef(function PullQuote( - { imagePosition = 'right', children }, - ref, -) { - const hasImage = Children.toArray(children).some((child) => isValidElement(child) && child.type === Media) - return ( - - {children} - - ) -}) diff --git a/web/components/src/Quote/Quote.tsx b/web/components/src/Quote/Quote.tsx deleted file mode 100644 index 3e330007b..000000000 --- a/web/components/src/Quote/Quote.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { forwardRef, HTMLAttributes } from 'react' -import styled from 'styled-components' -import { Text as BaseText } from '../Text' - -type QuoteProps = HTMLAttributes - -type TextProps = { - weight: string - fontSize: string -} - -const Text = styled(BaseText)` - align-self: end; - margin: 0; - font-style: italic; - color: var(--color-on-background); - font-weight: var(${({ weight }: TextProps) => weight}, --fontWeight-regular); - font-size: var(${({ fontSize }: TextProps) => fontSize}, --typeScale-1); -` - -const Container = styled.div` - grid-area: quote; -` - -const textBoldLimit = 160 -const textSizeLimit = 50 - -export const Quote = forwardRef(function Quote({ children, ...rest }, ref) { - if (!children) return null - - const quoteText = children.toString().trim() - - const weight = quoteText.length < textBoldLimit ? '--fontWeight-medium' : '--fontWeight-regular' - const size = quoteText.length < textSizeLimit ? '--typeScale-5' : '--typeScale-2' - const iconSize = quoteText.length < textSizeLimit ? '48px' : '36px' - return ( - - - Quote symbol - - - - {quoteText} - - - ) -}) diff --git a/web/components/src/Quote/index.ts b/web/components/src/Quote/index.ts deleted file mode 100644 index a40eb4293..000000000 --- a/web/components/src/Quote/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { PullQuote as PullQuoteWrapper, PullQuoteProps } from './PullQuote' -import { Media } from './Media' -import { Author } from './Author' -import { Quote } from './Quote' - -type PullQuoteCompoundProps = typeof PullQuoteWrapper & { - Media: typeof Media - Author: typeof Author - Quote: typeof Quote -} - -const PullQuote = PullQuoteWrapper as PullQuoteCompoundProps - -PullQuote.Media = Media -PullQuote.Author = Author -PullQuote.Quote = Quote - -export { PullQuote } -export type { PullQuoteProps } - -export * from './BlockQuote' diff --git a/web/components/src/index.ts b/web/components/src/index.ts index 460e6754f..4054c57f2 100644 --- a/web/components/src/index.ts +++ b/web/components/src/index.ts @@ -1,7 +1,6 @@ export * from './Button' export * from './Card' export * from './Topbar' -export * from './Quote' export * from './Fact' export * from './Text' export * from './FormattedDateTime' diff --git a/web/icons/QuoteSymbol.tsx b/web/icons/QuoteSymbol.tsx new file mode 100644 index 000000000..7f6b5de6e --- /dev/null +++ b/web/icons/QuoteSymbol.tsx @@ -0,0 +1,16 @@ +const QuoteSymbol = ({ iconSize }: { iconSize?: string }) => { + return ( + + Quote symbol + + + ) +} + +export default QuoteSymbol diff --git a/web/icons/index.ts b/web/icons/index.ts index 2c2b71206..f4ad66bd9 100644 --- a/web/icons/index.ts +++ b/web/icons/index.ts @@ -6,3 +6,4 @@ export { default as Youtube } from './Youtube' export { default as ArrowRight } from './ArrowRight' export { default as Play } from './Play' export { default as Pause } from './Pause' +export { default as QuoteSymbol } from './QuoteSymbol' diff --git a/web/pageComponents/shared/Quote.tsx b/web/pageComponents/shared/Quote.tsx index 81f2abe8c..257f99929 100644 --- a/web/pageComponents/shared/Quote.tsx +++ b/web/pageComponents/shared/Quote.tsx @@ -1,24 +1,74 @@ -import { PullQuote } from '@components' -import type { QuoteData } from '../../types/index' import Image, { Ratios } from './SanityImage' +import type { ImageWithAlt, DesignOptions } from '../../types/index' +import { QuoteSymbol } from '../../icons' -const Quote = ({ data: { quote, authorTitle, author, image, designOptions } }: { data: QuoteData }) => ( - - {quote} - - {author && {author}} - - {image?.asset && ( - - - - )} - -) +const textBoldLimit = 160 +const textSizeLimit = 50 + +export type ImagePosition = 'left' | 'right' + +type QuoteData = { + type: string + id: string + author: string + authorTitle?: string + quote: string + image?: ImageWithAlt + designOptions: DesignOptions & { imagePosition?: ImagePosition } +} + +const Quote = ({ data: { quote, authorTitle, author, image, designOptions } }: { data: QuoteData }) => { + if (!quote) return null + const imagePosition = designOptions?.imagePosition || 'right' + const isImageLeft = imagePosition === 'left' + + const weight = quote.length < textBoldLimit ? 'font-semibold' : 'font-normal' + const size = quote.length < textSizeLimit ? 'text-2xl' : 'text-lg' + const iconSize = quote.length < textSizeLimit ? 'w-12 h-12' : 'w-9 h-9' + + return ( +
+ {image?.asset && isImageLeft && ( +
+ +
+ )} + +
+ +
{quote}
+
+ + {image?.asset && !isImageLeft && ( +
+ +
+ )} + + {author && ( +
+ {author} + {authorTitle && {authorTitle}} +
+ )} +
+ ) +} export default Quote