Set CSS value in HTML to reflect current theme
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- css, javascript
- Ambito
- documentation, frontend
Direzione di ricerca
Inizia tracciando il selettore del tema e la funzione activateTheme() per vedere come il tema selezionato viene applicato alla pagina. Aggiungi un indicatore affidabile della modalità scura al contenitore di pagina pertinente, quindi verifica che lo stile SVG possa distinguere la modalità scura scelta dal selettore dalla modalità chiara e dalla modalità scura in base alle preferenze del browser.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- CSS
- Stelle
- 90
- Fork
- 78
- Merge medio
- 2g 19h
- PR unite (30g)
- 4
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python/python-docs-theme
-
bug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python/python-docs-theme#289 · 7 commenti · 2 reazioni ·
-
Docs Python.org button Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python/python-docs-theme#217 · 7 commenti · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
python/python-docs-theme#311 · 5 commenti ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 commenti · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
python/python-docs-theme#245 · 3 commenti ·
Tutte le issue di python/python-docs-theme
Issue simili
-
Add: hunch Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
AbdelStark/awesome-typesafe#104 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
A11y ♿️
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Link Checker Report Apertaautomated issue report
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
documentation improve or update documentation priority/low triage
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
warpdotdev/docs#782 · 1 commento ·