Skip to content

Commit

Permalink
add the value prop and faq modules/docs to sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkevingreen committed Aug 6, 2023
1 parent f76fda2 commit f465ba2
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 9 deletions.
49 changes: 49 additions & 0 deletions cms/schemas/documents/faq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {HomeIcon} from '@sanity/icons'
import {defineField} from 'sanity'

export default defineField({
name: 'faq',
type: 'document',
title: 'FAQ',
icon: HomeIcon,
groups: [
{
default: true,
name: 'editorial',
title: 'Editorial',
},
{
name: 'seo',
title: 'SEO',
},
],
fields: [
// Title
defineField({
name: 'question',
title: 'Question',
type: 'string',
validation: (Rule) => Rule.required(),
group: 'editorial',
}),

defineField({
name: 'answer',
title: 'Answer',
type: 'richText',
validation: (Rule) => Rule.required(),
group: 'editorial',
}),
],
preview: {
select: {
title: 'question',
},
prepare({ title}) {
return {
subtitle: 'FAQ',
title
}
},
},
})
9 changes: 1 addition & 8 deletions cms/schemas/documents/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ export default defineField({
defineField({
name: 'modules',
title: 'Modules',
type: 'array',
of: [
{type: 'module.hero'},
// {type: 'module.callout'},
// {type: 'module.callToAction'},
// {type: 'module.image'},
// {type: 'module.product'},
],
type: 'pageComponentList',
group: 'editorial',
}),
// SEO
Expand Down
11 changes: 10 additions & 1 deletion cms/schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import collection from './documents/collection'
import colorType from './documents/colorType'
import home from './documents/home'
import page from './documents/page'
import faq from './documents/faq'
import product from './documents/product'
import productVariant from './documents/productVariant'
import theme from './documents/theme'
Expand All @@ -25,6 +26,7 @@ const documents = [
colorType,
home,
page,
faq,
product,
productVariant,
theme
Expand Down Expand Up @@ -73,7 +75,6 @@ import moduleImage from './objects/module/image'
import moduleImages from './objects/module/images'
import moduleProduct from './objects/module/product'
import moduleProducts from './objects/module/products'
import moduleHero from './objects/module/hero'
import moduleStandardText from './objects/module/standardText'
import placeholderString from './objects/placeholderString'
import productHotspots from './objects/productHotspots'
Expand All @@ -82,6 +83,11 @@ import productWithVariant from './objects/productWithVariant'
import proxyString from './objects/proxyString'
import seo from './objects/seo'

// SUPERHI
import moduleHero from './objects/module/hero'
import moduleFAQs from './objects/module/faqModule'
import moduleValueProps from './objects/module/valueProps'

import shopifyCollection from './objects/shopifyCollection'
import shopifyCollectionRule from './objects/shopifyCollectionRule'
import shopifyProduct from './objects/shopifyProduct'
Expand All @@ -99,7 +105,10 @@ const objects = [
moduleCallToAction,
moduleImage,
moduleImages,
// SUPERHI
moduleHero,
moduleFAQs,
moduleValueProps,

moduleProduct,
moduleProducts,
Expand Down
3 changes: 3 additions & 0 deletions cms/schemas/modules/pageComponentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default {
icon: Icon,
type: 'array',
of: [
{ type: 'module.hero' },
{ type: 'module.valueProps' },
{ type: 'module.faqs' },
{ type: 'module.image' },
{ type: 'module.standardText' },
],
Expand Down
60 changes: 60 additions & 0 deletions cms/schemas/objects/module/faqModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react'
import {defineField, defineType} from 'sanity'
import {PackageIcon} from '@sanity/icons'

import {COLORS} from '../../../constants'

const GROUPS = [
{
name: 'theme',
title: 'Theme',
},
{
default: true,
name: 'editorial',
title: 'Editorial',
},
]

export default defineType({
name: 'module.faqs',
title: 'FAQs',
type: 'object',
icon: PackageIcon,
groups: GROUPS,
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
group: 'editorial',
}),
defineField({
name: 'faqList',
title: 'FAQs',
type: 'array',
of: [
{type: 'reference', to: [{ type: 'faq' }]}
],
group: 'editorial',
validation: Rule => Rule.required().min(1),
}),
defineField({
name: 'bgColor',
title: 'Background Color',
type: 'color',
group: 'theme',
options: {
colorList: COLORS,
},
}),
],
preview: {
select: {},
prepare(selection) {
return {
title: 'FAQs',
}
},
},
})
76 changes: 76 additions & 0 deletions cms/schemas/objects/module/valueProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react'
import {defineField, defineType} from 'sanity'
import {PackageIcon} from '@sanity/icons'

import {COLORS} from '../../../constants'

const GROUPS = [
{
name: 'theme',
title: 'Theme',
},
{
default: true,
name: 'editorial',
title: 'Editorial',
},
]

export default defineType({
name: 'module.valueProps',
title: 'Value Props',
type: 'object',
icon: PackageIcon,
groups: GROUPS,
fields: [
defineField({
name: 'values',
title: 'Values',
type: 'array',
group: 'editorial',
validation: Rule => Rule.required().min(1).max(3),
of: [{
type: 'object',
name: 'value',
title: 'Value',
fields: [
defineField({
name: 'text',
title: 'Text',
type: 'richText',
}),
],
preview: {
select: {
text: 'text'
},
prepare(selection) {
const { text } = selection

const block = (text || []).find(block => block._type === 'block')
return {
title: block.children[0]?.text || 'Value',
}
}
}
}]
}),
defineField({
name: 'bgColor',
title: 'Background Color',
type: 'color',
group: 'theme',
options: {
colorList: COLORS,
},
}),
],
preview: {
select: {},
prepare(selection) {
return {
title: 'Value Props',
}
},
},
})

0 comments on commit f465ba2

Please sign in to comment.