Skip to content

Commit fd133c8

Browse files
committed
✨ remove dark theme media query on default option
1 parent 229c9a9 commit fd133c8

File tree

4 files changed

+60
-96
lines changed

4 files changed

+60
-96
lines changed

packages/action/__tests__/__snapshots__/outputsOptions.spec.ts.snap

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`should parse /out.svg {"color_snake":"yellow"} 1`] = `
4-
{
5-
"animationOptions": {
6-
"frameDuration": 100,
7-
"step": 1,
8-
},
9-
"drawOptions": {
10-
"colorDotBorder": "#1b1f230a",
11-
"colorDots": [
12-
"#ebedf0",
13-
"#9be9a8",
14-
"#40c463",
15-
"#30a14e",
16-
"#216e39",
17-
],
18-
"colorEmpty": "#ebedf0",
19-
"colorSnake": "yellow",
20-
"dark": {
21-
"colorDotBorder": "#1b1f230a",
22-
"colorDots": [
23-
"#161b22",
24-
"#01311f",
25-
"#034525",
26-
"#0f6d31",
27-
"#00c647",
28-
],
29-
"colorEmpty": "#161b22",
30-
"colorSnake": "purple",
31-
},
32-
"sizeCell": 16,
33-
"sizeDot": 12,
34-
"sizeDotBorderRadius": 2,
35-
},
36-
"filename": "/out.svg",
37-
"format": "svg",
38-
}
39-
`;
40-
41-
exports[`should parse /out.svg?.gif.svg?color_snake=orange 1`] = `
42-
{
43-
"animationOptions": {
44-
"frameDuration": 100,
45-
"step": 1,
46-
},
47-
"drawOptions": {
48-
"colorDotBorder": "#1b1f230a",
49-
"colorDots": [
50-
"#ebedf0",
51-
"#9be9a8",
52-
"#40c463",
53-
"#30a14e",
54-
"#216e39",
55-
],
56-
"colorEmpty": "#ebedf0",
57-
"colorSnake": "orange",
58-
"dark": {
59-
"colorDotBorder": "#1b1f230a",
60-
"colorDots": [
61-
"#161b22",
62-
"#01311f",
63-
"#034525",
64-
"#0f6d31",
65-
"#00c647",
66-
],
67-
"colorEmpty": "#161b22",
68-
"colorSnake": "purple",
69-
},
70-
"sizeCell": 16,
71-
"sizeDot": 12,
72-
"sizeDotBorderRadius": 2,
73-
},
74-
"filename": "/out.svg?.gif.svg",
75-
"format": "svg",
76-
}
77-
`;
78-
793
exports[`should parse /out.svg?{"color_snake":"yellow","color_dots":["#000","#111","#222","#333","#444"]} 1`] = `
804
{
815
"animationOptions": {
@@ -148,6 +72,7 @@ exports[`should parse /out.svg?color_snake=orange&color_dots=#000,#111,#222,#333
14872
"colorEmpty": "#000",
14973
"colorSnake": "orange",
15074
"dark": {
75+
"colorDotBorder": "#1b1f230a",
15176
"colorDots": [
15277
"#a00",
15378
"#a11",
@@ -156,6 +81,7 @@ exports[`should parse /out.svg?color_snake=orange&color_dots=#000,#111,#222,#333
15681
"#a44",
15782
],
15883
"colorEmpty": "#a00",
84+
"colorSnake": "orange",
15985
},
16086
"sizeCell": 16,
16187
"sizeDot": 12,
@@ -183,18 +109,7 @@ exports[`should parse path/to/out.gif 1`] = `
183109
],
184110
"colorEmpty": "#ebedf0",
185111
"colorSnake": "purple",
186-
"dark": {
187-
"colorDotBorder": "#1b1f230a",
188-
"colorDots": [
189-
"#161b22",
190-
"#01311f",
191-
"#034525",
192-
"#0f6d31",
193-
"#00c647",
194-
],
195-
"colorEmpty": "#161b22",
196-
"colorSnake": "purple",
197-
},
112+
"dark": undefined,
198113
"sizeCell": 16,
199114
"sizeDot": 12,
200115
"sizeDotBorderRadius": 2,

packages/action/__tests__/outputsOptions.spec.ts

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,58 @@
11
import { parseEntry } from "../outputsOptions";
22

3+
it("should parse options as json", () => {
4+
expect(
5+
parseEntry(`/out.svg {"color_snake":"yellow"}`)?.drawOptions
6+
).toHaveProperty("colorSnake", "yellow");
7+
8+
expect(
9+
parseEntry(`/out.svg?{"color_snake":"yellow"}`)?.drawOptions
10+
).toHaveProperty("colorSnake", "yellow");
11+
12+
expect(
13+
parseEntry(`/out.svg?{"color_dots":["#000","#111","#222","#333","#444"]}`)
14+
?.drawOptions.colorDots
15+
).toEqual(["#000", "#111", "#222", "#333", "#444"]);
16+
});
17+
18+
it("should parse options as searchparams", () => {
19+
expect(parseEntry(`/out.svg?color_snake=yellow`)?.drawOptions).toHaveProperty(
20+
"colorSnake",
21+
"yellow"
22+
);
23+
24+
expect(
25+
parseEntry(`/out.svg?color_dots=#000,#111,#222,#333,#444`)?.drawOptions
26+
.colorDots
27+
).toEqual(["#000", "#111", "#222", "#333", "#444"]);
28+
});
29+
30+
it("should parse filename", () => {
31+
expect(parseEntry(`/a/b/c.svg?{"color_snake":"yellow"}`)).toHaveProperty(
32+
"filename",
33+
"/a/b/c.svg"
34+
);
35+
expect(
36+
parseEntry(`/a/b/out.svg?.gif.svg?{"color_snake":"yellow"}`)
37+
).toHaveProperty("filename", "/a/b/out.svg?.gif.svg");
38+
39+
expect(
40+
parseEntry(`/a/b/{[-1].svg?.gif.svg?{"color_snake":"yellow"}`)
41+
).toHaveProperty("filename", "/a/b/{[-1].svg?.gif.svg");
42+
});
43+
344
[
45+
// default
446
"path/to/out.gif",
547

48+
// overwrite colors (search params)
649
"/out.svg?color_snake=orange&color_dots=#000,#111,#222,#333,#444",
750

51+
// overwrite colors (json)
852
`/out.svg?{"color_snake":"yellow","color_dots":["#000","#111","#222","#333","#444"]}`,
953

10-
`/out.svg {"color_snake":"yellow"}`,
11-
54+
// overwrite dark colors
1255
"/out.svg?color_snake=orange&color_dots=#000,#111,#222,#333,#444&dark_color_dots=#a00,#a11,#a22,#a33,#a44",
13-
14-
"/out.svg?.gif.svg?color_snake=orange",
1556
].forEach((entry) =>
1657
it(`should parse ${entry}`, () => {
1758
expect(parseEntry(entry)).toMatchSnapshot();

packages/action/outputsOptions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const parseEntry = (entry: string) => {
3232
sizeCell: 16,
3333
sizeDot: 12,
3434
...palettes["default"],
35+
dark: palettes["default"].dark && { ...palettes["default"].dark },
3536
};
3637
const animationOptions: AnimationOptions = { step: 1, frameDuration: 100 };
3738

@@ -43,6 +44,14 @@ export const parseEntry = (entry: string) => {
4344
}
4445
}
4546

47+
{
48+
const dark_palette = palettes[sp.get("dark_palette")!];
49+
if (dark_palette) {
50+
const clone = { ...dark_palette, dark: undefined };
51+
drawOptions.dark = clone;
52+
}
53+
}
54+
4655
if (sp.has("color_snake")) drawOptions.colorSnake = sp.get("color_snake")!;
4756
if (sp.has("color_dots")) {
4857
const colors = sp.get("color_dots")!.split(/[,;]/);
@@ -56,6 +65,8 @@ export const parseEntry = (entry: string) => {
5665
if (sp.has("dark_color_dots")) {
5766
const colors = sp.get("dark_color_dots")!.split(/[,;]/);
5867
drawOptions.dark = {
68+
colorDotBorder: drawOptions.colorDotBorder,
69+
colorSnake: drawOptions.colorSnake,
5970
...drawOptions.dark,
6071
colorDots: colors,
6172
colorEmpty: colors[0],

packages/action/palettes.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ export const basePalettes: Record<
2323

2424
// aliases
2525
export const palettes = { ...basePalettes };
26-
palettes["github"] = {
27-
...palettes["github-light"],
28-
dark: { ...palettes["github-dark"] },
29-
};
26+
palettes["github"] = palettes["github-light"];
3027
palettes["default"] = palettes["github"];

0 commit comments

Comments
 (0)