Set CSS value in HTML to reflect current theme
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- css, javascript
- Bereich
- documentation, frontend
Rechercherichtung
Beginne damit, den Theme-Selector und die Funktion activateTheme() nachzuverfolgen, um zu sehen, wie das ausgewählte Theme auf die Seite angewendet wird. Füge dem relevanten Seiten-Container einen zuverlässigen Dark-Mode-Marker hinzu und bestätige anschließend, dass das SVG-Styling den vom Selector ausgewählten Dark Mode vom Light Mode und vom Dark Mode aufgrund der Browsereinstellung unterscheiden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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?
- Vorherrschende Sprache
- CSS
- Sterne
- 90
- Forks
- 78
- Ø Merge
- 2 T. 19 Std.
- Gemergte PRs (30 T.)
- 4
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/python-docs-theme
-
bug help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python/python-docs-theme#289 · 7 Kommentare · 2 Reaktionen ·
-
Docs Python.org button Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python/python-docs-theme#217 · 7 Kommentare · 1 Reaktion ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
python/python-docs-theme#311 · 5 Kommentare ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 Kommentare · 1 zugewiesene Person ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
python/python-docs-theme#245 · 3 Kommentare ·
Alle Issues in python/python-docs-theme
Ähnliche Issues
-
triage
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
feature pydanty:is-working
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
pydantic/pydantic-ai#8647 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
:watch: Not Triaged dotnet-fsharp/svc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100