Update ViewModeSelector with new view modes

- Add two-column view mode option
- Import new view mode icons
- Hide selector on mobile devices
- Update ViewMode type to include all options

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-06-19 01:55:18 +01:00
parent 049b6be57f
commit 26ef48fa95

View file

@ -1,32 +1,69 @@
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte' import { getContext } from 'svelte'
import PhotosIcon from '$icons/photos.svg?component' import PhotosIcon from '$icons/photos.svg?component'
import ViewSingleIcon from '$icons/view-single.svg?component'
import ViewTwoColumnIcon from '$icons/view-two-column.svg?component'
import ViewHorizontalIcon from '$icons/view-horizontal.svg?component'
import WidthNormalIcon from '$icons/width-normal.svg?component' import WidthNormalIcon from '$icons/width-normal.svg?component'
import WidthWideIcon from '$icons/width-wide.svg?component' import WidthWideIcon from '$icons/width-wide.svg?component'
export type ViewMode = 'masonry' | 'single' | 'two-column' | 'horizontal'
interface Props { interface Props {
mode?: 'masonry' mode?: ViewMode
width?: 'normal' | 'wide' width?: 'normal' | 'wide'
onModeChange?: (mode: ViewMode) => void
onWidthChange?: (width: 'normal' | 'wide') => void onWidthChange?: (width: 'normal' | 'wide') => void
} }
let { let {
mode = 'masonry', mode = 'masonry',
width = 'normal', width = 'normal',
onModeChange,
onWidthChange onWidthChange
}: Props = $props() }: Props = $props()
</script> </script>
<div class="view-mode-selector"> <div class="view-mode-selector">
<div class="mode-section"> <div class="mode-section">
<button class="mode-button selected" aria-label="Masonry view"> <button
class="mode-button"
class:selected={mode === 'masonry'}
aria-label="Masonry view"
onclick={() => onModeChange?.('masonry')}
>
<PhotosIcon /> <PhotosIcon />
</button> </button>
<button
class="mode-button"
class:selected={mode === 'single'}
aria-label="Single column view"
onclick={() => onModeChange?.('single')}
>
<ViewSingleIcon />
</button>
<button
class="mode-button"
class:selected={mode === 'two-column'}
aria-label="Two column view"
onclick={() => onModeChange?.('two-column')}
>
<ViewTwoColumnIcon />
</button>
<button
class="mode-button"
class:selected={mode === 'horizontal'}
aria-label="Horizontal scroll view"
onclick={() => onModeChange?.('horizontal')}
>
<ViewHorizontalIcon />
</button>
</div> </div>
<div class="separator"></div> {#if mode !== 'horizontal'}
<div class="separator"></div>
<div class="width-section">
<div class="width-section">
<button <button
class="mode-button" class="mode-button"
class:selected={width === 'normal'} class:selected={width === 'normal'}
@ -43,7 +80,8 @@
> >
<WidthWideIcon /> <WidthWideIcon />
</button> </button>
</div> </div>
{/if}
</div> </div>
<style lang="scss"> <style lang="scss">
@ -58,6 +96,10 @@
align-items: center; align-items: center;
gap: $unit-2x; gap: $unit-2x;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
@include breakpoint('phone') {
display: none;
}
} }
.mode-section, .mode-section,