File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ class DbStore {
6161 globalLanguageId = $state < string > (
6262 ( browser && localStorage . getItem ( 'copypasta_local_lang' ) ) || 'en'
6363 ) ;
64+ fluidWidth = $state < boolean > (
65+ ( browser && localStorage . getItem ( 'copypasta_local_fluid_width' ) === 'true' )
66+ ) ;
67+ columnCount = $state < string > (
68+ ( browser && localStorage . getItem ( 'copypasta_local_column_count' ) ) || '2'
69+ ) ;
6470 editingSnippetIds = $state < string [ ] > ( [ ] ) ;
6571 conflictData = $state < Database | null > ( null ) ;
6672 isLoading = $state ( false ) ;
@@ -76,6 +82,20 @@ class DbStore {
7682 }
7783 }
7884
85+ setFluidWidth ( fluid : boolean ) {
86+ this . fluidWidth = fluid ;
87+ if ( browser ) {
88+ localStorage . setItem ( 'copypasta_local_fluid_width' , fluid . toString ( ) ) ;
89+ }
90+ }
91+
92+ setColumnCount ( count : string ) {
93+ this . columnCount = count ;
94+ if ( browser ) {
95+ localStorage . setItem ( 'copypasta_local_column_count' , count ) ;
96+ }
97+ }
98+
7999 getLastSyncedAt ( ) : number {
80100 if ( ! browser ) return 0 ;
81101 return parseInt ( localStorage . getItem ( 'copypasta_last_synced' ) || '0' , 10 ) ;
Original file line number Diff line number Diff line change 2222<div class =" flex min-h-screen flex-col bg-base-200 pb-16 sm:pb-0" >
2323 <Navbar />
2424
25- <main class =" mx-auto w-full max-w-7xl flex-1 p-4" >
25+ <main class ={ ` mx-auto w-full flex-1 p-4 ${ dbStore . fluidWidth ? ' ' : ' max-w-7xl ' } ` } >
2626 {@render children ()}
2727 </main >
2828
Original file line number Diff line number Diff line change 266266 <!-- Snippets Grid -->
267267 <div class =" flex-1" >
268268 <div class =" mb-4 flex flex-col items-start justify-between gap-4 sm:flex-row sm:items-center" >
269- <h1 class =" text-2xl font-bold" >
270- {selectedCategoryId
271- ? dbStore .data .categories .find ((c ) => c .id === selectedCategoryId )?.name
272- : ' All Snippets' }
269+ <h1 class =" text-2xl font-bold flex items-center" >
270+ {#if selectedCategoryId }
271+ {@const category = dbStore .data .categories .find ((c ) => c .id === selectedCategoryId )}
272+ {#if category ?.icon }
273+ <span class ="mr-2" >{category .icon }</span >
274+ {/if }
275+ {category ?.name }
276+ {:else }
277+ All Snippets
278+ {/if }
273279 </h1 >
274280 <div class =" flex w-full items-center gap-2 sm:w-auto" >
275281 <select
344350 {/if }
345351
346352 <div
347- class ={` grid grid-cols-1 gap-4 lg:grid-cols-2 ${isReorderMode ? ' cursor-grab active:cursor-grabbing' : ' ' } ` }
353+ class ={` grid gap-4 ${isReorderMode ? ' cursor-grab active:cursor-grabbing' : ' ' } ${dbStore .columnCount === ' 1' ? ' grid-cols-1' : dbStore .columnCount === ' 3' ? ' grid-cols-1 md:grid-cols-2 lg:grid-cols-3' : dbStore .columnCount === ' 4' ? ' grid-cols-1 md:grid-cols-2 lg:grid-cols-4' : dbStore .columnCount === ' auto' ? ' ' : ' grid-cols-1 lg:grid-cols-2' } ` }
354+ style ={dbStore .columnCount === ' auto' ? ' grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));' : ' ' }
348355 use:sortableGroup ={group .categoryId }
349356 >
350357 {#each group .snippets as snippet (snippet .id )}
Original file line number Diff line number Diff line change 9797 <div class =" card border border-base-200 bg-base-100 shadow-sm" >
9898 <div class =" card-body flex-row items-center gap-4 overflow-visible p-4" >
9999 <div class =" dropdown dropdown-bottom" >
100- <div tabindex =" 0" role =" button" class =" btn w-16 btn-outline text-xl" >
100+ <div tabindex =" 0" role =" button" class =" btn w-16 btn-soft text-xl" >
101101 {newCategoryEmoji || ' 😀' }
102102 </div >
103103 <div
165165
166166 <div class =" flex flex-1 gap-2 overflow-visible font-medium" >
167167 <div class =" dropdown dropdown-bottom" >
168- <div tabindex =" 0" role =" button" class =" btn w-12 btn-outline text-lg btn-sm" >
168+ <div tabindex =" 0" role =" button" class =" btn w-12 btn-soft text-lg btn-sm" >
169169 {category .icon || ' 😀' }
170170 </div >
171171 <div
Original file line number Diff line number Diff line change 1313 Download ,
1414 Upload ,
1515 DatabaseBackup ,
16- Languages
16+ Languages ,
17+ LayoutGrid
1718 } from ' @lucide/svelte' ;
1819
1920 let pat = $state (authStore .token );
384385 </div >
385386 </section >
386387
388+ <!-- UI Layout Settings -->
389+ <section class =" card border border-base-200 bg-base-100 shadow-sm" >
390+ <div class =" card-body" >
391+ <h2 class =" card-title" >
392+ <LayoutGrid class =" h-5 w-5" />
393+ Layout Preferences
394+ </h2 >
395+ <p class =" mb-4 text-sm text-base-content/70" >
396+ Customize how snippets are displayed on the main page. (Stored locally on this device)
397+ </p >
398+
399+ <div class =" flex items-center justify-between max-w-xs" >
400+ <span class =" font-medium text-sm" >Fluid Width (Full Screen)</span >
401+ <input
402+ type =" checkbox"
403+ class =" toggle toggle-primary"
404+ checked ={dbStore .fluidWidth }
405+ onchange ={(e ) => dbStore .setFluidWidth (e .currentTarget .checked )}
406+ />
407+ </div >
408+
409+ <fieldset class =" fieldset w-full max-w-xs mt-4" >
410+ <legend class =" fieldset-legend font-medium" >Grid Columns</legend >
411+ <select
412+ class =" select select-bordered w-full"
413+ value ={dbStore .columnCount }
414+ onchange ={(e ) => dbStore .setColumnCount (e .currentTarget .value )}
415+ >
416+ <option value =" 1" >1 Column</option >
417+ <option value =" 2" >2 Columns</option >
418+ <option value =" 3" >3 Columns</option >
419+ <option value =" 4" >4 Columns</option >
420+ <option value =" auto" >Auto-fit (Responsive)</option >
421+ </select >
422+ </fieldset >
423+ </div >
424+ </section >
425+
387426 <!-- Languages Settings -->
388427 <section class =" card border border-base-200 bg-base-100 shadow-sm" >
389428 <div class =" card-body" >
You can’t perform that action at this time.
0 commit comments