Skip to content

Commit

Permalink
add prefix to header blok
Browse files Browse the repository at this point in the history
  • Loading branch information
the-kwisatz-haderach committed Jan 8, 2024
1 parent 69619de commit 7aab74c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
36 changes: 33 additions & 3 deletions components/StoryBlok/PageHeaderBlok/PageHeaderBlok.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { Box, Button, Heading, Text } from '@chakra-ui/react'
import { BlokType, IPageHeader } from '../../../lib/storyblok/types'
import { storyblokEditable } from '@storyblok/react'
import { Contained } from 'components/Contained/Contained'
import Image from 'next/image'

export default function PageHeaderBlok({
blok,
}: {
blok: BlokType<IPageHeader>
}): ReactElement {
const { title, align = 'left', subtitle, image, height, action_label } = blok
const {
title,
align = 'left',
subtitle,
image,
height,
action_label,
prefix = '',
} = blok
return (
<Box
{...storyblokEditable(blok)}
Expand All @@ -35,14 +44,35 @@ export default function PageHeaderBlok({
<Box
textAlign={align}
width="100%"
display="flex"
flexDir="column"
alignItems={align}
margin={align === 'center' ? 'auto' : 'unset'}
maxWidth={{ base: '600px', lg: '800px', xl: '1000px' }}
>
<Heading as="h1" fontSize={['4xl', '6xl', '7xl', '8xl', '9xl']}>
{prefix && (
<>
<Text
borderBottomStyle="solid"
borderBottomWidth={{ base: 1, md: 2 }}
borderBottomColor="rgba(255,255,255,0.7)"
width="fit-content"
fontWeight="600"
mb={[1, 2]}
pl={align === 'center' ? 3 : 0}
pr={3}
pb={1}
fontSize={['sm', 'md', 'lg', 'xl', '2xl']}
>
{prefix}
</Text>
</>
)}
<Heading as="h1" fontSize={['5xl', '6xl', '7xl', '8xl', '9xl']}>
{title}
</Heading>
{subtitle && (
<Text mt={2} fontSize={['lg', 'lg', 'xl', '2xl', '3xl']}>
<Text mt={[0, 1]} fontSize={['md', 'lg', 'xl', '2xl', '3xl']}>
{subtitle}
</Text>
)}
Expand Down
1 change: 1 addition & 0 deletions lib/storyblok/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface ITeaser {

export interface IPageHeader {
title: string
prefix?: string
subtitle?: string
align?: 'center' | 'left'
image?: ImageField
Expand Down

1 comment on commit 7aab74c

@vercel
Copy link

@vercel vercel bot commented on 7aab74c Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.