From f465ba2f1502f81ba4c1126958fc9814b4a72187 Mon Sep 17 00:00:00 2001 From: Kevin Green Date: Sat, 5 Aug 2023 18:27:09 -0700 Subject: [PATCH] add the value prop and faq modules/docs to sanity --- cms/schemas/documents/faq.js | 49 +++++++++++++++ cms/schemas/documents/home.js | 9 +-- cms/schemas/index.js | 11 +++- cms/schemas/modules/pageComponentList.js | 3 + cms/schemas/objects/module/faqModule.js | 60 +++++++++++++++++++ cms/schemas/objects/module/valueProps.js | 76 ++++++++++++++++++++++++ 6 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 cms/schemas/documents/faq.js create mode 100644 cms/schemas/objects/module/faqModule.js create mode 100644 cms/schemas/objects/module/valueProps.js diff --git a/cms/schemas/documents/faq.js b/cms/schemas/documents/faq.js new file mode 100644 index 0000000..f52962f --- /dev/null +++ b/cms/schemas/documents/faq.js @@ -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 + } + }, + }, +}) diff --git a/cms/schemas/documents/home.js b/cms/schemas/documents/home.js index 686dc21..714c8c0 100644 --- a/cms/schemas/documents/home.js +++ b/cms/schemas/documents/home.js @@ -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 diff --git a/cms/schemas/index.js b/cms/schemas/index.js index f8b34a8..cd85903 100644 --- a/cms/schemas/index.js +++ b/cms/schemas/index.js @@ -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' @@ -25,6 +26,7 @@ const documents = [ colorType, home, page, + faq, product, productVariant, theme @@ -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' @@ -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' @@ -99,7 +105,10 @@ const objects = [ moduleCallToAction, moduleImage, moduleImages, + // SUPERHI moduleHero, + moduleFAQs, + moduleValueProps, moduleProduct, moduleProducts, diff --git a/cms/schemas/modules/pageComponentList.js b/cms/schemas/modules/pageComponentList.js index 0886ac4..bb075a2 100644 --- a/cms/schemas/modules/pageComponentList.js +++ b/cms/schemas/modules/pageComponentList.js @@ -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' }, ], diff --git a/cms/schemas/objects/module/faqModule.js b/cms/schemas/objects/module/faqModule.js new file mode 100644 index 0000000..e0f877c --- /dev/null +++ b/cms/schemas/objects/module/faqModule.js @@ -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', + } + }, + }, +}) diff --git a/cms/schemas/objects/module/valueProps.js b/cms/schemas/objects/module/valueProps.js new file mode 100644 index 0000000..db294d9 --- /dev/null +++ b/cms/schemas/objects/module/valueProps.js @@ -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', + } + }, + }, +})