angular / angular/components

feat(all theming): Clean and reusable way to override all components theme colors

Đang mở
#30,244 0 bình luận 3 reaction 0 người được giao Xem trên GitHub
area: material/core feature P3
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 is a way to generate a custom color palette using the generation tool. However, all components appear too dark regardless of the target color, and there is no single-line solution to specify a base color tone for all components since `--mat-sys-primary` is hardcoded to the tone value `40` by the theme mixin.

Unfortunately, with Material v19, picking colors from the theme no longer works. You can still specify a material theme using `$app-theme: mat.define-theme(...)` with some restrictions, but applying it using the new mixin `@include mat.theme($app-theme)` doesn't work.

**So please provide clean and simple solution to:**

**1. Specify and reuse a theme object**
For example:
```scss
// Define theme object
$app_theme: mat.define-theme((
color: (primary: $primary-palette),
...
)); // Like it was in Material 18

// then use this theme object to apply theme or get theme color:
@include mat.theme($app-theme);
$theme-color: mat.get-theme-color($app-theme, primary, 70);

```
**2. Specify a base color tone for all components at once**
For example:
```scss
@include mat.theme((
color: (
theme-type: light,
primary: themes.$app-theme-palette, // Generated color palette
primary-color-tone: 70 // Here we specify which tone level to pick from color palette for --mat-sys-primary color
...
)
));
```
**_or as an alternative_** output all theme-palette tones as css variables, so we can easily reuse them to customize theme and component colors:
```scss
@include mat.theme-overrides((
primary: var(--mat-sys-primary-70),
on-primary: var(--mat-sys-primary-100)
));

@include mat.autocomplete-overrides((
background-color: var(--mat-sys-primary-80); // or any other custom color
));

```

**3. Specify a base color for a specific component (single-line override)**
For example:
```scss
@include mat.autocomplete-overrides((
base-color: mat.get-theme-color($theme, primary, 30); // or any other custom color
));
```

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

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

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các entry point mat.define-theme, mat.theme, mat.get-theme-color, mat.theme-overrides và mat.autocomplete-overrides được đề cập, cũng như cách chúng xử lý màu của theme. Issue không nêu tệp hoặc test nào; phần triển khai hoàn tất cần cung cấp một đối tượng theme có thể tái sử dụng, các tông màu cơ sở có thể cấu hình và các override màu component trên một dòng duy nhất mà không có những hạn chế được mô tả.

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, scss
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
35/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.