Skip to content

Commit 724e4b8

Browse files
committedFeb 27, 2024
add modifiers
1 parent 56575c0 commit 724e4b8

13 files changed

+581
-162
lines changed
 

‎app/components/component-tree-arg.js

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export default class ComponentTreeArg extends Component {
1212

1313
get displayValue() {
1414
if (this.isObject) {
15+
if (this.args.value.inspect) {
16+
if (this.args.value.type === 'function') {
17+
return this.args.value.inspect
18+
.replace(/"/g, '\\"')
19+
.replace('bound ', '')
20+
.replace('{ ... }', '');
21+
}
22+
return truncate(this.args.value.inspect.replace(/"/g, '\\"'));
23+
}
1524
return '...';
1625
} else if (typeof this.args.value === 'string') {
1726
// Escape any interior quotes – we will add the surrounding quotes in the template

‎app/components/component-tree-item.hbs

+18-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323

2424
<code
2525
class="component-tree-item__tag flex whitespace-no-wrap
26+
{{if @item.isClosingTag 'component-tree-item__closing'}}
27+
{{if @item.hasModifiers 'component-tree-item__has_modifier'}}
2628
{{if
27-
@item.isComponent
29+
(or @item.isComponent @item.isModifier @item.isHtmlTag)
2830
(if
2931
@item.isCurlyInvocation
3032
"component-tree-item-classic__bracket"
@@ -37,7 +39,7 @@
3739
}}"
3840
>
3941
{{!-- template-lint-disable no-unbalanced-curlies --}}
40-
{{#if @item.isComponent}}
42+
{{#if (or @item.isComponent @item.isModifier)}}
4143
{{#if @item.isCurlyInvocation}}
4244
<span class="component-name">
4345
{{@item.name}}
@@ -83,6 +85,20 @@
8385
\{{mount "{{@item.name}}"}}
8486
{{else if @item.isRouteTemplate}}
8587
{{@item.name}} route
88+
{{else if @item.isHtmlTag}}
89+
<span class="component-name">
90+
{{@item.name}}
91+
</span>
92+
{{#each-in @item.args.named as |name value|}}
93+
<div class="arg-token flex ml-2">
94+
<span class="key-token">
95+
{{name}}
96+
</span>
97+
={{if (is-string value) "\""}}
98+
<ComponentTreeArg @value={{value}} />
99+
{{if (is-string value) "\""}}
100+
</div>
101+
{{/each-in}}
86102
{{/if}}
87103
</code>
88104
</div>

‎app/components/object-inspector/property.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ export default class ObjectInspectorProperty extends Component<ObjectInspectorPr
119119
}
120120

121121
get cannotEdit() {
122-
if (this.args.model.name === '...' || !this.isCalculated) return true;
123-
return this.isFunction || this.isOverridden || this.readOnly;
122+
if (this.args.model.name === '...' || !this.isCalculated || this.readOnly) return true;
123+
return this.args.model?.value?.type !== 'type-string' && this.args.model?.value?.type !== 'type-number';
124124
}
125125

126126
@action

‎app/controllers/component-tree.js

+48-3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ export default class ComponentTreeController extends Controller {
4848

4949
renderItems.push(item);
5050

51+
if (
52+
item.isHtmlTag &&
53+
renderNode.children.some((c) => c.type === 'modifier')
54+
) {
55+
const idx = renderNode.children.findLastIndex(
56+
(c) => c.type === 'modifier'
57+
);
58+
renderNode.children.splice(idx + 1, 0, {
59+
type: 'placeholder-closing-tag',
60+
id: renderNode.id + '-closing-tag',
61+
name: '',
62+
children: [],
63+
});
64+
}
65+
5166
renderNode.children.forEach((node) => flatten(item, node));
5267
}
5368
};
@@ -301,7 +316,32 @@ class RenderItem {
301316
}
302317

303318
get isComponent() {
304-
return this.renderNode.type === 'component';
319+
return (
320+
this.renderNode.type === 'component' ||
321+
this.renderNode.type === 'remote-element'
322+
);
323+
}
324+
325+
get isModifier() {
326+
return this.renderNode.type === 'modifier';
327+
}
328+
329+
get hasModifiers() {
330+
return this.childItems.some((item) => item.isModifier);
331+
}
332+
333+
get isLastModifier() {
334+
return (
335+
this.parentItem.childItems.findLast((item) => item.isModifier) === this
336+
);
337+
}
338+
339+
get isHtmlTag() {
340+
return this.renderNode.type === 'html-element';
341+
}
342+
343+
get isClosingTag() {
344+
return this.renderNode.type === 'placeholder-closing-tag';
305345
}
306346

307347
get name() {
@@ -313,12 +353,15 @@ class RenderItem {
313353
}
314354

315355
get isCurlyInvocation() {
356+
if (this.isModifier) {
357+
return true;
358+
}
316359
return this.renderNode.args && this.renderNode.args.positional;
317360
}
318361

319362
get hasInstance() {
320363
let { instance } = this.renderNode;
321-
return typeof instance === 'object' && instance !== null;
364+
return typeof instance === 'object' && instance;
322365
}
323366

324367
get instance() {
@@ -330,7 +373,7 @@ class RenderItem {
330373
}
331374

332375
get hasBounds() {
333-
return this.renderNode.bounds !== null;
376+
return this.renderNode.bounds;
334377
}
335378

336379
get isRoot() {
@@ -400,6 +443,7 @@ class RenderItem {
400443
}
401444

402445
@action showPreview() {
446+
if (this.isClosingTag) return;
403447
this.controller.previewing = this.id;
404448
}
405449

@@ -410,6 +454,7 @@ class RenderItem {
410454
}
411455

412456
@action toggleInspection() {
457+
if (this.isClosingTag) return;
413458
if (this.isPinned) {
414459
this.controller.pinned = undefined;
415460
} else {

‎app/styles/component_tree.scss

+13
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@
141141
color: var(--base09);
142142
}
143143

144+
.component-tree-item__has_modifier:after {
145+
content: '' !important;
146+
}
147+
148+
.component-tree-item__closing:before {
149+
content: '>';
150+
margin-left: -13px;
151+
}
152+
153+
.component-tree-item__self-closing:before {
154+
content: '/>';
155+
}
156+
144157
.component-tree-item__bracket:before {
145158
content: '<';
146159
}

‎ember-cli-build.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,18 @@ module.exports = function (defaults) {
381381
if (env === 'test') {
382382
// `ember test` expects the index.html file to be in the
383383
// output directory.
384-
output = mergeTrees([dists.basic, dists.chrome]);
385-
} else {
386384
// Change base tag for running tests in development env.
387385
dists.basic = replace(dists.basic, {
388386
files: ['tests/index.html'],
389387
patterns: [
390388
{
391389
match: /<base.*\/>/,
392-
replacement: '<base href="../" />',
390+
replacement: '',
393391
},
394392
],
395393
});
396-
394+
output = mergeTrees([dists.basic, dists.chrome]);
395+
} else {
397396
dists.testing = mergeTrees([dists.basic, dists.chrome]);
398397

399398
output = mergeTrees([

‎ember_debug/adapters/web-extension.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export default class extends BasicAdapter {
2828
// "clone" them through postMessage unless they are converted to a
2929
// native array.
3030
options = deepClone(options);
31-
this._chromePort.postMessage(options);
31+
try {
32+
this._chromePort.postMessage(options);
33+
} catch (e) {
34+
console.log('failed to send message', e);
35+
}
3236
}
3337

3438
/**

0 commit comments

Comments
 (0)
Failed to load comments.