Skip to content

Commit

Permalink
add large image component
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman committed Oct 21, 2024
1 parent b424252 commit 9ad55e5
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 32 deletions.
7 changes: 6 additions & 1 deletion src/components/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ export const Hero2 = styled.h2<{ $color?: ColorKey }>(({ theme, $color }) => ({
color: $color && (theme.colors[$color] as string),
}))

export const Title2 = styled.h3<{ $color?: ColorKey }>(({ theme, $color }) => ({
export const Title1 = styled.h3<{ $color?: ColorKey }>(({ theme, $color }) => ({
...theme.partials.marketingText.title1,
color: $color && (theme.colors[$color] as string),
}))

export const Title2 = styled.h4<{ $color?: ColorKey }>(({ theme, $color }) => ({
...theme.partials.marketingText.title2,
color: $color && (theme.colors[$color] as string),
}))
Expand Down
33 changes: 8 additions & 25 deletions src/components/custom-page/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Button, Code, Flex } from '@pluralsh/design-system'
import { Button, Flex } from '@pluralsh/design-system'
import Link from 'next/link'

import { getImageUrl } from '@src/consts/routes'
import { type HeroComponentFragment } from '@src/generated/graphqlDirectus'
import { cn } from '@src/utils/cn'

import { ImageAspectRatio } from '../AspectRatio'
import Embed from '../Embed'
import { Body1, Hero1 } from '../Typography'

import { getSpacingClassName } from './common'
import { Multimedia } from './Multimedia'

export function Hero({
spacing,
Expand All @@ -22,8 +20,6 @@ export function Hero({
video_url: videoUrl,
form,
}: HeroComponentFragment) {
const imageUrl = getImageUrl(image)

return (
<section className={cn(getSpacingClassName(spacing), 'mx-xxxxxxlarge')}>
<Flex gap="xxxlarge">
Expand All @@ -47,25 +43,12 @@ export function Hero({
</Button>
)}
</Flex>
<div className="m-auto flex-1 ">
{mediaType === 'image' ? (
imageUrl && (
<ImageAspectRatio
$aspectRatio="16 / 10"
$url={imageUrl}
/>
)
) : mediaType === 'video' ? (
<Embed
aspectRatio="16/10"
url={videoUrl ?? ''}
/>
) : mediaType === 'form' ? (
<Code css={{ overflow: 'auto', maxHeight: '500px' }}>
{form ?? ''}
</Code>
) : null}
</div>
<Multimedia
mediaType={mediaType}
image={image}
videoUrl={videoUrl}
form={form}
/>
</Flex>
</section>
)
Expand Down
56 changes: 54 additions & 2 deletions src/components/custom-page/LargeImage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
import { Button, Flex } from '@pluralsh/design-system'
import Link from 'next/link'

import { type LargeImageComponentFragment } from '@src/generated/graphqlDirectus'

export function LargeImage({ spacing }: LargeImageComponentFragment) {
return <div>LargeImage</div>
import { cn } from '../cn'
import { Body2, OverlineLabel, Title1 } from '../Typography'

import { getSpacingClassName } from './common'
import { Multimedia } from './Multimedia'

export function LargeImage({
spacing,
overline,
heading,
body_text: bodyText,
cta_text: ctaText,
cta_url: ctaUrl,
media_type: mediaType,
image,
video_url: videoUrl,
form,
}: LargeImageComponentFragment) {
return (
<section className={cn(getSpacingClassName(spacing), 'mx-xxxxxxlarge')}>
<Flex gap="xxxlarge">
<Multimedia
mediaType={mediaType}
image={image}
videoUrl={videoUrl}
form={form}
/>
<Flex
flex={1}
flexDirection="column"
justifyContent="center"
gap="medium"
>
{overline && <OverlineLabel>{overline}</OverlineLabel>}
<Title1>{heading}</Title1>
<Body2 $color="text-light">{bodyText}</Body2>
{ctaText && (
<Button
className="mt-medium w-fit"
as={Link}
target="_blank"
rel="noopener noreferrer"
href={ctaUrl}
>
{ctaText}
</Button>
)}
</Flex>
</Flex>
</section>
)
}
49 changes: 49 additions & 0 deletions src/components/custom-page/Multimedia.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { type ComponentProps } from 'react'

import { Code } from '@pluralsh/design-system'

import { getImageUrl } from '@src/consts/routes'
import { type ImageFileFragment } from '@src/generated/graphqlDirectus'

import { ImageAspectRatio } from '../AspectRatio'
import Embed from '../Embed'

export function Multimedia({
mediaType,
image,
videoUrl,
form,
aspectRatio = '16 / 10',
...props
}: {
mediaType: Nullable<string>
image: Nullable<ImageFileFragment>
videoUrl: Nullable<string>
form: Nullable<string>
aspectRatio?: string
} & ComponentProps<'div'>) {
const imageUrl = getImageUrl(image)

return (
<div
className="m-auto flex-1"
{...props}
>
{mediaType === 'image' ? (
imageUrl && (
<ImageAspectRatio
$aspectRatio={aspectRatio}
$url={imageUrl}
/>
)
) : mediaType === 'video' ? (
<Embed
aspectRatio={aspectRatio}
url={videoUrl ?? ''}
/>
) : mediaType === 'form' ? (
<Code css={{ overflow: 'auto', maxHeight: '500px' }}>{form ?? ''}</Code>
) : null}
</div>
)
}
Loading

0 comments on commit 9ad55e5

Please sign in to comment.