diff --git a/apps/astro/src/components/Components.astro b/apps/astro/src/components/Components.astro index 56e7082..10b14b8 100644 --- a/apps/astro/src/components/Components.astro +++ b/apps/astro/src/components/Components.astro @@ -5,6 +5,7 @@ import Faq, { Faq_Query } from '@/components/global/Faq.astro' import TagsSection, { TagsSection_Query } from '@/components/global/TagsSection.astro' import MarqueePillSection, { MarqueePillSection_Query } from '@/components/global/MarqueePillSection.astro' import HeaderGridIcons, { HeaderGridIcons_Query } from '@/components/global/HeaderGridIcons.astro' +import SimpleHeaderWithImage, { SimpleHeaderWithImage_Query } from '@/components/global/SimpleHeaderWithImage.astro' const components = { SimpleCtaSection, @@ -12,6 +13,7 @@ const components = { TagsSection, MarqueePillSection, HeaderGridIcons, + SimpleHeaderWithImage, } type ComponentsMap = { @@ -38,6 +40,7 @@ export const Components_Query = /* groq */ ` ${TagsSection_Query} ${MarqueePillSection_Query} ${HeaderGridIcons_Query} + ${SimpleHeaderWithImage_Query} }, ` --- diff --git a/apps/astro/src/components/global/SimpleHeaderWithImage.astro b/apps/astro/src/components/global/SimpleHeaderWithImage.astro new file mode 100644 index 0000000..dd42d55 --- /dev/null +++ b/apps/astro/src/components/global/SimpleHeaderWithImage.astro @@ -0,0 +1,54 @@ +--- +import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image' +import PortableText, { PortableTextQuery, type PortableTextValue } from '@/components/ui/portable-text' + +export const SimpleHeaderWithImage_Query = ` + _type == "SimpleHeaderWithImage" => { + ${PortableTextQuery('heading')} + ${PortableTextQuery('paragraph')} + ${ImageDataQuery('img')} + }, +` + +type Props = { + index: number + sectionId?: string + heading: PortableTextValue + paragraph: PortableTextValue + img: ImageDataProps +} + +const { index, sectionId, heading, paragraph, img } = Astro.props +--- + +
+
+ + +
+ +
+ + diff --git a/apps/sanity/schema/Components.ts b/apps/sanity/schema/Components.ts index d640940..37de758 100644 --- a/apps/sanity/schema/Components.ts +++ b/apps/sanity/schema/Components.ts @@ -4,6 +4,7 @@ import Faq from "./components/Faq"; import TagsSection from "./components/TagsSection"; import MarqueePillSection from "./components/MarqueePillSection"; import HeaderGridIcons from "./components/HeaderGridIcons"; +import SimpleHeaderWithImage from "./components/SimpleHeaderWithImage"; export default defineType({ name: 'components', @@ -15,6 +16,7 @@ export default defineType({ TagsSection, MarqueePillSection, HeaderGridIcons, + SimpleHeaderWithImage, ], options: { insertMenu: { diff --git a/apps/sanity/schema/components/SimpleHeaderWithImage.ts b/apps/sanity/schema/components/SimpleHeaderWithImage.ts new file mode 100644 index 0000000..548a6b4 --- /dev/null +++ b/apps/sanity/schema/components/SimpleHeaderWithImage.ts @@ -0,0 +1,46 @@ +import { defineField } from 'sanity'; +import sectionId from '../ui/sectionId'; +import { toPlainText } from '../../utils/to-plain-text'; + +const name = 'SimpleHeaderWithImage'; +const title = 'Simple Header With Image'; +const icon = () => '📷'; + +export default defineField({ + name, + type: 'object', + title, + icon, + fields: [ + defineField({ + name: 'heading', + type: 'Heading', + title: 'Heading', + validation: Rule => Rule.required(), + }), + defineField({ + name: 'paragraph', + type: 'PortableText', + title: 'Paragraph', + validation: Rule => Rule.required(), + }), + defineField({ + name: 'img', + type: 'image', + title: 'Image', + validation: Rule => Rule.required(), + }), + ...sectionId, + ], + preview: { + select: { + media: 'img', + heading: 'heading', + }, + prepare: ({ heading, media }) => ({ + title: title, + subtitle: toPlainText(heading), + media, + }), + }, +}); diff --git a/apps/sanity/static/SimpleHeaderWithImage.webp b/apps/sanity/static/SimpleHeaderWithImage.webp new file mode 100644 index 0000000..01c4e9f Binary files /dev/null and b/apps/sanity/static/SimpleHeaderWithImage.webp differ