[Bug]: Internal and external design token hashes don't match
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- design
Hướng nghiên cứu
Start by comparing how @cloudscape-design/design-tokens generates or consumes CSS variable names with how @cloudscape-design/components and @cloudscape-design/global-styles emit them; the issue does not name source files or tests. Reproduce with the listed package versions and applyMode(Mode.Dark), then check whether the token variable set by dark mode is the one used by the inline style. Done when the packages' supported version contract is clear and the documented usage produces the dark-mode background.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Browser
Chrome
Package version
3.0.1330
React version
Description
I fully admit I may not be understanding something here about how this is supposed to be used, but I'm going by (as far as I can tell) official documentation.
I'm trying to implement dark mode in my application, and I have had to override some color somewhere in one of my controls (you may already feel where this is going).
As per the design token documentation, I am doing the following:
import * as awsui from '@cloudscape-design/design-tokens';
return (
<div style={{ backgroundColor: awsui.colorBackgroundContainerContent }}></div>
);
The dark mode documentation says that I should be using design tokens everywhere, which I'm doing, so I'm feeling good.
By the way, that page has 0 context on how to actually apply dark mode itself, which I've had to Google to come out to something like this:
import { applyMode, Mode } from "@cloudscape-design/global-styles";
export type LightDarkPreference = 'system' | 'dark' | 'light';
let userPreference = localStorage.getItem('light-dark-preference') as LightDarkPreference | null ?? 'system';
const systemDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
// Initialize color mode based on user's OS preference and stay in sync if the preference changes.
systemDarkMode.addEventListener('change', () => refreshDarkMode());
refreshDarkMode();
function refreshDarkMode() {
if (userPreference === 'system') {
applyMode(systemDarkMode.matches ? Mode.Dark : Mode.Light);
} else if (userPreference === 'dark') {
applyMode(Mode.Dark);
} else {
applyMode(Mode.Light);
}
}
The symptom
But of course, when I switch to Dark Mode my background is still bright white. The design token didn't do anything:
The promixate cause
When I look at the CSS it's because the variable names don't match:
// Variable consumed by the design-tokens library
background-color: var(--color-background-container-content-mjfil9, #ffffff);
// Variable set by the <body> element
.awsui-dark-mode:not(#\ ) {
--color-background-container-content-6u8rvp: var(--color-neutral-850-3f0gro);
}
The root cause?
Because mjfil9 != 6u8rvp, the variable that is set is not the variable that is read.
But my question is: why? I'm following documentation (as far as I can tell).
I'm consuming the following packages... they're not all the same major version but they are all the same major version line as the most recent packges (v3 for components and design-tokens, v1 for global-styles). I could perhaps expect incompatibilities between major version lines, but not inside a major version line.
@cloudscape-design/components 3.0.1330
@cloudscape-design/design-tokens 3.0.114
@cloudscape-design/global-styles 1.0.62
As far as I can tell I also only have one copy of each, so it's not multiple copies of the same package at slightly different versions, which should have been deduplicated but weren't.
What is the contract here?
Please tell me the it isn't "I have to go hunt for the exact patch version of components that was used to build design-tokens (or the other way around), and any time I upgrade one of the packages I have to go hunt for the patch version again" ?
Source code
No response
Reproduction
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate problems
- Ngôn ngữ chính
- TypeScript
- Star
- 2.7k
- Fork
- 248
- Merge trung bình
- 3 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 83
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 cloudscape-design/components
-
[Bug]: Circular app layout navigation and help icons are shifted upward in the official demoĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
cloudscape-design/components#5184 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudscape-design/components#5152 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
cloudscape-design/components#5149 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
cloudscape-design/components#5106 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug/Feature Request]: `usePerformanceMarks` has ID generation incompatible with Next.js Partial PrerenderingCó thể đã có người làm @amanabiy đã nhận 22 ngày trước. Đang mởenhancement
cloudscape-design/components#5023 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của cloudscape-design/components
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
braintrustdata/braintrust-sdk-javascript#2659 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
body-parser 2.3.0 in the published ai-dial-chat-bff image is vulnerable (CVE-2026-111181, HIGH)Có thể đã có người làm @illya-havsiyevych đã nhận hôm nay. Đang mởbug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
epam/ai-dial-chat#9566 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
はさみアイコンを修正するĐang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
resource.reload() while params is in error switches the resource to 'idle' instead of retryingĐang mởarea: core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày