Skip to content

Commit 8483b3f

Browse files
committed
class-field-desc: update to glimmer
Let's update the ClassFieldDescription component to extend glimmer/component instead of ember/component. Glimmer components offer a bunch of various advantages over classic components and are the direction that ember is heading in general.
1 parent e4675f1 commit 8483b3f

File tree

3 files changed

+88
-84
lines changed

3 files changed

+88
-84
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<section class="{{@type}}">
2+
{{!-- TODO: Fix this link for a11y --}}
3+
<h3 class="class-field-description--link" data-anchor="{{@field.name}}" role="link" {{on "click" (fn this.updateAnchor @field.name)}}>
4+
<a class="anchor" {{!-- template-lint-disable link-href-attributes --}}>
5+
{{svg-jar 'fa-link' class="class-field-description--link-hover" width="20px" height="20px"}}
6+
</a>
7+
<span class="{{@type}}-name">{{@field.name}}</span>
8+
{{#if @field.params}}
9+
<span class="args">
10+
({{join ", " (map-by "name" @field.params)}})
11+
</span>
12+
{{/if}}
13+
{{#if @field.return}}
14+
<span class="return-type">{{@field.return.type}}</span>
15+
{{/if}}
16+
{{#if @field.access}}
17+
<span class="access">{{@field.access}}</span>
18+
{{/if}}
19+
{{#if @field.deprecated}}
20+
<span class="access">deprecated</span>
21+
{{/if}}
22+
</h3>
23+
{{#if @model.module}}
24+
<div class="attributes">
25+
<div class="attribute">
26+
<span class="attribute-label">Module:</span>
27+
<span class="attribute-value"><LinkTo @route="project-version.modules.module" @models={{array @model.projectVersion.compactVersion @model.module}}>{{@model.module}}</LinkTo></span>
28+
</div>
29+
</div>
30+
{{/if}}
31+
<p class="github-link" data-test-file={{@field.file}}>
32+
{{#if @field.inherited}}
33+
Inherited from
34+
<a href="{{github-link @model.project.id @model.projectVersion.version @field.file @field.line}}" target="_blank" rel="noopener noreferrer">
35+
{{@field.inheritedFrom}} {{@field.file}}:{{@field.line}}
36+
</a>
37+
{{else}}
38+
Defined in
39+
<a href="{{github-link @model.project.id @model.projectVersion.version @field.file @field.line}}" target="_blank" rel="noopener noreferrer">
40+
{{@field.file}}:{{@field.line}}
41+
</a>
42+
{{/if}}
43+
</p>
44+
{{#if @field.since}}
45+
<p class="field-since">
46+
Available since v{{@field.since}}
47+
</p>
48+
{{/if}}
49+
{{#if (and (eq @field.static 1) (eq @field.itemtype "method") this.hasImportExample)}}
50+
<ImportExample @item={{concat "{ " @field.name " }"}} @package={{@field.class}} />
51+
{{/if}}
52+
<dl class="parameters">
53+
{{#each @field.params as |param|}}
54+
<div class="parameter">
55+
<dt>{{param.name}}</dt>
56+
<dd class="parameter-type">{{param.type}}</dd>
57+
<dd>{{param.description}}</dd>
58+
{{#if param.props}}
59+
<dl class="parameters">
60+
{{#each param.props as |prop|}}
61+
<div class="prop">
62+
<dt>{{prop.name}}</dt>
63+
<dd class="parameter-type">{{prop.type}}</dd>
64+
<dd>{{prop.description}}</dd>
65+
</div>
66+
{{/each}}
67+
</dl>
68+
{{/if}}
69+
</div>
70+
{{/each}}
71+
{{#if @field.return}}
72+
<div class="return">
73+
<dt>returns</dt>
74+
<dd class="return-type">{{@field.return.type}}</dd>
75+
<dd>{{@field.return.description}}</dd>
76+
</div>
77+
{{/if}}
78+
</dl>
79+
{{html-safe @field.description}}
80+
</section>
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { inject as service } from '@ember/service';
2-
import Component from '@ember/component';
2+
import Component from '@glimmer/component';
3+
import { action } from '@ember/object';
34

45
export default class ClassFieldDescription extends Component {
56
@service
67
legacyModuleMappings;
78

89
get hasImportExample() {
910
return this.legacyModuleMappings.hasFunctionMapping(
10-
this.field.name,
11-
this.field.class
11+
this.args.field.name,
12+
this.args.field.class
1213
);
1314
}
1415

@@ -18,5 +19,8 @@ export default class ClassFieldDescription extends Component {
1819
* @method updateAnchor
1920
* @method fieldName String The name representing the field that was clicked.
2021
*/
21-
updateAnchor() {}
22+
@action
23+
updateAnchor(fieldName) {
24+
this.args.updateAnchor?.(fieldName);
25+
}
2226
}

app/templates/components/class-field-description.hbs

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)