Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: appearance support light/dark mode theme in CodeHike #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/island/src/theme-default/logic/useAppearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@

const setClass = (dark: boolean): void => {
classList[dark ? 'add' : 'remove']('dark');

// When using Code Hike(a remark plugin for MDX v2) and its built-in themes, the two built-in themes both support switching light/dark mode by changing the CSS selector.
// see: https://codehike.org/docs/themes#lightdark-mode
const chThemeEls = document.querySelectorAll("[data-ch-theme='github-from-css'], [data-ch-theme='material-from-css']")

Check failure on line 27 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Replace `"[data-ch-theme='github-from-css'],·[data-ch-theme='material-from-css']")` with `⏎····"[data-ch-theme='github-from-css'],·[data-ch-theme='material-from-css']"⏎··);`

Check failure on line 27 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Strings must use singlequote

Check failure on line 27 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Missing semicolon
const mode = dark ? '' : 'light'

Check failure on line 28 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Insert `;`

Check failure on line 28 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Missing semicolon
chThemeEls.forEach(el => el.setAttribute('data-theme', mode))

Check failure on line 29 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Replace `el·=>·el.setAttribute('data-theme',·mode))` with `(el)·=>·el.setAttribute('data-theme',·mode));`

Check failure on line 29 in packages/island/src/theme-default/logic/useAppearance.ts

View workflow job for this annotation

GitHub Actions / test (16)

Missing semicolon
};

export const getToggle = () => {
Expand Down
Loading