Set CSS value in HTML to reflect current theme
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- css, javascript
調査の方向性
まずテーマセレクターと activateTheme() 関数を追跡し、選択されたテーマがページにどのように適用されるかを確認します。関連するページコンテナに信頼できるダークモードのマーカーを追加し、SVG スタイリングで、セレクターによって選択されたダークモード、ライトモード、ブラウザーの設定によるダークモードを区別できることを確認します。
索引モデルが issue の本文から書いたものです。
説明
See this page, where the anchor points to an SVG. If you ensure that there's no theme in local storage for this page, then if the browser settings are used to switch between dark and light modes (I'm using Firefox), the SVG is styled appropriately to display correctly. However, if I use the theme selector on the page to select dark mode when the browser is set to light mode, the SVG does not display correctly.
The reason is that I style for light mode and use a media query to override some styles, using @media (prefers-color-scheme: dark). However, when the theme selector is used to select dark mode, then some dark-mode CSS is pulled in using the activateTheme() JS function, but from what I can tell this leaves no trace in the markup that we're now in dark mode. If there were e.g. a dark-theme class added to the <body> tag when the page is in dark mode, then I could duplicate the styling using an appropriate selector. My complete styling of the SVG is:
svg {
background-color: transparent !important;
}
line {
stroke: #000000;
fill: none;
stroke-opacity: 1;
}
polygon, rect {
fill: none;
stroke: #000000;
fill-opacity: 1;
stroke-opacity: 1;
}
polygon.filled {
fill: #ff0000;
}
polyline {
fill: none;
stroke-opacity: 1;
stroke: #000000;
}
text {
fill: #000000;
fill-opacity: 1;
stroke: none;
font-family: sans-serif;
font-style: normal;
font-weight: normal;
text-anchor: start;
}
@media (prefers-color-scheme: dark) { /* could duplicate this styling if body.dark-theme */
polygon, rect, polyline, line {
stroke: #ffffff;
}
text {
fill: #ffffff;
}
}
If there is another approach I could use to achieve the desired result (proper styling of the SVG in all cases), please let me know. Otherwise, would you consider adding dark-theme class to the body or other container tag so that I could try and achieve the desired result? Or have I missed somewhere where such a class has been added?
- 主要言語
- CSS
- スター
- 90
- フォーク
- 78
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/python-docs-theme のほかの issue
-
bug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/python-docs-theme#289 · コメント 7 件 · リアクション 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/python-docs-theme#217 · コメント 7 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
python/python-docs-theme#311 · コメント 5 件 ·
-
enhancement github_actions
python/python-docs-theme#260 · コメント 6 件 · 担当者 1 名 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
python/python-docs-theme#245 · コメント 3 件 ·
python/python-docs-theme の issue をすべて見る
似ている issue
-
Area: Excel support
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
orbeon/orbeon-forms#7893 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
docToolchain/docToolchain#1705 ·
-
kb-infra-drift
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
OCHA-DAP/ds-knowledge-base#653 · コメント 1 件 ·
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
EclipseFdn/open-vsx.org#13419 ·