-
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.
✨ Add big title option to 50-50 banner #1887
- Loading branch information
Showing
6 changed files
with
50 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { Rule, ValidationContext } from 'sanity' | ||
import { PortableTextBlock, Rule, ValidationContext } from 'sanity' | ||
import CompactBlockEditor from '../../components/CompactBlockEditor' | ||
import { configureBlockContent, configureTitleBlockContent } from '../../editors' | ||
import { HeroTypes } from '../../HeroTypes' | ||
|
||
type DocumentType = { parent: { heroType?: string } } | ||
type DocumentType = { parent: Hero } | ||
type Hero = { | ||
heroType?: string | ||
isBigTitle?: boolean | ||
} | ||
|
||
const titleContentType = configureTitleBlockContent() | ||
const ingressContentType = configureBlockContent({ | ||
|
@@ -14,6 +18,29 @@ const ingressContentType = configureBlockContent({ | |
attachment: false, | ||
}) | ||
|
||
const isBigTitle = { | ||
title: 'Big title', | ||
name: 'isBigTitle', | ||
type: 'boolean', | ||
fieldset: 'header', | ||
hidden: ({ parent }: DocumentType) => { | ||
return parent?.heroType !== HeroTypes.FIFTY_FIFTY | ||
}, | ||
} | ||
|
||
const heroBigTitle = { | ||
name: 'heroBigTitle', | ||
title: 'Big Title', | ||
type: 'array', | ||
fieldset: 'header', | ||
of: [titleContentType], | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
padms
Author
Contributor
|
||
hidden: ({ parent }: DocumentType) => !parent.isBigTitle, | ||
validation: (Rule: Rule) => | ||
Rule.custom((value: PortableTextBlock[], ctx: ValidationContext) => | ||
!value && (ctx.parent as Hero)?.isBigTitle ? 'Title is required' : true, | ||
), | ||
} | ||
|
||
const title = { | ||
name: 'title', | ||
type: 'array', | ||
|
@@ -76,7 +103,9 @@ const heroTitle = { | |
of: [titleContentType], | ||
fieldset: 'header', | ||
hidden: ({ parent }: DocumentType) => { | ||
return parent?.heroType !== HeroTypes.FIFTY_FIFTY | ||
return ( | ||
parent?.heroType !== HeroTypes.FIFTY_FIFTY || (parent?.heroType === HeroTypes.FIFTY_FIFTY && parent.isBigTitle) | ||
) | ||
}, | ||
validation: (Rule: Rule) => | ||
Rule.custom((value: string, context: ValidationContext) => { | ||
|
@@ -92,7 +121,9 @@ const heroIngress = { | |
type: 'array', | ||
of: [ingressContentType], | ||
hidden: ({ parent }: DocumentType) => { | ||
return parent?.heroType !== HeroTypes.FIFTY_FIFTY | ||
return ( | ||
parent?.heroType !== HeroTypes.FIFTY_FIFTY || (parent?.heroType === HeroTypes.FIFTY_FIFTY && parent.isBigTitle) | ||
) | ||
}, | ||
fieldset: 'header', | ||
} | ||
|
@@ -104,7 +135,9 @@ const heroLink = { | |
type: 'array', | ||
of: [{ type: 'linkSelector', title: 'Link' }], | ||
hidden: ({ parent }: DocumentType) => { | ||
return parent?.heroType !== HeroTypes.FIFTY_FIFTY | ||
return ( | ||
parent?.heroType !== HeroTypes.FIFTY_FIFTY || (parent?.heroType === HeroTypes.FIFTY_FIFTY && parent.isBigTitle) | ||
) | ||
}, | ||
fieldset: 'header', | ||
validation: (Rule: Rule) => Rule.max(1).error('Only one action is permitted'), | ||
|
@@ -179,10 +212,12 @@ const heroLoopingVideoRatio = { | |
} | ||
|
||
export default [ | ||
isBigTitle, | ||
title, | ||
heroType, | ||
heroRatio, | ||
heroTitle, | ||
heroBigTitle, | ||
heroIngress, | ||
heroLink, | ||
background, | ||
|
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 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 |
---|---|---|
|
@@ -80,7 +80,7 @@ const HeroActionLink = ({ action, ...rest }: { action: LinkData }) => { | |
) | ||
} | ||
|
||
export const FiftyFiftyHero = ({ title, ingress, link, background, figure }: HeroType) => { | ||
export const FiftyFiftyHero = ({ title, ingress, link, background, figure, isBigTitle }: HeroType) => { | ||
return ( | ||
<> | ||
<StyledHero background={background}> | ||
|
@@ -97,8 +97,9 @@ export const FiftyFiftyHero = ({ title, ingress, link, background, figure }: Her | |
)} | ||
</StyledMedia> | ||
<StyledContent> | ||
{title && <StyledHeroTitle value={title} level="h1" size="xl" />} | ||
{ingress && ( | ||
{isBigTitle} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{title && <StyledHeroTitle value={title} level="h1" size={isBigTitle ? '2xl' : 'xl'} />} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
padms
Author
Contributor
|
||
{ingress && !isBigTitle && ( | ||
<StyledIngress> | ||
<IngressText | ||
value={ingress} | ||
|
@@ -114,7 +115,7 @@ export const FiftyFiftyHero = ({ title, ingress, link, background, figure }: Her | |
/> | ||
</StyledIngress> | ||
)} | ||
{link && <HeroActionLink action={link} />} | ||
{link && !isBigTitle && <HeroActionLink action={link} />} | ||
</StyledContent> | ||
</StyledHero> | ||
</> | ||
|
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
nice to make this visually big for editors, title could also be 'Title' instead of 'Big TItle':
vs