# Contributing Contributions welcome, especially new lexicon components for ATProto record types not yet supported. ## Setup ```sh pnpm install pnpm dev ``` Requires Node 18+ and pnpm. ## Adding a lexicon component The lexicon registry at `src/lib/lexicons/` maps ATProto NSIDs to Svelte components. Each component receives `record` and `uri` props and renders a record in the timeline. **Steps:** 1. Create `src/lib/lexicons//MyComponent.svelte` ```svelte

Display Name

``` If generated types are available for the lexicon (via `@atproto/lex`), use them instead of a generic interface. See `BlueskyPost.svelte` for a full example with embeds, or `FeedLike.svelte` for a minimal one. 2. Register in `src/lib/lexicons//index.ts`: ```ts import type { RegistryEntry } from '../types'; import MyComponent from './MyComponent.svelte'; export const entries: Record = { 'com.example.foo': { component: MyComponent, displayName: 'Human Name', recordUrl: (record, atUri) => `https://example.com/...` // optional — links the record to its source } }; ``` Null entries suppress the fallback JSON renderer for noisy types you don't want displayed: ```ts 'com.example.noisy': null ``` 3. If it's a new namespace, import the entries in `src/lib/lexicons/index.ts`: ```ts import { entries as comExample } from './com.example/index'; // ... const registry = { ...appBsky, ...comExample, ... }; ``` ## Component standards ### Typing the record prop **Prefer generated types** from `$lib/generated-lexicons/` when available: ```ts import type { Main } from '$lib/generated-lexicons/app/bsky/feed/post.defs.js'; record: Main; ``` When no generated type exists, use an inline interface. Mark fields that may be absent as optional, and include `[key: string]: unknown` as a catch-all: ```ts record: { $type: string; title?: string; description?: string; createdAt?: string; [key: string]: unknown; }; ``` Always include `$type: string` — it's needed by `getRecordUrl` and `getDisplayName`. ### Wrapper element Every component renders an `
` as its root: ```svelte
...
``` - `record-card` is the base class (used by `Stream.svelte` for layout) - `gap-1` for standard card density; `gap-2` acceptable for richer components (posts with images, profiles with avatars) - Do **not** add borders or vertical padding — `Stream.svelte` handles card spacing ### Type label Each card starts with a type label: ```svelte

Human-Readable Type

``` This should match the `displayName` in the registry entry. ### Text sizing | Element | Class | | ------------------------------------ | ---------------------------------------- | | Type label | `text-xs font-semibold opacity-60` | | Primary content (title, text body) | default size, optionally `font-semibold` | | Secondary content (description) | `text-sm` | | Metadata (dates, URLs, small labels) | `text-xs` | ### Opacity for visual hierarchy | Purpose | Value | | -------------------------------- | ---------------------------- | | Type label | `opacity-60` | | Secondary text (descriptions) | `opacity-70` | | Metadata (dates, tertiary links) | `opacity-40` to `opacity-50` | ### Links All external links: ```svelte ... ``` - Use `rel="noopener"` consistently (not `noopener noreferrer`) - Use `class="text-inherit"` when the link should blend with surrounding text - Suffix with `↗` for links that navigate to external apps (e.g., `bsky.app ↗`, `profile ↗`) ### Optional fields Use `{#if}` blocks for conditional rendering: ```svelte {#if record.description}

{record.description}

{/if} ``` For arrays, filter empty values before checking length: ```ts const topics = $derived((record.topics ?? []).filter((t) => t.trim() !== '')); ``` ```svelte {#if topics.length > 0}
{#each topics as topic (topic)} {topic} {/each}
{/if} ``` ### Dates Format with `toLocaleString()` and wrap in `