Title: Set CSS value in HTML to reflect current theme · Issue #192 · python/python-docs-theme · GitHub
Open Graph Title: Set CSS value in HTML to reflect current theme · Issue #192 · python/python-docs-theme
X Title: Set CSS value in HTML to reflect current theme · Issue #192 · python/python-docs-theme
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 app...
Open Graph 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...
X 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 mode...
Opengraph URL: https://github.com/python/python-docs-theme/issues/192
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Set CSS value in HTML to reflect current theme","articleBody":"See [this page](https://docs.python.org/3/howto/logging.html#logging-flow), 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.\n\nThe 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 `\u003cbody\u003e` 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:\n```css\n svg {\n background-color: transparent !important;\n }\n line {\n stroke: #000000;\n fill: none;\n stroke-opacity: 1;\n }\n polygon, rect {\n fill: none;\n stroke: #000000;\n fill-opacity: 1;\n stroke-opacity: 1;\n }\n polygon.filled {\n fill: #ff0000;\n }\n polyline {\n fill: none;\n stroke-opacity: 1;\n stroke: #000000;\n }\n text {\n fill: #000000;\n fill-opacity: 1;\n stroke: none;\n font-family: sans-serif;\n font-style: normal;\n font-weight: normal;\n text-anchor: start;\n }\n @media (prefers-color-scheme: dark) { /* could duplicate this styling if body.dark-theme */\n polygon, rect, polyline, line {\n stroke: #ffffff;\n }\n text {\n fill: #ffffff;\n }\n }\n```\nIf 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?\n","author":{"url":"https://github.com/vsajip","@type":"Person","name":"vsajip"},"datePublished":"2024-07-01T18:11:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/192/python-docs-theme/issues/192"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:53faa974-f752-8d03-a51f-318058a7f8f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C20C:32E262:2921B10:376C90D:69707313 |
| html-safe-nonce | a352301824c951cfb80b59825eea613616927723744250804828216941fe5f7b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjBDOjMyRTI2MjoyOTIxQjEwOjM3NkM5MEQ6Njk3MDczMTMiLCJ2aXNpdG9yX2lkIjoiMTIwMjMyNTI1MjQ2MTMyNzEyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f37fd10f12fe6a241fc781fd7d2c6a13f23e7a5ee34f07d25be153f33c4fc733 |
| hovercard-subject-tag | issue:2384450017 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/python-docs-theme/192/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20b24925030503163810c45a0af58de3d24fda8bb175268206e91c241c74ee32/python/python-docs-theme/issues/192 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20b24925030503163810c45a0af58de3d24fda8bb175268206e91c241c74ee32/python/python-docs-theme/issues/192 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vsajip |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/python-docs-theme git https://github.com/python/python-docs-theme.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 93341818 |
| octolytics-dimension-repository_nwo | python/python-docs-theme |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 93341818 |
| octolytics-dimension-repository_network_root_nwo | python/python-docs-theme |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width