11import { useEffect , useRef , useState } from 'react'
2- import { Check , Image as ImageIcon , Sparkles , Upload } from 'lucide-react'
2+ import { Check , Image as ImageIcon , Monitor , Sparkles , Upload } from 'lucide-react'
33import {
44 BackgroundId ,
55 backgrounds ,
@@ -10,7 +10,7 @@ interface Props {
1010 background : BackgroundId
1111 onBackgroundChange : ( id : BackgroundId ) => void
1212 hasWallpaper : boolean
13- onWallpaperChange : ( dataUrl : string ) => void
13+ onWallpaperChange : ( dataUrl : string | null ) => void
1414}
1515
1616export default function BackgroundPicker ( {
@@ -41,7 +41,6 @@ export default function BackgroundPicker({
4141 try {
4242 const dataUrl = await loadWallpaperFile ( file )
4343 onWallpaperChange ( dataUrl )
44- onBackgroundChange ( 'custom' )
4544 } catch {
4645 setError ( true )
4746 } finally {
@@ -67,20 +66,18 @@ export default function BackgroundPicker({
6766 className = "fixed right-16 top-11 z-[100] w-60 rounded-xl border border-white/10 bg-zinc-950/95 p-2 shadow-2xl shadow-black/50 backdrop-blur-xl"
6867 onPointerDown = { event => event . stopPropagation ( ) }
6968 >
69+ < p className = "px-3 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[.18em] text-white/35" >
70+ Animation
71+ </ p >
7072 { backgrounds . map ( option => {
7173 const active = option . id === background
72- const isCustom = option . id === 'custom'
7374 return (
7475 < button
7576 key = { option . id }
7677 type = "button"
7778 onPointerDown = { event => {
7879 event . preventDefault ( )
7980 event . stopPropagation ( )
80- if ( isCustom && ! hasWallpaper ) {
81- fileRef . current ?. click ( )
82- return
83- }
8481 onBackgroundChange ( option . id )
8582 setOpen ( false )
8683 } }
@@ -89,7 +86,7 @@ export default function BackgroundPicker({
8986 } `}
9087 >
9188 < span className = "grid h-4 w-4 place-items-center text-accent" >
92- { isCustom ? < ImageIcon size = { 14 } /> : < Sparkles size = { 12 } /> }
89+ < Sparkles size = { 12 } />
9390 </ span >
9491 < span className = "flex-1 font-semibold" > { option . label } </ span >
9592 { active && < Check size = { 14 } className = "text-accent" /> }
@@ -99,6 +96,28 @@ export default function BackgroundPicker({
9996
10097 < div className = "my-1 border-t border-white/10" />
10198
99+ < p className = "px-3 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[.18em] text-white/35" >
100+ Wallpaper
101+ </ p >
102+
103+ < button
104+ type = "button"
105+ onPointerDown = { event => {
106+ event . preventDefault ( )
107+ event . stopPropagation ( )
108+ onWallpaperChange ( null )
109+ } }
110+ className = { `flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm transition ${
111+ ! hasWallpaper ? 'bg-white/[.10] text-white' : 'text-white/72 hover:bg-white/[.07] hover:text-white'
112+ } `}
113+ >
114+ < span className = "grid h-4 w-4 place-items-center text-accent" >
115+ < Monitor size = { 13 } />
116+ </ span >
117+ < span className = "flex-1 font-semibold" > Default</ span >
118+ { ! hasWallpaper && < Check size = { 14 } className = "text-accent" /> }
119+ </ button >
120+
102121 < button
103122 type = "button"
104123 onPointerDown = { event => {
@@ -107,16 +126,37 @@ export default function BackgroundPicker({
107126 fileRef . current ?. click ( )
108127 } }
109128 disabled = { busy }
110- className = "flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-white/72 transition hover:bg-white/[.07] hover:text-white disabled:opacity-50"
129+ className = { `flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm transition disabled:opacity-50 ${
130+ hasWallpaper ? 'bg-white/[.10] text-white' : 'text-white/72 hover:bg-white/[.07] hover:text-white'
131+ } `}
111132 >
112133 < span className = "grid h-4 w-4 place-items-center text-accent" >
113- < Upload size = { 13 } />
134+ { hasWallpaper ? < ImageIcon size = { 14 } /> : < Upload size = { 13 } /> }
114135 </ span >
115136 < span className = "flex-1 font-semibold" >
116- { busy ? 'Loading…' : hasWallpaper ? 'Replace wallpaper… ' : 'Upload wallpaper…' }
137+ { busy ? 'Loading…' : hasWallpaper ? 'Custom ' : 'Upload wallpaper…' }
117138 </ span >
139+ { hasWallpaper && < Check size = { 14 } className = "text-accent" /> }
118140 </ button >
119141
142+ { hasWallpaper && (
143+ < button
144+ type = "button"
145+ onPointerDown = { event => {
146+ event . preventDefault ( )
147+ event . stopPropagation ( )
148+ fileRef . current ?. click ( )
149+ } }
150+ disabled = { busy }
151+ className = "flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/55 transition hover:bg-white/[.07] hover:text-white disabled:opacity-50"
152+ >
153+ < span className = "grid h-4 w-4 place-items-center text-accent" >
154+ < Upload size = { 12 } />
155+ </ span >
156+ < span className = "flex-1 font-semibold" > Replace wallpaper…</ span >
157+ </ button >
158+ ) }
159+
120160 { error && (
121161 < p className = "px-3 pb-1 pt-0.5 text-xs text-red-300" > Could not load that image.</ p >
122162 ) }
0 commit comments