diff --git a/README.md b/README.md
index 17d84cb..25ca7a8 100644
--- a/README.md
+++ b/README.md
@@ -143,8 +143,6 @@ BONOB_SCROBBLE_TRACKS | true | Whether to scrobble the playing of a track if it
BONOB_REPORT_NOW_PLAYING | true | Whether to report a track as now playing
BONOB_ICON_FOREGROUND_COLOR | undefined | Icon foreground color in sonos app, must be a valid [svg color](https://www.december.com/html/spec/colorsvg.html)
BONOB_ICON_BACKGROUND_COLOR | undefined | Icon background color in sonos app, must be a valid [svg color](https://www.december.com/html/spec/colorsvg.html)
-BONOB_ICON_FONT_COLOR | undefined | Icon font color in sonos app, must be a valid [svg color](https://www.december.com/html/spec/colorsvg.html)
-BONOB_ICON_FONT_FAMILY | undefined | Icon font family in sonos app
## Initialising service within sonos app
diff --git a/src/config.ts b/src/config.ts
index 52afb89..5950d0d 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -33,8 +33,6 @@ export default function () {
icons: {
foregroundColor: wordFrom("BONOB_ICON_FOREGROUND_COLOR"),
backgroundColor: wordFrom("BONOB_ICON_BACKGROUND_COLOR"),
- fontColor: wordFrom("BONOB_ICON_FONT_COLOR"),
- fontFamily: wordFrom("BONOB_ICON_FONT_FAMILY")
},
sonos: {
serviceName: process.env["BONOB_SONOS_SERVICE_NAME"] || "bonob",
diff --git a/src/icon.ts b/src/icon.ts
index 6a86a97..b6ee6a1 100644
--- a/src/icon.ts
+++ b/src/icon.ts
@@ -16,9 +16,6 @@ export type Transformation = {
viewPortIncreasePercent: number | undefined;
backgroundColor: string | undefined;
foregroundColor: string | undefined;
- text: string | undefined;
- fontColor: string | undefined;
- fontFamily: string | undefined;
};
const SVG_NS = {
@@ -59,7 +56,7 @@ export class ColorOverridingIcon implements Icon {
newColors: () => Partial<
Pick<
Transformation,
- "backgroundColor" | "foregroundColor" | "fontColor" | "fontFamily"
+ "backgroundColor" | "foregroundColor"
>
>;
icon: Icon;
@@ -70,7 +67,7 @@ export class ColorOverridingIcon implements Icon {
newColors: () => Partial<
Pick<
Transformation,
- "backgroundColor" | "foregroundColor" | "fontColor" | "fontFamily"
+ "backgroundColor" | "foregroundColor"
>
>
) {
@@ -97,9 +94,6 @@ export class SvgIcon implements Icon {
viewPortIncreasePercent: undefined,
backgroundColor: undefined,
foregroundColor: undefined,
- text: undefined,
- fontColor: undefined,
- fontFamily: undefined,
}
) {
this.svg = svg;
@@ -143,31 +137,6 @@ export class SvgIcon implements Icon {
else path.attr({ fill: this.transformation.foregroundColor! });
});
}
- if (this.transformation.text) {
- const w = Math.abs(viewBox.minX) + Math.abs(viewBox.width);
- const h = Math.abs(viewBox.minY) + Math.abs(viewBox.height);
- const i = Math.floor(0.1 * w);
- let attr: any = {
- "font-size": `${Math.floor(h / 4)}`,
- "font-weight": "bold",
- };
- if (this.transformation.fontFamily)
- attr = { ...attr, "font-family": this.transformation.fontFamily };
- if (this.transformation.fontColor)
- attr = { ...attr, style: `fill:${this.transformation.fontColor}` };
- const g = new Element(xml, "g");
- g.attr(attr);
- (xml.get("//svg:svg", SVG_NS) as Element).addChild(
- g.addChild(
- new Element(xml, "text")
- .attr({
- x: `${viewBox.minX + i}`,
- y: `${viewBox.minY + Math.floor(0.8 * h)}`,
- })
- .text(this.transformation.text)
- )
- );
- }
return xml.toString();
};
}
@@ -186,7 +155,7 @@ export const makeFestive = (icon: Icon, clock: Clock = SystemClock): Icon => {
rule: (clock: Clock) => boolean,
colors: Pick<
Transformation,
- "backgroundColor" | "foregroundColor" | "fontColor"
+ "backgroundColor" | "foregroundColor"
>
) =>
new ColorOverridingIcon(
@@ -201,33 +170,29 @@ export const makeFestive = (icon: Icon, clock: Clock = SystemClock): Icon => {
rule: (clock: Clock) => boolean,
colors: Pick<
Transformation,
- "backgroundColor" | "foregroundColor" | "fontColor"
+ "backgroundColor" | "foregroundColor"
>
) => (result = wrap(result, rule, colors));
apply(isChristmas, {
backgroundColor: "green",
foregroundColor: "red",
- fontColor: "white",
});
const randomHoliColors = _.shuffle([...HOLI_COLORS]);
apply(isHoli, {
backgroundColor: randomHoliColors.pop(),
foregroundColor: randomHoliColors.pop(),
- fontColor: randomHoliColors.pop(),
});
apply(isCNY, {
backgroundColor: "red",
foregroundColor: "yellow",
- fontColor: "crimson",
});
apply(isHalloween, {
backgroundColor: "orange",
foregroundColor: "black",
- fontColor: "orangered",
});
return result;
diff --git a/src/server.ts b/src/server.ts
index b45568d..b5be154 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -387,9 +387,6 @@ function server(
app.get("/icon/:type/size/:size", (req, res) => {
const type = req.params["type"]!;
const size = req.params["size"]!;
- const text: string | undefined = req.query.text
- ? (req.query.text as string)
- : undefined;
if (!Object.keys(ICONS).includes(type)) {
return res.status(404).send();
@@ -415,7 +412,7 @@ function server(
return Promise.resolve(
makeFestive(
- icon.with({ text, ...serverOpts.iconColors }),
+ icon.with(serverOpts.iconColors),
clock
).toString()
)
diff --git a/src/smapi.ts b/src/smapi.ts
index ab1aa32..e83331b 100644
--- a/src/smapi.ts
+++ b/src/smapi.ts
@@ -217,8 +217,7 @@ const genre = (bonobUrl: URLBuilder, genre: Genre) => ({
title: genre.name,
albumArtURI: iconArtURI(
bonobUrl,
- iconForGenre(genre.name),
- genre.name
+ iconForGenre(genre.name)
).href(),
});
@@ -254,12 +253,10 @@ export const defaultAlbumArtURI = (bonobUrl: URLBuilder, album: AlbumSummary) =>
export const iconArtURI = (
bonobUrl: URLBuilder,
- icon: ICON,
- text: string | undefined = undefined
+ icon: ICON
) =>
bonobUrl.append({
- pathname: `/icon/${icon}/size/legacy`,
- searchParams: text ? { text } : {},
+ pathname: `/icon/${icon}/size/legacy`
});
export const defaultArtistArtURI = (
diff --git a/tests/config.test.ts b/tests/config.test.ts
index 5ee89c5..037c871 100644
--- a/tests/config.test.ts
+++ b/tests/config.test.ts
@@ -169,68 +169,6 @@ describe("config", () => {
});
});
});
-
- describe("fontColor", () => {
- describe("when BONOB_ICON_FONT_COLOR is not specified", () => {
- it(`should default to undefined`, () => {
- expect(config().icons.fontColor).toEqual(undefined);
- });
- });
-
- describe("when BONOB_ICON_FONT_COLOR is ''", () => {
- it(`should default to undefined`, () => {
- process.env["BONOB_ICON_FONT_COLOR"] = "";
- expect(config().icons.fontColor).toEqual(undefined);
- });
- });
-
- describe("when BONOB_ICON_FONT_COLOR is specified", () => {
- it(`should use it`, () => {
- process.env["BONOB_ICON_FONT_COLOR"] = "pink";
- expect(config().icons.fontColor).toEqual("pink");
- });
- });
-
- describe("when BONOB_ICON_FONT_COLOR is an invalid string", () => {
- it(`should blow up`, () => {
- process.env["BONOB_ICON_FONT_COLOR"] = "#dfasd";
- expect(() => config()).toThrow(
- "Invalid color specified for BONOB_ICON_FONT_COLOR"
- );
- });
- });
- });
-
- describe("fontFamily", () => {
- describe("when BONOB_ICON_FONT_FAMILY is not specified", () => {
- it(`should default to undefined`, () => {
- expect(config().icons.fontFamily).toEqual(undefined);
- });
- });
-
- describe("when BONOB_ICON_FONT_FAMILY is ''", () => {
- it(`should default to undefined`, () => {
- process.env["BONOB_ICON_FONT_FAMILY"] = "";
- expect(config().icons.fontFamily).toEqual(undefined);
- });
- });
-
- describe("when BONOB_ICON_FONT_FAMILY is specified", () => {
- it(`should use it`, () => {
- process.env["BONOB_ICON_FONT_FAMILY"] = "helveta";
- expect(config().icons.fontFamily).toEqual("helveta");
- });
- });
-
- describe("when BONOB_ICON_FONT_FAMILY is an invalid string", () => {
- it(`should blow up`, () => {
- process.env["BONOB_ICON_FONT_FAMILY"] = "#dfasd";
- expect(() => config()).toThrow(
- "Invalid color specified for BONOB_ICON_FONT_FAMILY"
- );
- });
- });
- });
});
describe("secret", () => {
diff --git a/tests/icon.test.ts b/tests/icon.test.ts
index 753c64d..8383e61 100644
--- a/tests/icon.test.ts
+++ b/tests/icon.test.ts
@@ -228,75 +228,6 @@ describe("SvgIcon", () => {
});
});
});
-
- describe("with some text", () => {
- describe("with no font color or style", () => {
- describe("with no viewPort increase", () => {
- it("should render the line", () => {
- expect(
- new SvgIcon(svgIcon24).with({ text: "hello" }).toString()
- ).toEqual(
- xmlTidy(`
-
- `)
- );
- });
- });
-
- describe("with a viewPort increase", () => {
- it("should render the line", () => {
- expect(
- new SvgIcon(svgIcon24)
- .with({ viewPortIncreasePercent: 50, text: "hello" })
- .toString()
- ).toEqual(
- xmlTidy(`
-
- `)
- );
- });
- });
- });
-
- describe("with no font color and style", () => {
- it("should render the line", () => {
- expect(
- new SvgIcon(svgIcon24)
- .with({
- text: "hello world",
- fontColor: "red",
- fontFamily: "helvetica",
- })
- .toString()
- ).toEqual(
- xmlTidy(`
-
- `)
- );
- });
- });
- });
});
class DummyIcon implements Icon {
@@ -315,8 +246,6 @@ describe("ColorOverridingIcon", () => {
const icon = new DummyIcon({
backgroundColor: "black",
foregroundColor: "black",
- fontColor: "black",
- fontFamily: "plain",
});
describe("overriding some options", () => {
@@ -338,8 +267,6 @@ describe("ColorOverridingIcon", () => {
viewPortIncreasePercent: 99,
backgroundColor: "blue",
foregroundColor: "red",
- fontColor: "black",
- fontFamily: "plain",
});
});
});
@@ -350,8 +277,6 @@ describe("ColorOverridingIcon", () => {
new DummyIcon({
backgroundColor: "blue",
foregroundColor: "red",
- fontColor: "black",
- fontFamily: "plain",
}).toString()
);
});
@@ -365,8 +290,6 @@ describe("ColorOverridingIcon", () => {
() => ({
backgroundColor: "blue",
foregroundColor: "red",
- fontColor: "pink",
- fontFamily: "fancy",
})
);
@@ -376,16 +299,12 @@ describe("ColorOverridingIcon", () => {
viewPortIncreasePercent: 99,
backgroundColor: "shouldBeIgnored",
foregroundColor: "shouldBeIgnored",
- fontColor: "shouldBeIgnored",
- fontFamily: "shouldBeIgnored",
}) as DummyIcon;
expect(result.transformation).toEqual({
viewPortIncreasePercent: 99,
backgroundColor: "blue",
foregroundColor: "red",
- fontColor: "pink",
- fontFamily: "fancy",
});
});
});
@@ -396,8 +315,6 @@ describe("ColorOverridingIcon", () => {
new DummyIcon({
backgroundColor: "blue",
foregroundColor: "red",
- fontColor: "pink",
- fontFamily: "fancy",
}).toString()
);
});
@@ -444,7 +361,6 @@ describe("makeFestive", () => {
const icon = new DummyIcon({
backgroundColor: "black",
foregroundColor: "black",
- fontColor: "black",
});
let now = dayjs();
@@ -460,14 +376,12 @@ describe("makeFestive", () => {
viewPortIncreasePercent: 88,
backgroundColor: "shouldBeUsed",
foregroundColor: "shouldBeUsed",
- fontColor: "shouldBeUsed",
}) as DummyIcon;
expect(result.transformation).toEqual({
viewPortIncreasePercent: 88,
backgroundColor: "shouldBeUsed",
foregroundColor: "shouldBeUsed",
- fontColor: "shouldBeUsed",
});
});
});
@@ -482,14 +396,12 @@ describe("makeFestive", () => {
viewPortIncreasePercent: 25,
backgroundColor: "shouldNotBeUsed",
foregroundColor: "shouldNotBeUsed",
- fontColor: "shouldNotBeUsed",
}) as DummyIcon;
expect(result.transformation).toEqual({
viewPortIncreasePercent: 25,
backgroundColor: "green",
foregroundColor: "red",
- fontColor: "white",
});
});
});
@@ -504,14 +416,12 @@ describe("makeFestive", () => {
viewPortIncreasePercent: 12,
backgroundColor: "shouldNotBeUsed",
foregroundColor: "shouldNotBeUsed",
- fontColor: "shouldNotBeUsed",
}) as DummyIcon;
expect(result.transformation).toEqual({
viewPortIncreasePercent: 12,
backgroundColor: "orange",
foregroundColor: "black",
- fontColor: "orangered",
});
});
});
@@ -526,14 +436,12 @@ describe("makeFestive", () => {
viewPortIncreasePercent: 12,
backgroundColor: "shouldNotBeUsed",
foregroundColor: "shouldNotBeUsed",
- fontColor: "shouldNotBeUsed",
}) as DummyIcon;
expect(result.transformation).toEqual({
viewPortIncreasePercent: 12,
backgroundColor: "red",
foregroundColor: "yellow",
- fontColor: "crimson",
});
});
});
@@ -548,7 +456,6 @@ describe("makeFestive", () => {
viewPortIncreasePercent: 12,
backgroundColor: "shouldNotBeUsed",
foregroundColor: "shouldNotBeUsed",
- fontColor: "shouldNotBeUsed",
}) as DummyIcon;
expect(result.transformation.viewPortIncreasePercent).toEqual(12);
@@ -558,15 +465,9 @@ describe("makeFestive", () => {
expect(
HOLI_COLORS.includes(result.transformation.foregroundColor!)
).toEqual(true);
- expect(HOLI_COLORS.includes(result.transformation.fontColor!)).toEqual(
- true
- );
expect(result.transformation.backgroundColor).not.toEqual(
result.transformation.foregroundColor
);
- expect(result.transformation.backgroundColor).not.toEqual(
- result.transformation.fontColor
- );
});
});
});
diff --git a/tests/server.test.ts b/tests/server.test.ts
index 6a9da2d..156b51e 100644
--- a/tests/server.test.ts
+++ b/tests/server.test.ts
@@ -1636,16 +1636,6 @@ describe("server", () => {
expect(svg).toContain(`fill="brightpink"`);
});
- it("should return an icon with text if requested", async () => {
- const response = await request(server(SystemClock)).get(
- `/icon/${type}/size/180?text=foobar1000`
- );
-
- expect(response.status).toEqual(200);
- const svg = Buffer.from(response.body).toString();
- expect(svg).toContain(`foobar1000`);
- });
-
it("should return a christmas icon on christmas day", async () => {
const response = await request(
server({ now: () => dayjs("2022/12/25") })
diff --git a/tests/smapi.test.ts b/tests/smapi.test.ts
index 33f40a6..bbc625e 100644
--- a/tests/smapi.test.ts
+++ b/tests/smapi.test.ts
@@ -1021,7 +1021,6 @@ describe("api", () => {
albumArtURI: iconArtURI(
bonobUrl,
iconForGenre(genre.name),
- genre.name
).href(),
})),
index: 0,
@@ -1047,7 +1046,6 @@ describe("api", () => {
albumArtURI: iconArtURI(
bonobUrl,
iconForGenre(genre.name),
- genre.name
).href(),
})),
index: 1,