59 lines
3.0 KiB
TypeScript
59 lines
3.0 KiB
TypeScript
import { Reveal } from '../Reveal'
|
|
import { ServiceIcon } from '../ServiceIcon'
|
|
import { useSectionHeading, useSite } from '../../api'
|
|
import { useFieldSaver } from '../../admin/AdminContext'
|
|
import { InlineEdit } from '../admin/InlineEdit'
|
|
import { AddItemButton, EditableItem } from '../../admin/Editable'
|
|
|
|
export function Services({ tone = 'black' }: { tone?: 'black' | 'gray' } = {}) {
|
|
const { services } = useSite()
|
|
const heading = useSectionHeading('services')
|
|
const save = useFieldSaver()
|
|
|
|
const saveHeading = (field: 'title' | 'lead', value: string) =>
|
|
save('section-headings', heading.id, { [field]: value }, (d) => {
|
|
const h = d.section_headings.find((s) => s.id === heading.id)
|
|
if (h) h[field] = value
|
|
})
|
|
|
|
return (
|
|
<section className={`w-full max-w-full overflow-hidden ${tone === 'black' ? 'bg-char' : 'bg-ink'} py-12 md:py-24 lg:py-32`} aria-labelledby="services-title">
|
|
<div className="mx-auto max-w-site px-4 md:px-6 lg:px-10">
|
|
<Reveal className="max-w-2xl text-start">
|
|
<h2 id="services-title" className="text-section font-bold text-ivory">
|
|
<InlineEdit value={heading.title} onSave={(v) => saveHeading('title', v)} />
|
|
</h2>
|
|
<p className="mt-3 text-sm font-light leading-7 text-ivory/60 md:mt-5 md:text-base md:leading-9">
|
|
<InlineEdit multiline value={heading.lead} onSave={(v) => saveHeading('lead', v)} />
|
|
</p>
|
|
<div className="mt-4 h-px w-24 bg-copper/70 md:mt-6" />
|
|
</Reveal>
|
|
|
|
<div className="mt-8 grid grid-cols-2 gap-3 md:mt-14 md:gap-5 md:grid-cols-2 lg:grid-cols-4">
|
|
{services.map((service, i) => (
|
|
<Reveal key={service.id} delay={0.04 * i} className="h-full">
|
|
<EditableItem resource="services" item={service} className="h-full">
|
|
<article className="group flex h-full flex-col items-center rounded-xl border border-ivory/10 bg-char p-3.5 text-center transition-all duration-300 ease-out hover:-translate-y-2 hover:border-copper/40 hover:shadow-lift transform-gpu will-change-transform md:rounded-2xl md:p-8">
|
|
<div className="flex h-10 w-10 items-center justify-center md:h-14 md:w-14">
|
|
<ServiceIcon
|
|
name={service.icon}
|
|
className="h-10 w-10 text-copper/85 transition-colors duration-300 ease-out group-hover:text-copper md:h-14 md:w-14"
|
|
/>
|
|
</div>
|
|
<h3 className="mt-3 text-sm font-bold text-ivory transition-colors duration-300 ease-out group-hover:text-copper md:mt-6 md:text-lg">
|
|
{service.title}
|
|
</h3>
|
|
<p className="mt-2 text-xs font-light leading-relaxed text-ivory/55 md:mt-3 md:text-sm md:leading-8">
|
|
{service.desc}
|
|
</p>
|
|
</article>
|
|
</EditableItem>
|
|
</Reveal>
|
|
))}
|
|
<AddItemButton resource="services" />
|
|
</div>
|
|
</div>
|
|
</section>
|
|
)
|
|
}
|