Skip to content

Commit

Permalink
refactor: use vendor css from npm package (@fehmer) (#6206)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fehmer authored Feb 3, 2025
1 parent 3510ea9 commit 750a83d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@monkeytype/funbox": "workspace:*",
"@monkeytype/util": "workspace:*",
"@ts-rest/core": "3.51.0",
"balloon-css": "1.2.0",
"canvas-confetti": "1.5.1",
"chart.js": "3.7.1",
"chartjs-adapter-date-fns": "3.0.0",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/html/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@
<meta name="twitter:card" content="summary_large_image" />
<meta name="darkreader-lock" />
<meta http-equiv="Cache-Control" content="no-store" />
<link rel="preload" href="styles/vendor.scss" as="style" />
<link rel="stylesheet" href="styles/vendor.scss" />
<link rel="stylesheet" href="styles/index.scss" />
</head>
10 changes: 10 additions & 0 deletions frontend/src/styles/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
var(--caret-color) 20%,
transparent
);

--balloon-font-size: 1rem;
--balloon-border-radius: calc(var(--roundness) / 2);
}

::placeholder {
Expand Down Expand Up @@ -418,3 +421,10 @@ key {
color: var(--error-color);
}
}

// mouseover texts
[aria-label][data-balloon-pos]:after {
font-family: var(--font);
font-size: var(--balloon-font-size);
line-height: var(--balloon-font-size);
}
2 changes: 2 additions & 0 deletions frontend/src/styles/vendor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "slim-select/styles";
@import "balloon-css/src/balloon";
3 changes: 0 additions & 3 deletions frontend/src/ts/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { loadPromise } from "./config";

$(async (): Promise<void> => {
await loadPromise;
Misc.loadCSS("/css/slimselect.min.css", true);
Misc.loadCSS("/css/balloon.min.css", true);

CookiesModal.check();

//this line goes back to pretty much the beginning of the project and im pretty sure its here
Expand Down
1 change: 0 additions & 1 deletion frontend/static/css/balloon.min.css

This file was deleted.

1 change: 0 additions & 1 deletion frontend/static/css/slimselect.min.css

This file was deleted.

8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 750a83d

Please sign in to comment.