feat(handlers): add file icons with standard and retro variants
Introduce file icon support to the file browser. Icons are loaded on startup and mapped based on file name and content type. - Load file icon mappings in the App handler initialization. - Add `HasThumbnail`, `IconURL`, and `IconRetroURL` to the file view. - Update CSS to support displaying file icons alongside thumbnails. - Add retro theme support to swap standard icons with pixelated retro variants when the retro theme is active.
This commit is contained in:
@@ -45,6 +45,9 @@ type fileView struct {
|
||||
URL string
|
||||
DownloadURL string
|
||||
ThumbnailURL string
|
||||
HasThumbnail bool
|
||||
IconURL string
|
||||
IconRetroURL string
|
||||
ReactURL string
|
||||
Reactions []reactionView
|
||||
Reacted bool
|
||||
@@ -350,6 +353,7 @@ func (a *App) fileView(box services.Box, file services.File) fileView {
|
||||
}
|
||||
|
||||
func (a *App) fileViewWithReactions(box services.Box, file services.File, reactions []services.ReactionSummary, reacted bool) fileView {
|
||||
icon := a.fileIcons.lookup(file.Name, file.ContentType)
|
||||
return fileView{
|
||||
ID: file.ID,
|
||||
Name: file.Name,
|
||||
@@ -359,6 +363,9 @@ func (a *App) fileViewWithReactions(box services.Box, file services.File, reacti
|
||||
URL: fmt.Sprintf("/d/%s/f/%s", box.ID, file.ID),
|
||||
DownloadURL: fmt.Sprintf("/d/%s/f/%s/download", box.ID, file.ID),
|
||||
ThumbnailURL: fmt.Sprintf("/d/%s/thumb/%s", box.ID, file.ID),
|
||||
HasThumbnail: file.Thumbnail != "",
|
||||
IconURL: fileIconURL("standard", icon.Standard),
|
||||
IconRetroURL: fileIconURL("retro", icon.Retro),
|
||||
ReactURL: fmt.Sprintf("/d/%s/f/%s/react", box.ID, file.ID),
|
||||
Reactions: a.reactionViews(reactions),
|
||||
Reacted: reacted,
|
||||
|
||||
Reference in New Issue
Block a user