-
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
42fe354
commit 9ef8f5c
Showing
11 changed files
with
138 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
import type { ComponentProps } from 'astro/types' | ||
import SimpleCtaSection, { SimpleCtaSection_Query } from '@/components/global/SimpleCtaSection.astro' | ||
const components = { | ||
SimpleCtaSection, | ||
} | ||
type ComponentsMap = { | ||
[Component in keyof typeof components]: { | ||
_type: Component | ||
} & ComponentProps<(typeof components)[Component]> | ||
} | ||
export type ComponentsProps = Array<ComponentsMap[keyof typeof components]> | ||
type Props = { | ||
data: ComponentsProps | ||
indexStart?: number | ||
} | ||
const { data, indexStart = 0 } = Astro.props | ||
export const Components_Query = /* groq */ ` | ||
components[] { | ||
_type, | ||
_type == "SimpleCtaSection" => { | ||
${SimpleCtaSection_Query} | ||
}, | ||
}, | ||
` | ||
--- | ||
|
||
{ | ||
data?.map((item, i) => { | ||
const DynamicComponent = components[item._type] | ||
if (!DynamicComponent) return null | ||
return <DynamicComponent {...item} index={indexStart + i} /> | ||
}) | ||
} |
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,48 @@ | ||
--- | ||
import PortableText, { PortableTextQuery, type PortableTextValue } from '@/src/components/ui/portable-text' | ||
import Button, { ButtonDataQuery, type ButtonDataProps } from '@/components/ui/button' | ||
export const SimpleCtaSection_Query = ` | ||
${PortableTextQuery('name')} | ||
${PortableTextQuery('text')} | ||
${ButtonDataQuery('cta')} | ||
` | ||
export type Props = { | ||
index: number | ||
name: PortableTextValue | ||
text: PortableTextValue | ||
cta: ButtonDataProps | ||
} | ||
const { index, name, text, cta } = Astro.props | ||
--- | ||
|
||
<section class="SimpleCtaSection sec-wo-margin"> | ||
<div class="max-width"> | ||
<PortableText value={name} class="h3" /> | ||
<header> | ||
<PortableText value={text} heading={index === 0 ? 'h1' : 'h2'} class="h3" /> | ||
<Button {...cta} class="cta" /> | ||
</header> | ||
</div> | ||
</section> | ||
|
||
<style lang="scss"> | ||
.SimpleCtaSection { | ||
padding: clamp(calc(32rem / 16), calc(80vw / 7.68), calc(144rem / 16)) 0; | ||
background: var(--primary-300, #f4efe8); | ||
.max-width { | ||
max-width: calc(1024rem / 16); | ||
display: grid; | ||
gap: clamp(calc(32rem / 16), calc(56vw / 7.68), calc(56rem / 16)) | ||
clamp(calc(42rem / 16), calc(56vw / 7.68), calc(56rem / 16)); | ||
@media (min-width: calc(1000rem / 16)) { | ||
grid-template-columns: 1fr 3.6fr; | ||
} | ||
} | ||
} | ||
.cta { | ||
margin-top: 2rem; | ||
} | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,20 @@ | ||
--- | ||
import Layout from '@/src/layouts/Layout.astro' | ||
import metadataFetch from '@/utils/metadata.fetch' | ||
import sanityFetch from '@/utils/sanity.fetch' | ||
import Components, { Components_Query, type ComponentsProps } from '@/components/Components.astro' | ||
const metadata = await metadataFetch('Index_Page') | ||
const data = await sanityFetch<{ components: ComponentsProps }>({ | ||
query: ` | ||
*[_type == "Index_Page"][0] { | ||
${Components_Query} | ||
} | ||
`, | ||
}) | ||
--- | ||
|
||
<Layout {...metadata}> | ||
<h1>Index Page</h1> | ||
<Components data={data.components} /> | ||
</Layout> |
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 was deleted.
Oops, something went wrong.