Set CSS value in HTML to reflect current theme
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- css, javascript
- Domaine
- documentation, frontend
Piste de recherche
Commencez par suivre le sélecteur de thème et la fonction activateTheme() pour voir comment le thème sélectionné est appliqué à la page. Ajoutez un indicateur fiable du mode sombre au conteneur de page concerné, puis vérifiez que le style SVG peut distinguer le mode sombre choisi par le sélecteur du mode clair et du mode sombre selon la préférence du navigateur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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?
- Langage dominant
- CSS
- Étoiles
- 90
- Forks
- 78
- Merge moyen
- 2 j 19 h
- PR mergées (30 j)
- 4
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/python-docs-theme
-
bug help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
python/python-docs-theme#289 · 7 commentaires · 2 réactions ·
-
Docs Python.org button Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
python/python-docs-theme#217 · 7 commentaires · 1 réaction ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
python/python-docs-theme#311 · 5 commentaires ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 commentaires · 1 personne assignée ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
python/python-docs-theme#245 · 3 commentaires ·
Toutes les issues de python/python-docs-theme
Issues similaires
-
triage
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
feature pydanty:is-working
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
pydantic/pydantic-ai#8647 ·
-
Add date o "release information" Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Add more to the documentation Ouverte:watch: Not Triaged dotnet-fsharp/svc
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100