Skip to content

Commit

Permalink
add IconGridWithCtaSection
Browse files Browse the repository at this point in the history
  • Loading branch information
milewskibogumil committed Oct 16, 2024
1 parent f3785b6 commit 843cfef
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 23 deletions.
20 changes: 11 additions & 9 deletions apps/astro/src/components/Components.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CtaSectionWithShapedImage, {
import ServicesOverview, { ServicesOverview_Query } from '@/components/global/ServicesOverview.astro'
import MetricsSection, { MetricsSection_Query } from '@/components/global/MetricsSection.astro'
import Faq, { Faq_Query } from '@/components/global/Faq.astro'
import IconGridWithCtaSection, { IconGridWithCtaSection_Query } from '@/components/global/IconGridWithCtaSection.astro'
const components = {
SimpleCtaSection,
SplitContentImageGrid,
Expand All @@ -22,6 +22,7 @@ const components = {
ServicesOverview,
MetricsSection,
Faq,
IconGridWithCtaSection,
}
type ComponentsMap = {
Expand All @@ -42,14 +43,15 @@ const { data, indexStart = 0 } = Astro.props
export const Components_Query = /* groq */ `
components[] {
_type,
_type == "SimpleCtaSection" => ${SimpleCtaSection_Query}
_type == "SplitContentImageGrid" => ${SplitContentImageGrid_Query}
_type == "SimpleHeadingFullImage" => ${SimpleHeadingFullImage_Query}
_type == "FeatureAccordionSection" => ${FeatureAccordionSection_Query}
_type == "CtaSectionWithShapedImage" => ${CtaSectionWithShapedImage_Query}
_type == "ServicesOverview" => ${ServicesOverview_Query}
_type == "MetricsSection" => ${MetricsSection_Query}
_type == "Faq" => ${Faq_Query}
${SimpleCtaSection_Query}
${SplitContentImageGrid_Query}
${SimpleHeadingFullImage_Query}
${FeatureAccordionSection_Query}
${CtaSectionWithShapedImage_Query}
${ServicesOverview_Query}
${MetricsSection_Query}
${Faq_Query}
${IconGridWithCtaSection_Query}
},
`
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/b
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const CtaSectionWithShapedImage_Query = `
{
_type == "CtaSectionWithShapedImage" => {
${PortableTextQuery('heading')}
${PortableTextQuery('paragraph')}
${PortableTextQuery('description')}
Expand Down
4 changes: 2 additions & 2 deletions apps/astro/src/components/global/Faq.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Accordion from '@/components/ui/Accordion.astro'
import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/button'
export const Faq_Query = `
{
_type == "Faq" => {
${PortableTextQuery('heading')}
items[] -> {
${PortableTextQuery('question')}
Expand Down Expand Up @@ -53,7 +53,7 @@ const { index, heading, items, ctaDescription, cta, img } = Astro.props

<style lang="scss">
.Faq {
padding: clamp(calc(48rem / 16), calc(60vw / 7.68), calc(80rem / 16)) 0;
padding: clamp(3rem, calc(4vw / 0.48), 4rem) 0;
display: grid;
align-items: flex-start;
grid-template-rows: auto 1fr auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/imag
import Accordion from '@/components/ui/Accordion.astro'
export const FeatureAccordionSection_Query = `
{
_type == "FeatureAccordionSection" => {
${ImageDataQuery('img')}
${PortableTextQuery('heading')}
list[] {
Expand Down
114 changes: 114 additions & 0 deletions apps/astro/src/components/global/IconGridWithCtaSection.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
import PortableText, { PortableTextQuery, type PortableTextValue } from '@/components/ui/portable-text'
import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/button'
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const IconGridWithCtaSection_Query = `
_type == "IconGridWithCtaSection" => {
${PortableTextQuery('heading')}
items[] {
${ImageDataQuery('icon')}
label,
},
${PortableTextQuery('ctaDescription')}
${ButtonDataQuery('cta')}
},
`
export type Props = {
index: number
heading: PortableTextValue
items: {
icon: ImageDataProps
label: string
}[]
ctaDescription: PortableTextValue
cta: ButtonDataProps
}
const { index, heading, items, ctaDescription, cta } = Astro.props
---

<section class="IconGridWithCtaSection">
<PortableText value={heading} heading={index === 0 ? 'h1' : 'h2'} class="h2 heading" />
<ul class="list">
{
items.map(({ icon, label }) => (
<li class="item">
<Image {...icon} sizes="28px" />
<p>{label}</p>
</li>
))
}
</ul>
<div class="highlight">
<PortableText value={ctaDescription} class="ctaDescription" />
<Button {...cta} />
</div>
</section>

<style lang="scss">
.IconGridWithCtaSection {
padding: clamp(3rem, calc(4vw / 0.48), 8rem) 0;
display: grid;
gap: clamp(2rem, calc(3vw / 0.48), 3rem) 1rem;
display: grid;
align-items: center;
.heading {
text-align: center;
max-width: 28rem;
margin: 0 auto;
}
@media (min-width: 75rem) {
grid-template-columns: 1fr 2fr 1fr;
.heading {
text-align: left;
}
}
}

.list {
background-color: var(--primary-300, #f4efe8);
padding: 0.5rem;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
align-items: center;
gap: 0.5rem;
.item {
min-height: 16rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
gap: 1rem;
text-align: center;
font-size: 0.875rem;
background-color: var(--primary-100, #fffefd);
padding: clamp(1rem, calc(1.5vw / 0.48), 1.5rem) 1rem;
img {
width: 28px;
height: 28px;
}
&::before {
content: '';
}
}
@media (max-width: 37rem) {
grid-template-columns: unset;
.item {
text-align: left;
min-height: unset;
flex-direction: row-reverse;
&::before {
display: none;
}
}
}
}
.highlight {
text-align: center;
.ctaDescription {
margin-bottom: clamp(0.75rem, calc(1.25vw / 0.48), 1.25rem);
}
}
</style>
2 changes: 1 addition & 1 deletion apps/astro/src/components/global/MetricsSection.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PortableText, { PortableTextQuery, type PortableTextValue } from '@/compo
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const MetricsSection_Query = `
{
_type == "MetricsSection" => {
${PortableTextQuery('heading')}
${PortableTextQuery('paragraph')}
metrics[] {
Expand Down
2 changes: 1 addition & 1 deletion apps/astro/src/components/global/ServicesOverview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/b
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const ServicesOverview_Query = `
{
_type == "ServicesOverview" => {
${PortableTextQuery('heading')}
${PortableTextQuery('paragraph')}
items[] {
Expand Down
2 changes: 1 addition & 1 deletion apps/astro/src/components/global/SimpleCtaSection.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PortableText, { PortableTextQuery, type PortableTextValue } from '@/compo
import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/button'
export const SimpleCtaSection_Query = `
{
_type == "SimpleCtaSection" => {
${PortableTextQuery('name')}
${PortableTextQuery('text')}
${ButtonDataQuery('cta')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/b
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const SimpleHeadingFullImage_Query = `
{
_type == "SimpleHeadingFullImage" => {
${PortableTextQuery('heading')}
${PortableTextQuery('paragraph')}
${ButtonDataQuery('cta')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/b
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image'
export const SplitContentImageGrid_Query = `
{
_type == "SplitContentImageGrid" => {
${PortableTextQuery('heading')}
${PortableTextQuery('paragraph')}
${ButtonDataQuery('cta')}
Expand Down
2 changes: 1 addition & 1 deletion apps/astro/src/components/ui/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export const ButtonDataQuery = (name: string) => `
text,
theme,
linkType,
"href": select(type == "internal" => internal -> slug.current, type == "external" => external, "#"),
"href": select(linkType == "internal" => internal -> slug.current, linkType == "external" => external, "#"),
},
`
11 changes: 7 additions & 4 deletions apps/astro/src/global/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ h6,
}
h1,
.h1 {
font-size: clamp(calc(28rem / 16), calc(40vw / 7.68), calc(40rem / 16));
font-size: clamp(1.75rem, calc(2.5vw / 0.48), 2.5rem);
letter-spacing: -0.06em;
}
h2,
.h2,
.h2 {
font-size: clamp(1.5rem, calc(2vw / 0.48), 2rem);
letter-spacing: -0.04em;
}
h3,
.h3 {
font-size: clamp(calc(24rem / 16), calc(32vw / 7.68), calc(32rem / 16));
letter-spacing: -0.04em;
font-size: clamp(1.25rem, calc(1.5vw / 0.48), 1.5rem);
letter-spacing: -0.06em;
}

.link {
Expand Down
2 changes: 2 additions & 0 deletions apps/sanity/schema/Components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CtaSectionWithShapedImage from "./components/CtaSectionWithShapedImage";
import ServicesOverview from "./components/ServicesOverview";
import MetricsSection from "./components/MetricsSection";
import Faq from "./components/Faq";
import IconGridWithCtaSection from "./components/IconGridWithCtaSection";

export default defineType({
name: 'components',
Expand All @@ -21,6 +22,7 @@ export default defineType({
ServicesOverview,
MetricsSection,
Faq,
IconGridWithCtaSection,
],
options: {
insertMenu: {
Expand Down
79 changes: 79 additions & 0 deletions apps/sanity/schema/components/IconGridWithCtaSection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { defineField } from 'sanity';
import { toPlainText } from '../../utils/to-plain-text';

const name = 'IconGridWithCtaSection';
const title = 'Sekcja z siatką ikon i CTA';
const icon = () => '🔲';

export default defineField({
name,
type: 'object',
title,
icon,
fields: [
defineField({
name: 'heading',
type: 'Heading',
title: 'Nagłówek',
validation: Rule => Rule.required(),
}),
defineField({
name: 'items',
type: 'array',
title: 'Elementy',
of: [
defineField({
name: 'item',
type: 'object',
fields: [
defineField({
name: 'icon',
type: 'image',
title: 'Ikona',
validation: Rule => Rule.required(),
}),
defineField({
name: 'label',
type: 'string',
title: 'Etykieta',
validation: Rule => Rule.required(),
}),
],
preview: {
select: {
media: 'icon',
label: 'label',
},
prepare: ({ media, label }) => ({
media: media,
title: label,
}),
},
}),
],
validation: Rule => Rule.required().min(1).max(4),
}),
defineField({
name: 'ctaDescription',
type: 'PortableText',
title: 'Opis przed CTA',
validation: Rule => Rule.required(),
}),
defineField({
name: 'cta',
type: 'cta',
title: 'Wezwanie do działania',
validation: Rule => Rule.required(),
}),
],
preview: {
select: {
heading: 'heading',
},
prepare: ({ heading }) => ({
title: title,
subtitle: toPlainText(heading),
icon,
}),
},
});
Binary file added apps/sanity/static/IconGridWithCtaSection.webp
Binary file not shown.

0 comments on commit 843cfef

Please sign in to comment.