memos/web
Claude 4e37fcfa22
refactor(web): unify Location/Attachments/Relations components for consistency
This refactor introduces a maintainable, unified component architecture for
memo metadata (Location, Attachments, Relations) that ensures visual and
functional consistency between editor and view modes.

## Key Changes

### New Shared Component Library (web/src/components/memo-metadata/)
- **MetadataBadge**: Reusable badge component for compact metadata display
- **MetadataCard**: Reusable card component for structured metadata
- **LocationDisplay**: Unified location component with mode support
- **AttachmentList**: Unified attachment list with thumbnail support
- **RelationList**: Unified relation list with bidirectional tabs
- **AttachmentCard**: Shared attachment rendering logic
- **RelationCard**: Shared relation item rendering logic

### Benefits
1. **Single Source of Truth**: One component handles both edit/view modes
2. **Visual Consistency**: Same badge/card styles across all contexts
3. **Better Maintainability**: Shared logic reduces duplication (9 files vs 6)
4. **Enhanced Features**:
   - Thumbnails for images in editor mode
   - Consistent badge sizing (h-7) across all metadata types
   - Unified spacing and interaction patterns

### Component Updates
- **MemoEditor**: Now uses LocationDisplay, AttachmentList, RelationList
- **MemoView**: Now uses the same unified components with mode="view"
- Removed old separate implementations:
  - MemoEditor/{LocationView, AttachmentListView, RelationListView}
  - {MemoLocationView, MemoAttachmentListView, MemoRelationListView}

### Technical Details
- All components use `DisplayMode` type ("edit" | "view") for behavior
- Editor mode: Shows badges with remove buttons, drag-sort for attachments
- View mode: Shows rich previews, popovers, galleries, navigation links
- TypeScript strict mode compatible, passes all lint checks
- Production build tested and verified

This architecture follows modern React patterns and makes it easy to add
new metadata types or modify existing ones without duplicating code.
2025-11-08 23:11:34 +00:00
..
public chore: enhance site.webmanifest in firefox (#4828) 2025-07-08 19:56:46 +08:00
src refactor(web): unify Location/Attachments/Relations components for consistency 2025-11-08 23:11:34 +00:00
.gitignore chore: update gitignore 2025-04-17 23:11:36 +08:00
.prettierrc.js chore: fix linter 2025-03-02 15:40:16 +08:00
MARKDOWN_STYLE_GUIDE.md chore: remove unused syntax 2025-10-27 08:31:57 +08:00
README.md chore: tweak readme 2024-02-23 08:25:54 +08:00
components.json feat: themes (#4824) 2025-07-07 20:13:22 +08:00
eslint.config.mjs refactor: migrate eslint 2025-04-01 00:04:43 +08:00
index.html chore: remove fixed theme color 2025-07-15 23:26:07 +08:00
package.json chore: remove unused syntax 2025-10-27 08:31:57 +08:00
pnpm-lock.yaml chore: remove unused syntax 2025-10-27 08:31:57 +08:00
tsconfig.json refactor: update import prefix with alias (#1433) 2023-04-01 16:03:14 +08:00
vite.config.mts refactor: update markdown parser 2025-10-26 11:28:40 +08:00

README.md

The frontend of Memos