-
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.
Merge branch 'fer/1889' into staging
- Loading branch information
Showing
23 changed files
with
411 additions
and
63 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 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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { label } from '@equinor/eds-icons' | ||
import type { PortableTextBlock } from 'sanity' | ||
import type { ColorSelectorValue } from '../components/ColorSelector' | ||
import { EdsIcon } from '../../icons' | ||
import type { LinkSelector } from './linkSelector' | ||
import { configureBlockContent } from '../editors' | ||
import { getLinkSelectorFields } from './linkSelector' | ||
import blocksToText from '../../helpers/blocksToText' | ||
|
||
const ingressBlockContentType = configureBlockContent({ | ||
h1: false, | ||
h2: false, | ||
h3: false, | ||
h4: false, | ||
internalLink: false, | ||
externalLink: false, | ||
attachment: false, | ||
lists: false, | ||
}) | ||
|
||
export type PromoCardsType = { | ||
_type: 'promoCards' | ||
linkLabelAsTitle?: boolean | ||
link?: LinkSelector | ||
isLink?: boolean | ||
background?: ColorSelectorValue | ||
} | ||
|
||
const linkFields = getLinkSelectorFields('label', 'isLink', false) | ||
|
||
export default { | ||
title: 'Promo cards', | ||
name: 'promoCards', | ||
type: 'object', | ||
fieldsets: [ | ||
{ | ||
title: 'Design options', | ||
name: 'design', | ||
description: 'Some options for design', | ||
options: { | ||
collapsible: true, | ||
collapsed: false, | ||
}, | ||
}, | ||
{ | ||
name: 'link', | ||
title: 'Link', | ||
description: 'Select either an internal link or external URL.', | ||
}, | ||
{ | ||
name: 'label', | ||
title: 'Label', | ||
description: 'The label that the link/button should have.', | ||
}, | ||
], | ||
fields: [ | ||
{ | ||
name: 'ingress', | ||
title: 'Promo Text', | ||
type: 'array', | ||
of: [ingressBlockContentType], | ||
}, | ||
{ | ||
name: 'isLink', | ||
type: 'boolean', | ||
title: 'Use a link', | ||
description: 'Link to another piece of content', | ||
initialValue: false, | ||
}, | ||
...linkFields, | ||
{ | ||
title: 'Background', | ||
description: 'Pick a colour for the background. Default is white.', | ||
name: 'background', | ||
type: 'colorlist', | ||
fieldset: 'design', | ||
}, | ||
], | ||
preview: { | ||
select: { | ||
link: 'label', | ||
ingress: 'ingress', | ||
}, | ||
prepare({ link, ingress }: { link: string; ingress: PortableTextBlock[] }) { | ||
return { | ||
title: link || blocksToText(ingress) || 'Promo Text Tile', | ||
subtitle: `Promo text tile component`, | ||
media: EdsIcon(label), | ||
} | ||
}, | ||
}, | ||
} |
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,43 @@ | ||
import { collection_2 } from '@equinor/eds-icons' | ||
import { EdsIcon } from '../../icons' | ||
import type { Rule } from 'sanity' | ||
import type { PromoCardsType } from './promoCards' | ||
|
||
export type PromoCardsArray = { | ||
_type: 'promoCardsArrayType' | ||
group: PromoCardsType[] | ||
} | ||
|
||
export default { | ||
type: 'object', | ||
name: 'promoCardsArray', | ||
title: 'Promo cards', | ||
fields: [ | ||
{ | ||
name: 'spacing', | ||
type: 'boolean', | ||
title: 'Space between other components', | ||
initialValue: false, | ||
}, | ||
{ | ||
type: 'array', | ||
name: 'group', | ||
description: 'Add promo cards as one or a pair', | ||
title: 'Promo cards', | ||
of: [{ type: 'promoCards' }], | ||
validation: (Rule: Rule) => Rule.required().min(1).max(2), | ||
}, | ||
], | ||
preview: { | ||
select: { | ||
group: 'group', | ||
}, | ||
prepare() { | ||
return { | ||
title: 'Promo cards title', | ||
subtitle: `Promo cards component`, | ||
media: EdsIcon(collection_2), | ||
} | ||
}, | ||
}, | ||
} |
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
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
Oops, something went wrong.