Commit Graph

72 Commits

Author SHA1 Message Date
Claudio Ortolina 30c0af475d Update tailwind from 4.1.13 to 4.1.14 2025-10-01 21:08:13 +03:00
Claudio Ortolina 42a9a450c8 Update npm dependencies
barcode-detector 3.0.5 => 3.0.6
2025-09-30 11:44:18 +03:00
Claudio Ortolina 6a5fc53492 Improve shine effect 2025-09-24 21:10:02 +03:00
Claudio Ortolina dd1b115e02 Update npm dependencies 2025-09-24 20:54:17 +03:00
Claudio Ortolina d680a50f29 Move BarcodeScanner to colocated hook 2025-09-22 14:30:15 +03:00
Claudio Ortolina f31a98eea7 Update npm lockfile format
Presumably due to Node upgrade - it now includes license info.
2025-09-21 09:05:13 +03:00
Claudio Ortolina 6853299865 Show application version in console banner 2025-09-20 10:44:18 +03:00
Claudio Ortolina 2e8399c44b Update npm dependencies 2025-09-19 23:51:02 +03:00
Claudio Ortolina fa1a8bee54 Extract FormatNumber Hook 2025-09-17 09:02:09 +03:00
Claudio Ortolina 6112ec7f0a Move barcode-scanner.js under hooks/ 2025-09-17 08:58:18 +03:00
Claudio Ortolina b4e3aefde7 Add console banner 2025-09-16 15:30:42 +03:00
Claudio Ortolina 80a9ab9d0a Update npm dependencies 2025-09-15 07:13:05 +03:00
Claudio Ortolina 21783f5dbf Resolve timezone from user browser 2025-09-11 22:14:15 +03:00
Claudio Ortolina b80e618d60 Use tailwind typography for notes 2025-09-07 15:59:24 +03:00
Claudio Ortolina ee47c9da7f Update JS dependencies 2025-09-04 08:12:29 +03:00
Claudio Ortolina b1151df0f6 Shine effect for significant anniversaries 2025-08-29 13:55:48 +03:00
Claudio Ortolina 71ca5fa1b9 Update to Fluxon 2.0
Address required changes and immediate deprecations
2025-08-20 16:09:53 +03:00
Claudio Ortolina feab0939b4 Update vendored topbar 2025-07-17 17:42:00 +01:00
Claudio Ortolina 6c90a3467d Include TS configuration 2025-07-17 17:40:28 +01:00
Claudio Ortolina 70b59d1eec Update app.js to match Phoenix 1.8 generated version 2025-07-17 17:39:19 +01:00
Claudio Ortolina 5e73231767 Move SearchGlobalShortcut to a colocated hook 2025-07-17 17:32:24 +01:00
Claudio Ortolina ad74560cf9 Enable Ctrl/Meta+K to trigger universal search 2025-07-07 11:36:41 +01:00
Claudio Ortolina b86e8abd52 Remove universal search hooks
- Global shortcuts don't work
- Focus input on open can be achieved just with 'autofocus' attribute
- Maintaining focus when input is active can be achieved just by adding
  an ID to the input
2025-07-06 09:14:57 +01:00
Claudio Ortolina c4d4c91477 First draft: universal search (Claude)
# Universal Search Modal Implementation Plan

## Overview

This plan outlines the implementation of a universal search modal that
provides unified search across Records (Collection), Records (Wishlist),
and Artists. The modal will be accessible via a search icon in the top
navigation bar and a keyboard shortcut.

## Requirements

### Core Features
- Modal accessible via:
  - Search icon in top navigation bar
  - Keyboard shortcut (Ctrl/Cmd + K)
- Search across three entity types:
  1. Records in Collection
  2. Records in Wishlist
  3. Artists
- Real-time search as user types
- Keyboard navigation support
- Mobile-responsive design

### Search Functionality
- Leverage existing FTS5 search infrastructure
- Support existing search syntax (artist:, album:, genre:, etc.)
- Show search results grouped by entity type
- Limit results per category (e.g., 5 per type)
- Click-to-navigate to full results or individual records

## Technical Architecture

### 1. Modal Component Structure

**New Components:**
- `UniversalSearchModal` - Main modal component
- `SearchResultGroup` - Groups results by type (Collection, Wishlist,
Artists)
- `SearchResultItem` - Individual result display
- `SearchInput` - Enhanced search input with keyboard shortcuts

**Component Location:**
```
lib/music_library_web/components/
├── search_components.ex          # New universal search components
└── layouts/app.html.heex         # Add search icon to navigation
```

### 2. LiveView Integration

**New LiveView Module:**
```
lib/music_library_web/live/universal_search_live/
├── index.ex                      # Main search LiveView
└── index.html.heex              # Search modal template
```

**Integration Points:**
- Mount as child LiveView in main layout
- Handle modal open/close state
- Manage search query and results
- Handle keyboard navigation

### 3. Backend Search Implementation

**New Context Functions:**
```elixir
# In lib/music_library/search.ex (new module)
def universal_search(query, opts \\ [])
def search_collection(query, limit \\ 5)
def search_wishlist(query, limit \\ 5)
def search_artists(query, limit \\ 5)
```

**Search Strategy:**
- Reuse existing `Records.search_collection/2` and
`Records.search_wishlist/2`
- Extend `Artists.search/2` or create new artist search function
- Combine results with type metadata
- Implement result limiting and pagination

### 4. Database Considerations

**Leverage Existing Infrastructure:**
- Use existing `records_search_index` FTS5 table
- Utilize existing search parser for tagged queries
- Consider artist search optimization (may need artist search index)

**Artist Search Enhancement:**
- Current artist search may need optimization
- Consider adding FTS5 index for artist_infos table if performance
issues
- Leverage existing artist_records view for artist-record relationships

## Implementation Details

### 1. Modal Behavior

**Desktop:**
- Modal opens centered on screen
- Size: `max-w-2xl` (responsive)
- Overlay with backdrop blur
- Esc key to close, click outside to close

**Mobile:**
- Full-screen modal on mobile (`sm:max-w-2xl max-w-full`)
- Touch-friendly result items
- Swipe down to close (if feasible)
- Virtual keyboard considerations

### 2. Search Interface

**Search Input:**
- Placeholder: "Search records and artists..."
- Auto-focus when modal opens
- Debounced search (300ms delay)
- Clear button when text present
- Loading indicator during search

**Search Results:**
```
┌─────────────────────────────────────┐
│ Search: "radiohead ok computer"     │
├─────────────────────────────────────┤
│ COLLECTION (3 results)              │
│ • OK Computer - Radiohead           │
│ • Kid A - Radiohead                 │
│ • In Rainbows - Radiohead           │
│ View all 12 collection results →    │
├─────────────────────────────────────┤
│ WISHLIST (1 result)                 │
│ • Hail to the Thief - Radiohead     │
│ View all 1 wishlist results →       │
├─────────────────────────────────────┤
│ ARTISTS (1 result)                  │
│ • Radiohead                         │
│ View artist page →                  │
└─────────────────────────────────────┘
```

### 3. Keyboard Navigation

**Keyboard Shortcuts:**
- `Ctrl/Cmd + K` - Open modal
- `Esc` - Close modal
- `↑/↓` - Navigate results
- `Enter` - Select highlighted result
- `Tab` - Move between sections

**Implementation:**
- Use Phoenix LiveView's `phx-window-keydown` for global shortcuts
- Implement focus management with JavaScript hooks
- Maintain accessibility standards (ARIA labels, focus indicators)

### 4. Result Navigation

**Click Actions:**
- Record results → Navigate to record show page
- Artist results → Navigate to artist page
- "View all X results" → Navigate to respective list page with search
applied

**URL Strategy:**
- Don't change URL for modal open/close
- When navigating to results, apply search query to destination page
- Use existing search parameter patterns

## Database Schema Impact

**No Schema Changes Required:**
- Leverage existing tables and search infrastructure
- May add database indexes for performance if needed

**Performance Considerations:**
- Monitor query performance with combined searches
- Consider query result caching for common searches
- Implement search result limits to prevent slow queries

## Testing Strategy

### 1. Unit Tests

**Search Logic Tests:**
```elixir
# test/music_library/search_test.exs
describe "universal_search/2" do
  test "searches across all entity types"
  test "limits results per category"
  test "handles empty queries"
  test "handles special characters"
  test "respects search syntax (artist:, album:, etc.)"
end
```

### 2. Integration Tests

**LiveView Tests:**
```elixir
# test/music_library_web/live/universal_search_live_test.exs
describe "UniversalSearchLive" do
  test "opens modal on keyboard shortcut"
  test "searches as user types"
  test "displays results grouped by type"
  test "navigates to selected results"
  test "handles keyboard navigation"
  test "closes modal on escape"
end
```

### 3. Component Tests

**Search Components:**
```elixir
# test/music_library_web/components/search_components_test.exs
describe "SearchResultGroup" do
  test "renders results with proper grouping"
  test "shows 'view all' link when more results available"
  test "handles empty result sets"
end
```

### 4. JavaScript/Hook Tests

**Browser Tests:**
- Test keyboard shortcuts work globally
- Test focus management
- Test modal open/close behavior
- Test mobile touch interactions

## Mobile Considerations

### 1. Layout Adaptations

**Mobile Modal:**
- Full-screen on small devices
- Reduced padding and margins
- Larger touch targets for results
- Simplified result display (fewer details)

**Touch Interactions:**
- Swipe down to close modal
- Tap to select results
- Pull-to-refresh for search results

### 2. Performance

**Mobile Optimization:**
- Shorter debounce delays on mobile
- Reduced result limits on mobile
- Lazy loading for large result sets
- Optimize image loading for album covers

### 3. Virtual Keyboard

**iOS/Android Considerations:**
- Modal positioning with virtual keyboard
- Proper input focus management
- Prevent zoom on input focus

## Implementation Phases

### Phase 1: Core Modal Infrastructure
1. Create basic modal component
2. Add search icon to navigation
3. Implement modal open/close
4. Add keyboard shortcut support

### Phase 2: Search Backend
1. Create universal search context
2. Implement combined search functions
3. Add result limiting and grouping
4. Optimize query performance

### Phase 3: Search Interface
1. Implement search input with debouncing
2. Add search result display
3. Implement keyboard navigation
4. Add result selection and navigation

### Phase 4: Mobile & Polish
1. Mobile layout optimizations
2. Touch interaction improvements
3. Performance optimizations
4. Accessibility enhancements

### Phase 5: Testing & Documentation
1. Comprehensive test coverage
2. Performance testing
3. Mobile device testing
4. Documentation updates

## Success Metrics

**Functionality:**
- Modal opens/closes reliably
- Search results are accurate and fast
- Keyboard navigation works smoothly
- Mobile experience is touch-friendly

**Performance:**
- Search queries complete in <500ms
- Modal opens in <100ms
- No janky animations or interactions
- Efficient database queries

**Usability:**
- Easy to discover and use
- Intuitive keyboard shortcuts
- Clear result presentation
- Seamless navigation to results

## Risks and Mitigation

**Performance Risks:**
- Complex queries may be slow
- **Mitigation:** Implement query limits, caching, and monitoring

**Mobile Experience:**
- Small screen constraints
- **Mitigation:** Responsive design, touch-friendly interfaces

**Accessibility:**
- Keyboard navigation complexity
- **Mitigation:** Follow ARIA guidelines, comprehensive testing

**Search Accuracy:**
- Users may expect Google-like search
- **Mitigation:** Clear documentation of search syntax, good defaults

## Future Enhancements

**Advanced Features:**
- Search history and suggestions
- Saved searches
- Search filters and facets
- Search result previews

**Integration:**
- Integration with barcode scanning
- Voice search capabilities
- External search (MusicBrainz, Last.fm)

**Analytics:**
- Search usage analytics
- Popular search terms
- Search success rates

## Conclusion

This universal search modal will significantly improve the user
experience by providing quick access to all content types from any page.
The implementation leverages existing infrastructure while adding a
modern, accessible search interface that works well on both desktop and
mobile devices.

The phased approach ensures a solid foundation while allowing for
iterative improvements based on user feedback and usage patterns.
2025-07-05 16:47:06 +01:00
Claudio Ortolina f0d8e84221 Update npm dependencies 2025-06-25 20:45:13 +03:00
Claudio Ortolina d14587c120 Revert "Show confetti when adding a record"
Shows up too often
2025-06-11 08:42:41 +03:00
Claudio Ortolina a31d92bc9f Show confetti when adding a record 2025-06-09 18:40:03 +01:00
Claudio Ortolina 8ac4a99df2 Track live_toast in assets lockfile 2025-06-09 14:18:57 +01:00
Claudio Ortolina 0aa0a19a00 Use live_toast instead of built-in flash
Precursor for building better notifications
2025-06-07 08:27:25 +01:00
Claudio Ortolina 40eb23dc9b Trim whitespace when copying to clipboard 2025-05-21 22:02:49 +01:00
Claudio Ortolina 5bab710b8a Update npm dependencies 2025-05-07 11:53:32 +01:00
Claudio Ortolina 23e59edeec Update npm dependencies 2025-05-02 18:39:58 +01:00
Claudio Ortolina 584c5cf3e0 Use Fluxon components for record edit form 2025-05-01 20:30:44 +01:00
Claudio Ortolina 99bba31ff0 Update npm dependencies 2025-05-01 16:43:42 +01:00
Claudio Ortolina e69d011a89 Update npm dependencies 2025-04-28 19:58:40 +01:00
Claudio Ortolina a0ad47acf9 Update npm dependencies 2025-04-21 16:19:22 +01:00
Claudio Ortolina 4eac9f715a Mount Fluxon UI inside css and js entrypoints 2025-04-16 10:42:37 +01:00
Claudio Ortolina f0f43c22f6 Use Phoenix 1.8.0rc heroicons plugin 2025-04-05 12:21:32 +01:00
Claudio Ortolina 0b553ff747 Fix sources for tailwind.css
Avoids continuously recompiling on unrelated file changes
2025-04-05 12:20:13 +01:00
Claudio Ortolina b7d69e3f63 Update npm dependencies 2025-04-03 18:19:00 +01:00
Claudio Ortolina 1df3f85a37 Update npm dependencies 2025-04-01 19:09:48 +01:00
Claudio Ortolina 73fb6098ba Update npm dependencies 2025-03-25 18:07:38 +00:00
Claudio Ortolina 67c02423d2 Fix phx-* css variants
See https://tailwindcss.com/docs/hover-focus-and-other-states#registering-a-custom-variant
2025-03-11 20:28:39 +00:00
Claudio Ortolina 4a18129d31 Show confetti when purchasing a record 2025-03-08 21:53:17 +00:00
Claudio Ortolina 6fbf71dfe6 Add opt-in client-side observer for LiveView updates 2025-03-07 06:51:58 +00:00
Claudio Ortolina 13add71066 Format js files 2025-03-06 15:49:54 +00:00
Claudio Ortolina 4e609465c3 Update npm dependencies 2025-03-06 15:33:31 +00:00
Claudio Ortolina 83658734db Removed unused brand color setting 2025-03-02 07:54:02 +00:00
Claudio Ortolina 55d0e656f7 Show pointer on buttons
Used to be default for Tailwind v3, gone in v4 as per
https://tailwindcss.com/docs/upgrade-guide#buttons-use-the-default-cursor
2025-03-02 07:22:09 +00:00
Claudio Ortolina d9e87d6c80 Migrate to Tailwind v4 2025-02-28 20:46:53 +00:00