Set CSS value in HTML to reflect current theme
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- css, javascript
- Lĩnh vực
- documentation, frontend
Hướng nghiên cứu
Bắt đầu bằng cách lần theo bộ chọn giao diện và hàm activateTheme() để xem giao diện được chọn được áp dụng cho trang như thế nào. Thêm một dấu đánh dấu chế độ tối đáng tin cậy vào vùng chứa trang liên quan, sau đó xác nhận rằng kiểu SVG có thể phân biệt chế độ tối được bộ chọn chọn với chế độ sáng và chế độ tối theo tùy chọn của trình duyệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- CSS
- Star
- 90
- Fork
- 78
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/python-docs-theme
-
bug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python/python-docs-theme#289 · 7 bình luận · 2 reaction ·
-
Docs Python.org button Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python/python-docs-theme#217 · 7 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
python/python-docs-theme#311 · 5 bình luận ·
-
enhancement github_actions
python/python-docs-theme#260 · 6 bình luận · 1 người được giao ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
python/python-docs-theme#245 · 3 bình luận ·
Tất cả issue của python/python-docs-theme
Issue tương tự
-
triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
feature pydanty:is-working
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
pydantic/pydantic-ai#8647 ·
-
Add date o "release information" Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Add more to the documentation Đang mở:watch: Not Triaged dotnet-fsharp/svc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100