Set CSS value in HTML to reflect current theme
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- css, javascript
- Área
- documentation, frontend
Línea de trabajo
Comienza siguiendo el selector de temas y la función activateTheme() para ver cómo se aplica el tema seleccionado a la página. Añade un marcador fiable de modo oscuro al contenedor de página correspondiente y confirma después que el estilo de SVG puede distinguir entre el modo oscuro elegido por el selector, el modo claro y el modo oscuro según la preferencia del navegador.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- CSS
- Estrellas
- 90
- Forks
- 78
- Merge medio
- 2 d 19 h
- PR fusionados (30 d)
- 4
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/python-docs-theme
-
bug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
python/python-docs-theme#289 · 7 comentarios · 2 reacciones ·
-
Docs Python.org button Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
python/python-docs-theme#217 · 7 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
python/python-docs-theme#311 · 5 comentarios ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 comentarios · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
python/python-docs-theme#245 · 3 comentarios ·
Todos los issues de python/python-docs-theme
Issues similares
-
triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
feature pydanty:is-working
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
pydantic/pydantic-ai#8647 ·
-
Add date o "release information" Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Add more to the documentation Abierto:watch: Not Triaged dotnet-fsharp/svc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100