Debian Codegraph @

www/src/components/Sponsors.astro

raw
1 ---
2 interface Props {
3 sponsors: Record<string, any>[];
4 }
5
6 import { Image } from 'astro:assets';
7
8 const { sponsors } = Astro.props;
9
10 const sponsorLogos = import.meta.glob('/src/assets/img/sponsors/*.{svg,png,jpg,jpeg,webp}', { eager: true });
11
12 const sponsorsByTier = sponsors.reduce((acc, sponsor) => {
13 if (!acc[sponsor.tier]) acc[sponsor.tier] = [];
14 acc[sponsor.tier].push(sponsor);
15 return acc;
16 }, {} as Record<string, typeof sponsors>);
17
18 const tiers = Object.keys(sponsorsByTier);
19 ---
20
21 <div class="not-prose">
22 <div class="max-w-2xl mx-auto">
23 {tiers.map(tier => {
24 const tierSponsors = sponsorsByTier[tier];
25
26 return (
27 <div class="first:mt-8 sm:first:mt-10 not-first:mt-12 sm:not-first:mt-16">
28 <h3 id={`${tier}-sponsors-heading`}
29 class:list={[
30 'inline-flex items-center gap-3 mb-6 sm:mb-8 font-chicago text-xs uppercase tracking-widest',
31 { 'text-blue-700 dark:text-blue-350': tier === 'platinum' },
32 { 'text-neutral-600 dark:text-neutral-400': tier === 'silver' }
33 ]}>
34 <span aria-hidden="true">{tier === 'platinum' ? '◆' : '★'}</span>
35 <span>
36 {tier} Sponsor{tierSponsors.length > 1 ? 's' : ''}
37 </span>
38 </h3>
39
40 <ul class:list={[
41 'grid gap-4 list-none p-0 m-0',
42 { 'grid-cols-1': tier === 'platinum' },
43 { 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3': tier === 'silver' }
44 ]}>
45 {tierSponsors.map((sponsor) => {
46 const logo = (sponsorLogos[sponsor.image] as any)?.default;
47 const isSvg = sponsor.image.endsWith('.svg');
48 const SvgComponent = isSvg ? logo : null;
49
50 if (!logo) return null;
51
52 return (
53 <li>
54 <a href={sponsor.url} target="_blank" rel="noopener noreferrer" aria-label={`Visit ${sponsor.name} website`}
55 class:list={[
56 'card lg',
57 'flex items-center justify-center w-full h-full group relative outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-neutral-500 dark:focus-visible:ring-neutral-400 interact:border-neutral-300 dark:interact:border-neutral-600',
58 { 'p-8': tier === 'platinum', 'p-6': tier !== 'platinum' },
59 { 'min-h-[180px]': tier === 'platinum' },
60 { 'min-h-[120px]': tier === 'silver' }
61 ]}>
62 {isSvg ? (
63 <SvgComponent
64 role="presentation"
65 aria-label={`${sponsor.name} Logo`}
66 class:list={[
67 'object-contain pointer-events-none',
68 { 'max-h-[80px] w-[360px]': tier === 'platinum' },
69 { 'max-h-[55px] w-[180px]': tier === 'silver' }
70 ]}
71 width="100%"
72 />
73 ) : (
74 <Image
75 src={logo}
76 alt={`${sponsor.name} Logo`}
77 class:list={[
78 'object-contain pointer-events-none',
79 { 'max-h-[80px] w-[360px]': tier === 'platinum' },
80 { 'max-h-[55px] w-[180px]': tier === 'silver' }
81 ]}
82 width={tier === 'platinum' ? 360 : 180}
83 height={tier === 'platinum' ? 80 : 55}
84 />
85 )}
86 </a>
87 </li>
88 )})}
89 </ul>
90 </div>
91 );
92 })}
93 </div>
94 <div class="flex justify-center w-full mt-12">
95 <a href="https://github.com/sponsors/bigskysoftware?o=esb"
96 target="_blank"
97 rel="noopener noreferrer"
98 class="inline-flex items-center justify-center gap-2 h-10 px-6 bg-linear-to-b font-chicago text-sm rounded-lg from-white to-neutral-75 dark:from-neutral-850 dark:to-neutral-900 text-neutral-600 dark:text-neutral-400 interact:text-black dark:interact:text-white border border-neutral-200 dark:border-neutral-800 interact:border-neutral-300 dark:interact:border-neutral-700 shadow-3d-neutral-500 dark:shadow-3d-neutral-950 active:translate-y-[0.375cqh] active:shadow-3d-depth-[2px] transition">
99 <i class="icon-[mdi--heart] text-red-500" aria-hidden="true"></i>
100 Sponsor htmx
101 </a>
102 </div>
103 </div>