Skip to content

Commit 77b5eed

Browse files
hawkgsthePunderWoman
authored andcommitted
refactor(devtools): extract and organize colors into themes (angular#60374)
Extract all colors from the stylesheets, reduce their number by merging the similar ones and organize them into themes represented by CSS variables. PR Close angular#60374
1 parent c65259c commit 77b5eed

File tree

50 files changed

+361
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+361
-622
lines changed

devtools/projects/ng-devtools/src/lib/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package(default_visibility = ["//visibility:public"])
88
sass_binary(
99
name = "devtools_component_styles",
1010
src = "devtools.component.scss",
11-
deps = ["//devtools/projects/ng-devtools/src/styles:theme"],
1211
)
1312

1413
ng_module(

devtools/projects/ng-devtools/src/lib/application-services/theme_service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class ThemeService {
3535
toggleDarkMode(isDark: boolean): void {
3636
const removeClass = isDark ? LIGHT_THEME_CLASS : DARK_THEME_CLASS;
3737
const addClass = !isDark ? LIGHT_THEME_CLASS : DARK_THEME_CLASS;
38-
this.renderer.removeClass(this.doc.body, removeClass);
39-
this.renderer.addClass(this.doc.body, addClass);
38+
this.renderer.removeClass(this.doc.documentElement, removeClass);
39+
this.renderer.addClass(this.doc.documentElement, addClass);
4040
this.currentTheme.set(addClass);
4141
}
4242

devtools/projects/ng-devtools/src/lib/application-services/theme_service_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('ThemeService', () => {
5757
const doc = TestBed.inject(DOCUMENT);
5858

5959
expect(service.currentTheme()).toEqual('light-theme');
60-
expect(doc.body.classList.contains('light-theme')).toBeTrue();
60+
expect(doc.documentElement.classList.contains('light-theme')).toBeTrue();
6161
});
6262

6363
it(`should enable dark mode, if it's the preferred/system one`, () => {
@@ -69,7 +69,7 @@ describe('ThemeService', () => {
6969
const doc = TestBed.inject(DOCUMENT);
7070

7171
expect(service.currentTheme()).toEqual('dark-theme');
72-
expect(doc.body.classList.contains('dark-theme')).toBeTrue();
72+
expect(doc.documentElement.classList.contains('dark-theme')).toBeTrue();
7373
});
7474

7575
it('should toggle dark mode', () => {
@@ -84,7 +84,7 @@ describe('ThemeService', () => {
8484
const doc = TestBed.inject(DOCUMENT);
8585

8686
expect(service.currentTheme()).toEqual('dark-theme');
87-
expect(doc.body.classList.contains('dark-theme')).toBeTrue();
87+
expect(doc.documentElement.classList.contains('dark-theme')).toBeTrue();
8888
});
8989

9090
it('should update the theme automatically, if the system one changes', () => {
@@ -95,7 +95,7 @@ describe('ThemeService', () => {
9595
// Initialize the watcher.
9696
service.initializeThemeWatcher();
9797

98-
const docClassList = TestBed.inject(DOCUMENT).body.classList;
98+
const docClassList = TestBed.inject(DOCUMENT).documentElement.classList;
9999

100100
expect(service.currentTheme()).toEqual('light-theme');
101101
expect(docClassList.contains('light-theme')).toBeTrue();

devtools/projects/ng-devtools/src/lib/devtools-tabs/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package(default_visibility = ["//visibility:public"])
88
sass_binary(
99
name = "devtools_tabs_component_styles",
1010
src = "devtools-tabs.component.scss",
11-
deps = ["//devtools/projects/ng-devtools/src/styles:theme"],
1211
)
1312

1413
ng_module(

devtools/projects/ng-devtools/src/lib/devtools-tabs/dependency-injection/resolution-path/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ sass_binary(
99
name = "resolution_path_styles",
1010
src = "resolution-path.component.scss",
1111
visibility = ["//visibility:private"],
12-
deps = ["//devtools/projects/ng-devtools/src/styles:theme"],
1312
)
1413

1514
ng_module(

devtools/projects/ng-devtools/src/lib/devtools-tabs/dependency-injection/resolution-path/resolution-path.component.scss

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
@use '../../../../styles/theme' as theme;
2-
3-
/* TODO: Extract */
4-
$darkBg: #1a1a1a;
5-
$lightBg: #f3f3f3;
6-
71
:host {
82
display: flex;
93
flex-wrap: wrap;
10-
background: $lightBg;
11-
border-top: 1px solid black;
4+
background: var(--octonary-contrast);
125
padding: 0.5rem 0.5rem 0.25rem 0.5rem;
6+
border-top: 1px solid var(--senary-contrast);
137

148
.node {
159
position: relative;
1610
border-radius: 5px;
17-
background: #c4c4c4;
11+
background: var(--octonary-contrast);
1812
color: black;
1913
padding: 4px 25px 4px 15px;
2014
margin-bottom: 0.25rem;
@@ -23,15 +17,15 @@ $lightBg: #f3f3f3;
2317
box-sizing: border-box;
2418

2519
&.type-env {
26-
background: #f9c2c5;
20+
background: var(--red-06);
2721
}
2822

2923
&.type-element {
30-
background: #a6d5a9;
24+
background: var(--green-03);
3125
}
3226

3327
&.type-imported {
34-
background: #c79eff;
28+
background: var(--purple-03);
3529
}
3630

3731
&.type-hidden {
@@ -60,7 +54,7 @@ $lightBg: #f3f3f3;
6054

6155
&:not(:last-of-type)::before {
6256
content: '';
63-
background: $lightBg;
57+
background: var(--octonary-contrast);
6458
width: 21px;
6559
height: 21px;
6660
top: calc(50% - 6px);
@@ -76,10 +70,3 @@ $lightBg: #f3f3f3;
7670
}
7771
}
7872
}
79-
80-
@include theme.dark-theme {
81-
:host,
82-
.node:not(:last-of-type)::before {
83-
background: #1a1a1a;
84-
}
85-
}

devtools/projects/ng-devtools/src/lib/devtools-tabs/devtools-tabs.component.scss

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@use '../../styles/theme' as theme;
2-
31
:host {
42
position: relative;
53
width: 100%;
@@ -23,6 +21,10 @@ ng-injector-tree.hidden {
2321
height: calc(100% - 31px);
2422
}
2523

24+
nav {
25+
border-bottom: 1px solid var(--color-separator);
26+
}
27+
2628
#nav-buttons {
2729
display: flex;
2830

@@ -31,6 +33,7 @@ ng-injector-tree.hidden {
3133
border: none;
3234
cursor: pointer;
3335
opacity: 0.8;
36+
color: var(--secondary-contrast);
3437

3538
&:active {
3639
opacity: 1;
@@ -39,7 +42,7 @@ ng-injector-tree.hidden {
3942
}
4043

4144
.inspector-active {
42-
color: #1a73e8 !important;
45+
color: var(--blue-02) !important;
4346
}
4447

4548
#app-angular-version {
@@ -54,7 +57,7 @@ ng-injector-tree.hidden {
5457
}
5558

5659
#version-number {
57-
color: #1b1aa5;
60+
color: var(--blue-02);
5861
cursor: text;
5962
-moz-user-select: text;
6063
-khtml-user-select: text;
@@ -63,7 +66,7 @@ ng-injector-tree.hidden {
6366
user-select: text;
6467

6568
&.unsupported-version {
66-
color: red;
69+
color: var(--red-04);
6770
}
6871
}
6972

@@ -109,42 +112,11 @@ mat-icon {
109112
}
110113

111114
.frame-selector {
112-
background-color: #e2e2e2;
113115
border-radius: 2px;
114-
color: #474747;
115116
border: none;
116117
margin: 4px 4px 2px 4px;
117118
padding: 2px;
118119
outline-offset: -2px;
119120
width: 100px;
120121
font-size: 12px;
121122
}
122-
123-
@include theme.dark-theme {
124-
.frame-selector {
125-
background-color: #464646;
126-
color: #fff;
127-
}
128-
129-
#app-angular-version {
130-
color: #fff;
131-
}
132-
133-
#nav-buttons {
134-
button {
135-
color: #fff;
136-
}
137-
}
138-
139-
#version-number {
140-
color: #5caace;
141-
142-
&.unsupported-version {
143-
color: red;
144-
}
145-
}
146-
147-
.inspector-active {
148-
color: #4688f1 !important;
149-
}
150-
}

devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/directive-forest/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"])
66
sass_binary(
77
name = "directive_forest_component_styles",
88
src = "directive-forest.component.scss",
9-
deps = ["//devtools/projects/ng-devtools/src/styles:theme"],
109
)
1110

1211
ng_module(

devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/directive-forest/breadcrumbs/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"])
66
sass_binary(
77
name = "breadcrumbs_component_styles",
88
src = "breadcrumbs.component.scss",
9-
deps = ["//devtools/projects/ng-devtools/src/styles:theme"],
109
)
1110

1211
ng_module(
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@use '../../../../../styles/theme' as theme;
2-
31
.mdc-card.breadcrumb-card {
42
padding: 0;
53
width: 100%;
@@ -9,7 +7,7 @@
97

108
.scroll-button {
119
height: 100%;
12-
background-color: rgb(243, 243, 243);
10+
background-color: var(--septenary-contrast);
1311
border: none;
1412
cursor: pointer;
1513

@@ -34,7 +32,7 @@
3432
height: 24px;
3533

3634
&.selected {
37-
background-color: rgb(243, 243, 243);
35+
background-color: var(--color-tree-node-highlighted);
3836
}
3937
}
4038
}
@@ -45,36 +43,10 @@
4543
font-size: 11px;
4644
margin-right: 5px;
4745
width: fit-content;
48-
color: #8a1882;
46+
color: var(--color-tree-node-element-name);
4947

5048
&:hover {
51-
background-color: #ebf1fb;
52-
}
53-
}
54-
}
55-
56-
@include theme.dark-theme {
57-
.mdc-card {
58-
&.breadcrumb-card {
59-
.scroll-button {
60-
background-color: rgb(41, 42, 45);
61-
color: #ffffff;
62-
}
63-
64-
.breadcrumbs {
65-
button {
66-
&.selected {
67-
background-color: rgb(41, 42, 45);
68-
}
69-
}
70-
}
71-
72-
.mdc-button {
73-
color: #5caace;
74-
&:hover {
75-
background-color: #093e69;
76-
}
77-
}
49+
background-color: var(--color-tree-node-hovered);
7850
}
7951
}
8052
}

0 commit comments

Comments
 (0)