Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 634bea8

Browse files
committed
Photonize Reps and ObjectInspector.
This patch changes a few CSS variables to match the Devtools Photon design spec. We take this as an opportunity to have more consistent look and classnames across the different reps (e.g. window, document and location).
1 parent 5d5d935 commit 634bea8

File tree

8 files changed

+77
-54
lines changed

8 files changed

+77
-54
lines changed
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4-
.tree.object-inspector .object-label, .object-label * {
4+
5+
.tree.object-inspector .object-label,
6+
.tree.object-inspector .object-label * {
57
color: var(--theme-highlight-blue);
68
}
79

810
.tree.object-inspector .node .unavailable {
9-
color: var(--theme-content-color3);
11+
color: var(--theme-comment);
1012
}
1113

12-
.lessen {
13-
opacity: 0.6;
14+
.tree.object-inspector .lessen,
15+
.tree.object-inspector .lessen *,
16+
.tree.object-inspector .lessen .object-label,
17+
.tree.object-inspector .lessen .object-label * {
18+
color: var(--theme-comment);
1419
}

packages/devtools-reps/src/reps/attribute.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,11 @@ function Attribute(props) {
3232
return (
3333
span({
3434
"data-link-actor-id": object.actor,
35-
className: "objectLink-Attr"
35+
className: "objectBox-Attr"
3636
},
37-
span({className: "attrTitle"},
38-
getTitle(object)
39-
),
40-
span({className: "attrEqual"},
41-
"="
42-
),
43-
StringRep({object: value})
37+
span({className: "attrName"}, getTitle(object)),
38+
span({className: "attrEqual"}, "="),
39+
StringRep({className: "attrValue", object: value})
4440
)
4541
);
4642
}

packages/devtools-reps/src/reps/document.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ function Document(props) {
2929
return (
3030
span({
3131
"data-link-actor-id": grip.actor,
32-
className: "objectBox objectBox-object"
32+
className: "objectBox objectBox-document"
3333
},
3434
getTitle(grip),
35-
span({className: "objectPropValue"},
35+
span({className: "location"},
3636
getLocation(grip)
3737
)
3838
)

packages/devtools-reps/src/reps/element-node.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
isGrip,
1111
wrapRender,
1212
} = require("./rep-utils");
13+
const {rep: StringRep} = require("./string");
1314
const { MODE } = require("./constants");
1415
const nodeConstants = require("../shared/dom-node-constants");
1516
const Svg = require("../shared/images/Svg");
@@ -79,18 +80,18 @@ function ElementNode(props) {
7980
function getElements(grip, mode) {
8081
let {attributes, nodeName} = grip.preview;
8182
const nodeNameElement = span({
82-
className: "tag-name theme-fg-color3"
83+
className: "tag-name"
8384
}, nodeName);
8485

8586
if (mode === MODE.TINY) {
8687
let elements = [nodeNameElement];
8788
if (attributes.id) {
8889
elements.push(
89-
span({className: "attr-name theme-fg-color2"}, `#${attributes.id}`));
90+
span({className: "attrName"}, `#${attributes.id}`));
9091
}
9192
if (attributes.class) {
9293
elements.push(
93-
span({className: "attr-name theme-fg-color2"},
94+
span({className: "attrName"},
9495
attributes.class
9596
.trim()
9697
.split(/\s+/)
@@ -113,20 +114,19 @@ function getElements(grip, mode) {
113114
const attributeElements = attributeKeys.reduce((arr, name, i, keys) => {
114115
let value = attributes[name];
115116
let attribute = span({},
116-
span({className: "attr-name theme-fg-color2"}, `${name}`),
117-
`="`,
118-
span({className: "attr-value theme-fg-color6"}, `${value}`),
119-
`"`
117+
span({className: "attrName"}, name),
118+
span({className: "attrEqual"}, "="),
119+
StringRep({className: "attrValue", object: value}),
120120
);
121121

122122
return arr.concat([" ", attribute]);
123123
}, []);
124124

125125
return [
126-
"<",
126+
span({className: "angleBracket"}, "<"),
127127
nodeNameElement,
128128
...attributeElements,
129-
">",
129+
span({className: "angleBracket"}, ">"),
130130
];
131131
}
132132

packages/devtools-reps/src/reps/reps.css

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
.theme-dark,
77
.theme-light {
88
--number-color: var(--theme-highlight-green);
9-
--string-color: var(--theme-highlight-orange);
9+
--string-color: var(--theme-highlight-red);
1010
--null-color: var(--theme-comment);
11-
--object-color: var(--theme-body-color);
11+
--object-color: var(--theme-highlight-blue);
1212
--caption-color: var(--theme-highlight-blue);
13-
--location-color: var(--theme-content-color1);
13+
--location-color: var(--theme-comment);
1414
--source-link-color: var(--theme-highlight-blue);
15-
--node-color: var(--theme-highlight-bluegrey);
16-
--reference-color: var(--theme-highlight-purple);
15+
--node-color: var(--theme-highlight-purple);
16+
--reference-color: var(--theme-highlight-blue);
17+
--comment-node-color: var(--theme-comment);
1718
}
1819

1920
.theme-firebug {
@@ -73,16 +74,16 @@
7374
color: var(--object-color);
7475
}
7576

76-
.objectBox-Location {
77-
font-style: italic;
77+
.objectBox-Location,
78+
.location {
7879
color: var(--location-color);
7980
}
8081

8182
.objectBox-null,
8283
.objectBox-undefined,
8384
.objectBox-hint,
85+
.objectBox-nan,
8486
.logRowHint {
85-
font-style: italic;
8687
color: var(--null-color);
8788
}
8889

@@ -109,25 +110,42 @@
109110
.objectBox-event,
110111
.objectBox-eventLog,
111112
.objectBox-regexp,
112-
.objectBox-object,
113-
.objectBox-Date {
114-
font-weight: bold;
113+
.objectBox-object {
115114
color: var(--object-color);
116115
white-space: pre-wrap;
117116
}
118117

118+
.objectBox .Date {
119+
color: var(--string-color);
120+
white-space: pre-wrap;
121+
}
122+
119123
/******************************************************************************/
120124

121-
.objectBox-object .nodeName,
122-
.objectBox-NamedNodeMap .nodeName,
123-
.objectBox-NamedNodeMap .objectEqual,
124-
.objectBox-Attr .attrEqual,
125-
.objectBox-Attr .attrTitle {
125+
.objectBox.theme-comment {
126+
color: var(--comment-node-color);
127+
}
128+
129+
.tag-name {
130+
color: var(--object-color);
131+
}
132+
133+
.attrName {
134+
color: var(--string-color);
135+
}
136+
137+
.attrEqual,
138+
.objectEqual {
139+
color: var(--comment-node-color);
140+
}
141+
142+
.attrValue,
143+
.attrValue.objectBox-string {
126144
color: var(--node-color);
127145
}
128146

129-
.objectBox-object .nodeName {
130-
font-weight: normal;
147+
.angleBracket {
148+
color: var(--theme-body-color);
131149
}
132150

133151
/******************************************************************************/
@@ -136,7 +154,7 @@
136154
.objectRightBrace,
137155
.arrayLeftBracket,
138156
.arrayRightBracket {
139-
color: var(--theme-highlight-blue);
157+
color: var(--object-color);
140158
}
141159

142160
/******************************************************************************/
@@ -147,14 +165,12 @@
147165
color: var(--reference-color);
148166
}
149167

150-
[class*="objectBox-"] > .objectTitle {
151-
color: var(--theme-highlight-blue);
152-
font-style: italic;
168+
[class*="objectBox"] > .objectTitle {
169+
color: var(--object-color);
153170
}
154171

155172
.caption {
156-
font-weight: bold;
157-
color: var(--caption-color);
173+
color: var(--caption-color);
158174
}
159175

160176
/******************************************************************************/
@@ -182,7 +198,7 @@
182198
/* Open DOMNode in inspector button */
183199

184200
.open-inspector svg {
185-
fill: rgb(215, 215, 215);
201+
fill: var(--comment-node-color);
186202
height: 16px;
187203
width: 16px;
188204
margin-left: .25em;
@@ -193,11 +209,11 @@
193209
.objectBox-node:hover .open-inspector svg,
194210
.objectBox-textNode:hover .open-inspector svg,
195211
.open-inspector svg:hover {
196-
fill: rgb(65, 175, 230);
212+
fill: var(--theme-highlight-blue);
197213
}
198214

199215
/******************************************************************************/
200216
/* "more…" ellipsis */
201217
.more-ellipsis {
202-
color: var(--theme-comment);
218+
color: var(--comment-node-color);
203219
}

packages/devtools-reps/src/reps/string.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ StringRep.propTypes = {
3030
member: React.PropTypes.any,
3131
cropLimit: React.PropTypes.number,
3232
openLink: React.PropTypes.func,
33+
className: React.PropTypes.string,
3334
};
3435

3536
function StringRep(props) {
3637
let {
38+
className,
3739
cropLimit,
3840
object: text,
3941
member,
@@ -43,7 +45,11 @@ function StringRep(props) {
4345
openLink,
4446
} = props;
4547

46-
let config = {className: "objectBox objectBox-string"};
48+
const classNames = ["objectBox", "objectBox-string"];
49+
if (className) {
50+
classNames.push(className);
51+
}
52+
let config = {className: classNames.join(" ")};
4753
if (style) {
4854
config.style = style;
4955
}

packages/devtools-reps/src/reps/tests/window.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("test Window", () => {
4545
object: stub
4646
}));
4747

48-
expect(renderedComponent.find(".objectPropValue").text()).toEqual("about:newtab");
48+
expect(renderedComponent.find(".location").text()).toEqual("about:newtab");
4949
});
5050

5151
it("renders with expected text in TINY mode", () => {

packages/devtools-reps/src/reps/window.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function WindowRep(props) {
4848
span(config,
4949
getTitle(object),
5050
" ",
51-
span({className: "objectPropValue"},
51+
span({className: "location"},
5252
getLocation(object)
5353
)
5454
)
@@ -57,7 +57,7 @@ function WindowRep(props) {
5757

5858
function getTitle(object) {
5959
let title = object.displayClass || object.class || "Window";
60-
return span({className: "objectBoxTitle"}, title);
60+
return span({className: "objectTitle"}, title);
6161
}
6262

6363
function getLocation(object) {

0 commit comments

Comments
 (0)