From 9e9fc326b84dc16f3f1198ce9051d62a8c9f85cd Mon Sep 17 00:00:00 2001 From: James Xylight Date: Wed, 20 Aug 2025 20:48:50 -0700 Subject: [PATCH] design: use commonlist in sidebars --- CLAUDE.md | 113 ++++++++++++++++++ .../lemmy/post/actions/PostActions.svelte | 4 +- .../lemmy/post/actions/PostActionsMenu.svelte | 17 --- src/lib/components/ui/Expandable.svelte | 10 +- .../components/ui/layout/CommonList.svelte | 56 +++++++-- src/lib/components/ui/navbar/NavButton.svelte | 2 +- src/lib/components/ui/sidebar/Sidebar.svelte | 77 +++++++----- .../ui/sidebar/SidebarButton.svelte | 2 +- src/lib/mono/button/Button.svelte | 4 +- 9 files changed, 216 insertions(+), 69 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..638a5e96 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,113 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +Photon is a Svelte-based Lemmy client built with SvelteKit 2 and Svelte 5. It's a modern frontend for Lemmy instances with extensive customization options and multi-platform support. + +### Key Technologies +- **Frontend**: SvelteKit 2 + Svelte 5 with TypeScript +- **Styling**: TailwindCSS v4 + PostCSS +- **Desktop App**: Tauri (optional, in src-tauri/) +- **Package Manager**: Bun (primary) or npm +- **Build Adapters**: Supports Bun, Node, and static builds + +## Development Commands + +### Development +```bash +# Start development server +bun run dev +# or +npm run dev +``` + +### Building +```bash +# Build for Bun runtime (fastest) +ADAPTER=bun bun run build + +# Build for Node runtime (better compatibility) +ADAPTER=node npm run build + +# Build static files +ADAPTER=static npm run build +``` + +### Code Quality +```bash +# Type checking +bun run check +# or watch mode +bun run check:watch + +# Linting +bun run lint + +# Formatting +bun run format +# or specific files +bun run format:specific +``` + +### Running Built Application +```bash +# Start Bun server +bun run bunstart + +# Start Node server +bun run start +``` + +### Testing +The project uses Vitest as configured in package.json, but no test files currently exist: +```bash +bun run test +``` + +## Architecture + +### Core Structure +- **Routes**: SvelteKit file-based routing in `src/routes/` +- **Components**: Organized by domain in `src/lib/components/` + - `lemmy/`: Lemmy-specific components (posts, comments, communities) + - `ui/`: Generic UI components + - `mono/`: Design system components (imported as 'mono-svelte') +- **State Management**: Svelte 5 runes with custom stores for global state +- **Internationalization**: Custom i18n system in `src/lib/i18n/` + +### Key Global State +- **Authentication**: `src/lib/auth.svelte.ts` - Profile and user management +- **Settings**: `src/lib/settings.svelte.ts` - User preferences and configuration +- **Lemmy Client**: `src/lib/lemmy.svelte.ts` - API client and site data +- **Instance**: `src/lib/instance.svelte.ts` - Instance URL management + +### Component Organization +- **Lemmy Domain**: Components for posts, comments, communities, moderation +- **UI Components**: Reusable interface elements with design system +- **Layout**: Shell, navbar, sidebar structure +- **Form Components**: Input controls with consistent styling + +### Environment Configuration +Photon uses PUBLIC_ prefixed environment variables for client-side configuration. Default values are defined in `src/lib/settings.svelte.ts`. Key configuration includes: +- `PUBLIC_INSTANCE_URL`: Default Lemmy instance +- `PUBLIC_SSR_ENABLED`: Server-side rendering toggle +- `PUBLIC_LOCK_TO_INSTANCE`: Whether to allow instance switching + +### Multi-Platform Support +- **Web**: Primary SvelteKit application +- **Desktop**: Optional Tauri wrapper in `src-tauri/` for native desktop app +- **Mobile**: PWA capabilities with responsive design + +### Build System +- **Vite**: Primary build tool with SvelteKit integration +- **Adapters**: Dynamic adapter selection via ADAPTER environment variable +- **Aliases**: 'mono-svelte' points to internal design system at `src/lib/mono` + +### State Patterns +The codebase uses Svelte 5 runes extensively: +- `$state()` for reactive state +- `$derived()` for computed values +- `$effect()` for side effects +- Custom classes with reactive properties for complex state management \ No newline at end of file diff --git a/src/lib/components/lemmy/post/actions/PostActions.svelte b/src/lib/components/lemmy/post/actions/PostActions.svelte index 1401de67..2ce4191c 100644 --- a/src/lib/components/lemmy/post/actions/PostActions.svelte +++ b/src/lib/components/lemmy/post/actions/PostActions.svelte @@ -44,8 +44,8 @@ onedit, onhide, }: Props = $props() - let buttonHeight = $derived(view == 'compact' ? 'h-7' : 'h-8') - let buttonSquare = $derived(view == 'compact' ? 'w-7 h-7' : 'w-8 h-8') + let buttonHeight = $derived(view == 'compact' ? 'h-7.5' : 'h-8') + let buttonSquare = $derived(view == 'compact' ? 'w-7.5 h-7.5' : 'w-8 h-8') {#if editing} diff --git a/src/lib/components/lemmy/post/actions/PostActionsMenu.svelte b/src/lib/components/lemmy/post/actions/PostActionsMenu.svelte index c49a07ea..c80e9886 100644 --- a/src/lib/components/lemmy/post/actions/PostActionsMenu.svelte +++ b/src/lib/components/lemmy/post/actions/PostActionsMenu.svelte @@ -39,23 +39,6 @@ let { post, onhide, editing = $bindable() }: Props = $props() -{$t('post.actions.more.creator')} - - {#snippet prefix()} - - {/snippet} - - {post.creator.name} - - - - {#snippet prefix()} - - {/snippet} - - {post.community.title} - - {$t('post.actions.more.actions')} diff --git a/src/lib/components/ui/Expandable.svelte b/src/lib/components/ui/Expandable.svelte index ce0323ca..26fac279 100644 --- a/src/lib/components/ui/Expandable.svelte +++ b/src/lib/components/ui/Expandable.svelte @@ -34,15 +34,15 @@ {@render title?.(open)} {#if icon} - + > + + {/if}
import type { Snippet } from 'svelte' + import type { ClassValue } from 'svelte/elements' - const sizeDelay: Record<'lg' | 'md' | 'sm', number> = { + const sizeDelay: Record<'lg' | 'md' | 'sm' | 'xs', number> = { lg: 120, md: 80, sm: 40, + xs: 0, } interface Props { @@ -12,7 +14,9 @@ item?: Snippet<[T, number]> children?: Snippet animate?: boolean - size?: 'lg' | 'md' | 'sm' + size?: 'lg' | 'md' | 'sm' | 'xs' + class?: ClassValue + selected?: (item: T) => boolean } let { @@ -21,6 +25,8 @@ children, animate = true, size = 'sm', + class: clazz, + selected, }: Props = $props() @@ -28,7 +34,13 @@ {#if items} {#each items as item, index (item)}
  • {@render itemSnippet?.(item, index)} @@ -40,8 +52,6 @@