Skip to content

Commit 8153d54

Browse files
committed
refactor: use Spicetify.Icon type
1 parent 5e899ae commit 8153d54

File tree

2 files changed

+4
-83
lines changed

2 files changed

+4
-83
lines changed

src/types.ts

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -24,85 +24,6 @@ export type Settings = {
2424

2525
export type ButtonTone = "primary" | "danger" | "subtle" | "default";
2626

27-
export type IconName =
28-
| "collaborative"
29-
| "album"
30-
| "artist"
31-
| "block"
32-
| "brightness"
33-
| "car"
34-
| "chart-down"
35-
| "chart-up"
36-
| "check"
37-
| "check-alt-fill"
38-
| "chevron-left"
39-
| "chevron-right"
40-
| "chromecast-disconnected"
41-
| "clock"
42-
| "computer"
43-
| "copy"
44-
| "download"
45-
| "downloaded"
46-
| "edit"
47-
| "enhance"
48-
| "exclamation-circle"
49-
| "external-link"
50-
| "facebook"
51-
| "follow"
52-
| "fullscreen"
53-
| "gamepad"
54-
| "grid-view"
55-
| "heart"
56-
| "heart-active"
57-
| "instagram"
58-
| "laptop"
59-
| "library"
60-
| "list-view"
61-
| "location"
62-
| "locked"
63-
| "locked-active"
64-
| "lyrics"
65-
| "menu"
66-
| "minimize"
67-
| "minus"
68-
| "more"
69-
| "new-spotify-connect"
70-
| "offline"
71-
| "pause"
72-
| "phone"
73-
| "play"
74-
| "playlist"
75-
| "playlist-folder"
76-
| "plus2px"
77-
| "plus-alt"
78-
| "podcasts"
79-
| "projector"
80-
| "queue"
81-
| "repeat"
82-
| "repeat-once"
83-
| "search"
84-
| "search-active"
85-
| "shuffle"
86-
| "skip-back"
87-
| "skip-back15"
88-
| "skip-forward"
89-
| "skip-forward15"
90-
| "soundbetter"
91-
| "speaker"
92-
| "spotify"
93-
| "subtitles"
94-
| "tablet"
95-
| "ticket"
96-
| "twitter"
97-
| "visualizer"
98-
| "voice"
99-
| "volume"
100-
| "volume-off"
101-
| "volume-one-wave"
102-
| "volume-two-wave"
103-
| "watch"
104-
| "x";
105-
10627
export type ButtonRenderOptions = {
10728
action?: string;
10829
id?: string;

src/ui.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Snapshot, Settings, ButtonTone, IconName, ButtonRenderOptions } from "./types";
1+
import { Snapshot, Settings, ButtonTone, ButtonRenderOptions } from "./types";
22
import { loadSnapshots, pruneAutosToMax, saveSettings, saveSnapshots } from "./storage";
33
import { getSnapshotItemNames, getSnapshotDisplayName } from "./names";
44
import { escapeHtml, downloadJson, setButtonLabel } from "./utils";
@@ -19,14 +19,14 @@ const exportingIds = new Set<string>();
1919

2020
const DEFAULT_ICON_SIZE = 16;
2121

22-
function getIconMarkup(icon: IconName, size = DEFAULT_ICON_SIZE): string {
22+
function getIconMarkup(icon: Spicetify.Icon, size = DEFAULT_ICON_SIZE): string {
2323
const iconMap = (Spicetify.SVGIcons ?? {}) as Record<string, string>;
2424
const raw = iconMap[icon];
2525
if (!raw) return "";
2626
return `<span class="qs-btn-icon" data-icon-name="${escapeHtml(icon)}"><svg class="qs-svg-icon" viewBox="0 0 16 16" aria-hidden="true" focusable="false" style="width:${size}px;height:${size}px;">${raw}</svg></span>`;
2727
}
2828

29-
function renderButton(label: string, icon: IconName, options: ButtonRenderOptions = {}): string {
29+
function renderButton(label: string, icon: Spicetify.Icon, options: ButtonRenderOptions = {}): string {
3030
const { action, id, tone = "default", title } = options;
3131
const classes = ["qs-btn"];
3232
if (tone === "danger") classes.push("danger");
@@ -41,7 +41,7 @@ function renderButton(label: string, icon: IconName, options: ButtonRenderOption
4141
return `<button type="button" class="${classes.join(" ")}"${attrString}>${iconHtml}<span class="qs-btn-label">${escapeHtml(label)}</span></button>`;
4242
}
4343

44-
function renderActionIconButton(action: string, icon: IconName, title: string): string {
44+
function renderActionIconButton(action: string, icon: Spicetify.Icon, title: string): string {
4545
return `<button type="button" class="qs-icon-btn" data-action="${escapeHtml(action)}" title="${escapeHtml(title)}">${getIconMarkup(icon)}</button>`;
4646
}
4747

0 commit comments

Comments
 (0)