angular / angular/components

feat(theming): Add a typesafe like API to get theming tokens CSS var names

Đang mở
#32,800 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

area: material/core feature P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

Feature Description

Currently there are Sass mixings that allow to, in a typesafe safe way, override theming tokens:

mat.snack-bar-overrides(....)

When saying typesafe, I mean that if a token is renamed or removed, the compiler will trigger an error. There are no equivalent to generating the CSS custom properties associated with these tokens.

Use Case

Why this could help?

I have a component to show temporary messages, much like an snack-bar, but it isn't a snack bar, but it uses the same snack bar theming, same colors, for example. So this uses currently --mat-snack-bar- prefixed CSS variables. The problem is that migrating from version 19 up to 21, many of these variables names were renamed from --mdc- to --mat- prefixes thankfully automatically but it missed that for snack bars, the prefixes changed from snackbar to snack-bar.

If instead of using the var named directly we had some kind of:

mat.token-var(snack-bar, container-color, white)

to generate var(--mat-snack-bar-container-color, white) in a typesafe way, triggering an error if a bad component or token name is used, this could have avoided the missed rename.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Không có tệp hoặc điểm bắt đầu của bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng việc kiểm tra các Sass override mixin hiện có, bao gồm mat.snack-bar-overrides, cùng với quy ước đặt tên CSS custom-property của snack-bar được mô tả ở đây. Công việc được xem là hoàn tất khi có một API typesafe đã được thống nhất để tạo tên biến token và có coverage cho các tên component hoặc token không hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, sass
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.