mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
feat(frontend): add basic print functionality
Some checks failed
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
E2E Tests / Build test build of frontend (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (push) Has been cancelled
Run tests & build / Test and build with NodeJS 20 (push) Has been cancelled
E2E Tests / frontend-cypress (1) (push) Has been cancelled
E2E Tests / frontend-cypress (2) (push) Has been cancelled
E2E Tests / frontend-cypress (3) (push) Has been cancelled
Some checks failed
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
E2E Tests / Build test build of frontend (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (push) Has been cancelled
Run tests & build / Test and build with NodeJS 20 (push) Has been cancelled
E2E Tests / frontend-cypress (1) (push) Has been cancelled
E2E Tests / frontend-cypress (2) (push) Has been cancelled
E2E Tests / frontend-cypress (3) (push) Has been cancelled
Co-authored-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Erik Michelson <github@erik.michelson.eu> Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
09e365ceea
commit
45ea11dc9a
51 changed files with 520 additions and 80 deletions
|
@ -1,11 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2024 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { DarkModePreference } from '../../redux/dark-mode/types'
|
||||
import { useApplicationState } from '../common/use-application-state'
|
||||
import useMediaQuery from '@restart/hooks/useMediaQuery'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
/**
|
||||
* Uses the user settings and the browser preference to determine if dark mode should be used.
|
||||
|
@ -14,7 +15,14 @@ import useMediaQuery from '@restart/hooks/useMediaQuery'
|
|||
*/
|
||||
export const useDarkModeState = (): boolean => {
|
||||
const preference = useApplicationState((state) => state.darkMode.darkModePreference)
|
||||
const printModeEnabled = useApplicationState((state) => state.printMode)
|
||||
const isBrowserPreferringDark = useMediaQuery('(prefers-color-scheme: dark)')
|
||||
|
||||
return preference === DarkModePreference.DARK || (preference === DarkModePreference.AUTO && isBrowserPreferringDark)
|
||||
return useMemo(() => {
|
||||
if (printModeEnabled) {
|
||||
return false
|
||||
}
|
||||
|
||||
return preference === DarkModePreference.DARK || (preference === DarkModePreference.AUTO && isBrowserPreferringDark)
|
||||
}, [preference, printModeEnabled, isBrowserPreferringDark])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue