Set CSS value in HTML to reflect current theme
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- css, javascript
- Domínio
- documentation, frontend
Direção de pesquisa
Comece rastreando o seletor de tema e a função activateTheme() para ver como o tema selecionado é aplicado à página. Adicione um marcador confiável de modo escuro ao contêiner de página relevante e confirme então que a estilização de SVG consegue distinguir o modo escuro escolhido pelo seletor do modo claro e do modo escuro definido pela preferência do navegador.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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?
- Linguagem predominante
- CSS
- Estrelas
- 90
- Forks
- 78
- Merge médio
- 2d 19h
- PRs com merge (30d)
- 4
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/python-docs-theme
-
bug help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/python-docs-theme#289 · 7 comentários · 2 reações ·
-
Docs Python.org button Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/python-docs-theme#217 · 7 comentários · 1 reação ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
python/python-docs-theme#311 · 5 comentários ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 comentários · 1 responsável ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
python/python-docs-theme#245 · 3 comentários ·
Todas as issues de python/python-docs-theme
Issues semelhantes
-
Add: hunch Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
AbdelStark/awesome-typesafe#104 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
A11y ♿️
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
Link Checker Report Abertaautomated issue report
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
-
documentation improve or update documentation priority/low triage
Dificuldade 2/5 Meio dia Facilidade para iniciantes 86/100
warpdotdev/docs#782 · 1 comentário ·