Dark Mode Automatic Theme Switcher

:warning: Discourse now supports Automatic Dark Mode color scheme switching in core, this component is now deprecated and should no longer be used.

Repository:

https://github.com/pmusaraj/discourse-dark-mode

Installation instructions: Installing a theme or theme component

What this does?

This component allows automatic switching to a dark theme when the browser is set to dark mode. This works for logged-in users only on all browsers that support the prefers-color-scheme media query.

By default, this component is enabled and individual users can turn it off in their Preferences > Interface screen. Admins can also set the component to be default off, in which case users will see a button to enable automatic switching in their interface preferences

How it works?

If the browser is in dark mode, this component will reload Discourse with the dark theme enabled. If the browser returns to light mode, this component will reload with the default enabled theme.

It will also reload if dark mode is toggled while user is on the site (as shown in video above).

(If you have more than two themes enabled, and the user has selected a theme other than default or dark, this component will do nothing, i.e. it will respect the user’s choice.)

Configuration

  • Make sure you have a dark theme installed, and that it is selectable by users
  • Add this component to both the default theme and the dark theme (very important, if you don’t add it to both themes, users won’t be able to switch back to the default theme)
  • In the component settings, enter the id of your dark theme in dark theme id
28개의 좋아요

Awesome, although flux is overkill just to toggle dark mode on the mac. Night Owl will do the same thing without interfering with anything else.

4개의 좋아요

I just pushed a small update to this theme component to make it compatible with iOS 13 (which will ship with Dark Mode as well as an option to automatically enable it in the evenings).

9개의 좋아요

이 멋진 컴포넌트를 올려주셔서 감사합니다. 이걸 찾고 있었거든요! 아쉽게도 작동시키는 데 어려움을 겪고 있습니다. 아마도 사소한 문제일 수 있는데, 다크 테마 ID는 어디서 찾을 수 있나요? 그냥 테마 이름인가요?

1개의 좋아요

감사합니다!

ID는 관리자 화면에서 테마를 선택했을 때 URL에 표시되는 테마의 숫자입니다. 예를 들어 /admin/customize/themes/39라는 URL에서 ID는 39입니다.

1개의 좋아요

멋지네요, 완벽하게 작동합니다. 감사합니다! 이 기능이 표준 디스커스 설치에 포함되길 진심으로 바랍니다.

2개의 좋아요

Google Chrome는 이제 iOS 13 및 iPadOS 13에서 다크 모드를 지원합니다. 다만 macOS Mojave 또는 macOS Catalina에서 Google Chrome의 다크 모드 지원 여부는 확실하지 않습니다.

Google Chrome의 지원은 언제 제공될 예정인가요?

이미 Chrome에서 작동해야 합니다. 내부적으로 prefers-color-scheme 미디어 쿼리를 사용하며, 현재 브라우저 지원이 상당히 좋습니다: Can I use... Support tables for HTML5, CSS3, etc

아, 정말 좋은 소식입니다! :grinning:

네, 저도 이 기능이 표준 Discourse 설치에 포함되기를 진심으로 바랍니다. 포럼 업데이트만 하고 그 이상은 하지 않는 사람들이 꽤 있거든요.

1개의 좋아요

@pmusaraj 한 가지 눈여겨본 점은 전환 기능이 로그인한 사용자에서만 작동한다는 것입니다. 아직 계정을 만들지 않은匿名用户(예: 개인 브라우저 창에서 다크 테마로 전환하는 경우)에게도 자동으로 설정할 수 있는 방법이 있을까요?

1개의 좋아요

제 환경에서는 작동하지 않습니다 :-/

향후 업데이트를 위해: 올바른 테마를 선택할 수 있는 드롭다운 메뉴가 있으면 좋겠습니다.

“prefers-color-scheme” 기능은 윈도우에서도 지원됩니다. 최신 Chrome Beta 및 최신 Firefox 버전이 이 미디어 쿼리를 지원합니다.

5개의 좋아요

이 컴포넌트는 2.4.0.beta11+39에서 문제를 일으키는 것 같습니다. 등록 사용자 전용 커뮤니티에서 https://mydomain/login의 로그인 화면이 비어 있습니다. 이 컴포넌트를 비활성화하면 정상적으로 작동합니다.

최신 Discourse와 해당 컴포넌트의 최신 버전으로 로컬에서 이 문제를 재현할 수 없습니다. 로그인 화면이 비어 있을 때 브라우저 콘솔에 오류가 표시되나요?

업데이트: Thomas가 겪었던 문제는 이제 해당 컴포넌트에서 수정되었습니다. 보고해 주셔서 감사합니다!

4개의 좋아요

Discourse Core에 이 기능을 포함시키는 데 +1입니다

4개의 좋아요