Skip to content

Commit

Permalink
feat(src/monet-theme): don't use @Material dep
Browse files Browse the repository at this point in the history
  • Loading branch information
nexpid committed Dec 7, 2024
1 parent 8ea7831 commit 3a9e7e4
Show file tree
Hide file tree
Showing 8 changed files with 1,243 additions and 18 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"format": "prettier . --write"
},
"dependencies": {
"@material/material-color-utilities": "^0.2.7",
"@nexpid/vdp-shared": "^1.0.2",
"@swc/core": "^1.5.3",
"@swc/helpers": "^0.5.11",
Expand Down
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

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

1 change: 0 additions & 1 deletion scripts/build/modules/workers/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ async function buildPlugin(
".svg": "text",
".json": "json",
},
external: ["@material/material-color-utilities"],
globalName: "$",
banner: { js: "(()=>{" },
footer: { js: "return $;})();" },
Expand Down
22 changes: 14 additions & 8 deletions src/plugins/monet-theme/src/stuff/colors.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {
argbFromHex,
Hct,
hexFromArgb,
} from "@material/material-color-utilities";
import { rawColors } from "@vendetta/ui";

import { vstorage } from "..";
import { argbFromHex, hexFromArgb } from "./material";
import { Cam16 } from "./material/cam16";
import { HctSolver } from "./material/hctsolver";
import { lstarFromArgb } from "./material/utils";

export function parseColor(clr: string): string | undefined {
const shade = Number(clr.split("_")[1]);
Expand All @@ -31,7 +30,14 @@ export function getLABShade(
): string {
mult ??= 1;

const hct = Hct.fromInt(argbFromHex(color));
hct.tone += ((500 - shade) / 10) * mult;
return hexFromArgb(hct.toInt());
const argb = argbFromHex(color);
const cam = Cam16.fromInt(argb);

return hexFromArgb(
HctSolver.solveToInt(
cam.hue,
cam.chroma,
lstarFromArgb(argb) + ((500 - shade) / 10) * mult,
),
);
}
Loading

0 comments on commit 3a9e7e4

Please sign in to comment.