| 1 |
--- |
| 2 |
title: "Patterns" |
| 3 |
description: "Patterns, recipes, and working examples." |
| 4 |
--- |
| 5 |
|
| 6 |
import { getFolder } from '../../lib/content'; |
| 7 |
|
| 8 |
export const folder = await getFolder('patterns'); |
| 9 |
export const groupedPatterns = folder.folders.map(sub => ({ |
| 10 |
slug: sub.slug, |
| 11 |
label: sub.frontmatter.title, |
| 12 |
items: sub.files.map(f => ({ |
| 13 |
title: f.frontmatter.title, |
| 14 |
url: f.url, |
| 15 |
description: f.frontmatter.description, |
| 16 |
icon: f.frontmatter.icon || '', |
| 17 |
soon: f.frontmatter.soon || false, |
| 18 |
})), |
| 19 |
})); |
| 20 |
|
| 21 |
<div class="not-prose mb-6"> |
| 22 |
<input |
| 23 |
type="text" |
| 24 |
placeholder="Search patterns..." |
| 25 |
autocomplete="off" |
| 26 |
class="w-full px-3 py-2 text-sm border border-neutral-200 dark:border-neutral-800 rounded-md bg-white dark:bg-neutral-900 text-neutral-800 dark:text-neutral-200 placeholder:text-neutral-400 dark:placeholder:text-neutral-500 focus:outline-none focus:ring-2 focus:ring-neutral-300/50 dark:focus:ring-neutral-600/50 focus:border-neutral-300 dark:focus:border-neutral-600" |
| 27 |
_="install ActiveSearch" |
| 28 |
/> |
| 29 |
</div> |
| 30 |
|
| 31 |
{groupedPatterns.map(group => ( |
| 32 |
<section role="group"> |
| 33 |
|
| 34 |
<h2 id={group.slug}>{group.label}</h2> |
| 35 |
|
| 36 |
<table> |
| 37 |
<tbody> |
| 38 |
{group.items.map(item => ( |
| 39 |
<tr class={`stretch-link ${item.soon ? 'opacity-50' : ''}`} data-filter={`${item.title} ${item.description || ''}`.toLowerCase()}> |
| 40 |
<td> |
| 41 |
{item.icon && <i class={`${item.icon} size-5 inline-block align-middle mr-4 sm:mr-7`}></i>} |
| 42 |
<span class="inline-block align-middle"> |
| 43 |
{item.soon |
| 44 |
? <span>{item.title}</span> |
| 45 |
: <a href={item.url}>{item.title}</a>} |
| 46 |
{item.soon && <span class="sm:hidden text-[9px] ml-2 px-1.5 py-0.5 rounded bg-yellow-300/5 text-yellow-700 dark:text-yellow-300 border border-yellow-600/50 dark:border-yellow-300 font-medium uppercase tracking-wide">Soon</span>} |
| 47 |
{item.description && <span class="block sm:hidden text-[0.8125em] text-neutral-650 dark:text-neutral-350 mt-0.5">{item.description}</span>} |
| 48 |
</span> |
| 49 |
</td> |
| 50 |
<td class="hidden sm:table-cell text-neutral-650 dark:text-neutral-350"> |
| 51 |
{item.description || ''} |
| 52 |
{item.soon && <span class="text-[9px] ml-2 px-1.5 py-0.5 rounded bg-yellow-300/5 text-yellow-700 dark:text-yellow-300 border border-yellow-600/50 dark:border-yellow-300 font-medium uppercase tracking-wide">Soon</span>} |
| 53 |
</td> |
| 54 |
</tr> |
| 55 |
))} |
| 56 |
</tbody> |
| 57 |
</table> |
| 58 |
|
| 59 |
</section> |
| 60 |
))} |