mirror of https://github.com/luizdepra/hugo-coder.git

XiaoTian
28.53.2022 9f7ec4f706e7d0ff4997dc692b368ebc9516a5ba
refs
author XiaoTian <tianyp@pku.edu.cn>
Monday, November 28, 2022 20:53 +0100
committer GitHub <noreply@github.com>
Monday, November 28, 2022 20:53 +0100
commit9f7ec4f706e7d0ff4997dc692b368ebc9516a5ba
tree 4dce678b50a88cdd40caf23156243accede8e19d tree | zip | gz
parent 5c4502ae75ad98ec90877eec0fe8f26331bdaaf3 view | diff
Fix disqus background in dark mode. (#732)

### Prerequisites

- [x] This pull request fixes a bug.
- [x] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

This PR fixes the bug about disqus iframe background in dark mode, it
also fix another bug when switching color mode.

Before:
<img width="881" alt="opaque background in dark mode"
src="https://user-images.githubusercontent.com/17041194/202862887-720dbb82-f0c8-4a24-97fd-78baef2a7cb4.png">

After:
<img width="883" alt="CleanShot 2022-11-20 at 01 12 52@2x"
src="https://user-images.githubusercontent.com/17041194/202863146-d5a246a7-bbe5-4bef-9687-883ce33f5b1a.png">

#### Why this happens

The problem is widely discussed
[here](https://github.com/w3c/csswg-drafts/issues/4772).

>If the color scheme of an iframe differs from embedding document,
iframe gets an opaque canvas bg appropriate to its color scheme.

So I made two fixes:

1. Add `color-scheme: light` CSS property for disqus `iframe`, this
creates a transparent background and fixes the opaque issue.
2. Add `themeChanged` event to notice disqus comments board refresh when
the theme change, this fixes the opaque problem when you switch the
mode.

#### Reference

I've been working on this issue for a whole night and the fixing idea
was strongly inspired by [Sergeyski's
Blog](https://sergeyski.com/css-color-scheme-and-iframes-lessons-learned-from-disqus-background-bug/).

### Issues Resolved

Fixes #722.
8 files modified
43 ■■■■■ changed files
CONTRIBUTORS.md 1 ●●●● diff | view | raw | blame | history
assets/js/coder.js 3 ●●●●● diff | view | raw | blame | history
assets/scss/_base.scss 4 ●●●● diff | view | raw | blame | history
exampleSite/resources/_gen/assets/scss/scss/coder.scss_fd4b5b3f9a48bc0c7f005d2f7a4cc30f.content 3 ●●●●● diff | view | raw | blame | history
layouts/partials/posts/disqus.html 25 ●●●●● diff | view | raw | blame | history
resources/_gen/assets/scss/scss/coder.scss_5e1eb8e37c42cdfb6215b61e44dcfa5f.content 2 ●●● diff | view | raw | blame | history
resources/_gen/assets/scss/scss/coder.scss_5e1eb8e37c42cdfb6215b61e44dcfa5f.json 2 ●●● diff | view | raw | blame | history
resources/_gen/assets/scss/scss/coder.scss_fd4b5b3f9a48bc0c7f005d2f7a4cc30f.content 3 ●●●●● diff | view | raw | blame | history