Skip to content

Commit 750a83d

Browse files
authored
refactor: use vendor css from npm package (@fehmer) (monkeytypegame#6206)
This PR removes the remaining "vendor" css files copied into `static/css` and pick them from npm packages instead. For the slimselect the css should match the version of the js. Since we use the slimselect `js` file from the npm package we should use the `css` file from the package as well. For the balloon.css the file was copied into the project. Adding it as a dependency makes sure we know the version of it and we don't modify it in the project leading to problems when we try to update it later. Similar to the vendor `js` files (js dependencies from packages) extract the vendor `css` files into a separate `css` file as well.
1 parent 3510ea9 commit 750a83d

File tree

8 files changed

+23
-5
lines changed

8 files changed

+23
-5
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@monkeytype/funbox": "workspace:*",
7474
"@monkeytype/util": "workspace:*",
7575
"@ts-rest/core": "3.51.0",
76+
"balloon-css": "1.2.0",
7677
"canvas-confetti": "1.5.1",
7778
"chart.js": "3.7.1",
7879
"chartjs-adapter-date-fns": "3.0.0",

frontend/src/html/head.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,7 @@
8989
<meta name="twitter:card" content="summary_large_image" />
9090
<meta name="darkreader-lock" />
9191
<meta http-equiv="Cache-Control" content="no-store" />
92+
<link rel="preload" href="styles/vendor.scss" as="style" />
93+
<link rel="stylesheet" href="styles/vendor.scss" />
9294
<link rel="stylesheet" href="styles/index.scss" />
9395
</head>

frontend/src/styles/core.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
var(--caret-color) 20%,
2929
transparent
3030
);
31+
32+
--balloon-font-size: 1rem;
33+
--balloon-border-radius: calc(var(--roundness) / 2);
3134
}
3235

3336
::placeholder {
@@ -418,3 +421,10 @@ key {
418421
color: var(--error-color);
419422
}
420423
}
424+
425+
// mouseover texts
426+
[aria-label][data-balloon-pos]:after {
427+
font-family: var(--font);
428+
font-size: var(--balloon-font-size);
429+
line-height: var(--balloon-font-size);
430+
}

frontend/src/styles/vendor.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "slim-select/styles";
2+
@import "balloon-css/src/balloon";

frontend/src/ts/ready.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import { loadPromise } from "./config";
1212

1313
$(async (): Promise<void> => {
1414
await loadPromise;
15-
Misc.loadCSS("/css/slimselect.min.css", true);
16-
Misc.loadCSS("/css/balloon.min.css", true);
17-
1815
CookiesModal.check();
1916

2017
//this line goes back to pretty much the beginning of the project and im pretty sure its here

frontend/static/css/balloon.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/static/css/slimselect.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)