Skip to content

Commit 7c7eac9

Browse files
Fix
1 parent 5506a14 commit 7c7eac9

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

packages/cheatsheet/src/lib/Cheatsheet.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { faCircleQuestion } from "@fortawesome/free-solid-svg-icons/faCircleQuestion";
22
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3+
import { useEffect } from "preact/hooks";
34
import "./cheatsheet.css";
45
import type { CheatsheetInfo } from "./cheatsheet.types";
56
import { cheatsheetLegendData } from "./utils/cheatsheetLegendData";
@@ -9,13 +10,15 @@ import CheatsheetNotesSection from "./CheatsheetNotesSection";
910
import { applyBootstrapTheme } from "./utils/applyBootstrapTheme";
1011
import SmartLink from "./utils/SmartLink";
1112

12-
applyBootstrapTheme();
13-
1413
type Props = {
1514
cheatsheetInfo: CheatsheetInfo;
1615
};
1716

1817
export function Cheatsheet({ cheatsheetInfo }: Props) {
18+
useEffect(() => {
19+
return applyBootstrapTheme();
20+
}, []);
21+
1922
return (
2023
<main className="cheatsheet">
2124
<div className="container-xxl pb-2">

packages/cheatsheet/src/lib/utils/applyBootstrapTheme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export function applyBootstrapTheme() {
2-
console.log("hello");
32
const media = window.matchMedia("(prefers-color-scheme: dark)");
43

54
function applyTheme() {
@@ -12,4 +11,8 @@ export function applyBootstrapTheme() {
1211
applyTheme();
1312

1413
media.addEventListener("change", applyTheme);
14+
15+
return () => {
16+
media.removeEventListener("change", applyTheme);
17+
};
1518
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { Cheatsheet, defaultCheatsheetInfo } from "@cursorless/cheatsheet";
1+
import {
2+
Cheatsheet as OriginalCheatsheet,
3+
defaultCheatsheetInfo,
4+
} from "@cursorless/cheatsheet";
25

36
export function Cheatsheet() {
47
return (
58
<>
69
<title>Cursorless cheatsheet</title>
7-
<Cheatsheet cheatsheetInfo={defaultCheatsheetInfo} />
10+
<OriginalCheatsheet cheatsheetInfo={defaultCheatsheetInfo} />
811
</>
912
);
1013
}

packages/cursorless-vscode/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,8 @@
12811281
]
12821282
},
12831283
"scripts": {
1284-
"build": "pnpm run esbuild:prod && pnpm -F cheatsheet-local build:prod && pnpm -F cursorless-vscode-tutorial-webview build:prod && pnpm run populate-dist",
1285-
"build:dev": "pnpm generate-grammar && pnpm run esbuild && pnpm -F cheatsheet-local build && pnpm -F cursorless-vscode-tutorial-webview build && pnpm run populate-dist",
1284+
"build": "pnpm run esbuild:prod && pnpm run populate-dist",
1285+
"build:dev": "pnpm generate-grammar && pnpm run esbuild && pnpm run populate-dist",
12861286
"esbuild:base": "bash ./scripts/compile-esbuild.sh",
12871287
"install-local": "bash ./scripts/install-local.sh",
12881288
"install-from-pr": "bash ./scripts/install-from-pr.sh",
@@ -1326,6 +1326,8 @@
13261326
"vscode-uri": "^3.1.0"
13271327
},
13281328
"devDependencies": {
1329+
"@cursorless/cheatsheet-local": "workspace:*",
1330+
"@cursorless/cursorless-vscode-tutorial-webview": "workspace:*",
13291331
"@types/fs-extra": "^11.0.4",
13301332
"@types/js-yaml": "^4.0.9",
13311333
"@types/lodash-es": "^4.17.12",

0 commit comments

Comments
 (0)