-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0496df6
commit 48b9cae
Showing
6 changed files
with
153 additions
and
3 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
68 changes: 68 additions & 0 deletions
68
apps/astro/src/components/global/FeatureAccordionSection.astro
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,68 @@ | ||
--- | ||
import PortableText, { PortableTextQuery, type PortableTextValue } from '@/components/ui/portable-text' | ||
import Image, { ImageDataQuery, type ImageDataProps } from '@/components/ui/image' | ||
import Accordion from '@/components/ui/Accordion.astro' | ||
export const FeatureAccordionSection_Query = ` | ||
{ | ||
${ImageDataQuery('img')} | ||
${PortableTextQuery('heading')} | ||
list[] { | ||
${PortableTextQuery('title')} | ||
${PortableTextQuery('description')} | ||
} | ||
}, | ||
` | ||
export type Props = { | ||
index: number | ||
img: ImageDataProps | ||
heading: PortableTextValue | ||
list: { | ||
title: PortableTextValue | ||
description: PortableTextValue | ||
}[] | ||
} | ||
const { index, img, heading, list } = Astro.props | ||
--- | ||
|
||
<section class="FeatureAccordionSection"> | ||
<Image {...img} sizes="(max-width: calc(499rem / 16)) 100vw, 50vw" priority={index === 0} /> | ||
<div> | ||
<PortableText value={heading} heading={index === 0 ? 'h1' : 'h2'} class="heading" /> | ||
{ | ||
list?.map(({ title, description }, i) => ( | ||
<Accordion summary={title} class="accordion" open={i === 0}> | ||
<PortableText value={description} /> | ||
</Accordion> | ||
)) | ||
} | ||
</div> | ||
</section> | ||
|
||
<style lang="scss"> | ||
.FeatureAccordionSection { | ||
display: grid; | ||
align-items: flex-start; | ||
gap: clamp(calc(32rem / 16), calc(48vw / 7.68), calc(48rem / 16)) | ||
clamp(calc(64rem / 16), calc(82vw / 7.68), calc(124rem / 16)); | ||
grid-template-columns: 1fr 1.2fr; | ||
@media (max-width: calc(899rem / 16)) { | ||
grid-template-columns: 1fr; | ||
img { | ||
width: 298px; | ||
} | ||
} | ||
& > div { | ||
max-width: calc(608rem / 16); | ||
} | ||
} | ||
.heading { | ||
margin-bottom: clamp(calc(32rem / 16), calc(48vw / 7.68), calc(48rem / 16)); | ||
} | ||
.accordion { | ||
&:not(:last-child) { | ||
margin-bottom: clamp(calc(24rem / 16), calc(48vw / 7.68), calc(48rem / 16)); | ||
} | ||
} | ||
</style> |
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,75 @@ | ||
import { defineField } from 'sanity'; | ||
import { toPlainText } from '../../utils/to-plain-text'; | ||
|
||
const name = 'FeatureAccordionSection'; | ||
const title = 'Sekcja z akordeonem cech'; | ||
const icon = () => '🏛️'; | ||
|
||
export default defineField({ | ||
name, | ||
type: 'object', | ||
title, | ||
icon, | ||
fields: [ | ||
defineField({ | ||
name: 'img', | ||
type: 'image', | ||
title: 'Zdjęcie', | ||
validation: Rule => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'heading', | ||
type: 'Heading', | ||
title: 'Nagłówek', | ||
validation: Rule => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'list', | ||
type: 'array', | ||
title: 'Lista', | ||
of: [ | ||
defineField({ | ||
name: 'item', | ||
type: 'object', | ||
fields: [ | ||
defineField({ | ||
name: 'title', | ||
type: 'Heading', | ||
title: 'Tytuł', | ||
validation: Rule => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'description', | ||
type: 'PortableText', | ||
title: 'Opis', | ||
validation: Rule => Rule.required(), | ||
}), | ||
], | ||
preview: { | ||
select: { | ||
title: 'title', | ||
description: 'description', | ||
}, | ||
prepare: ({ title, description }) => ({ | ||
title: toPlainText(title), | ||
subtitle: toPlainText(description), | ||
}), | ||
} | ||
}), | ||
], | ||
validation: Rule => Rule.required() | ||
}), | ||
], | ||
preview: { | ||
select: { | ||
heading: 'heading', | ||
media: 'img', | ||
}, | ||
prepare: ({ heading, media }) => ({ | ||
title: title, | ||
subtitle: toPlainText(heading), | ||
media, | ||
icon, | ||
}), | ||
}, | ||
}); |
Binary file not shown.