Skip to content

Commit bbf4576

Browse files
Use colocated components (#934)
* Start removing ember-get-config * Remove magic auto export, add adapters to app * Add api components to exports * Use colocated components * Fix imports * Reset lots of things * Update x-import-path.hbs * Fix lint
1 parent ed004b5 commit bbf4576

File tree

125 files changed

+210
-298
lines changed

Some content is hidden

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

125 files changed

+210
-298
lines changed

addon/components/api/x-class/component.js renamed to addon/components/api/x-class/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import config from 'ember-get-config';
77

88
const { showImportPaths } = config['ember-cli-addon-docs'];
99

10-
import layout from './template';
11-
1210
export default Component.extend({
13-
layout,
1411
tagName: '',
1512

1613
showImportPaths,

addon/components/api/x-component/component.js renamed to addon/components/api/x-component/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { alias, or } from '@ember/object/computed';
44
import { capitalize } from '@ember/string';
55
import { memberFilter } from '../../../utils/computed';
66

7-
import layout from './template';
8-
97
export default Component.extend({
10-
layout,
118
tagName: '',
129

1310
showInherited: false,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="import-path docs-mb-6" data-test-import-path>
2+
<pre class="docs-md__code docs-whitespace-no-wrap">
3+
<span class="hljs-keyword">
4+
import
5+
</span>
6+
7+
{{#if (eq @item.exportType "default")}}
8+
{{@item.name}}
9+
{{else}}
10+
{ {{@item.name}} }
11+
{{/if}}
12+
13+
<span class="hljs-keyword">
14+
from
15+
</span>
16+
<span class="hljs-string">'{{@item.file}}'</span>;
17+
</pre>
18+
</div>

addon/components/api/x-import-path/component.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h4 class="docs-mb-2 docs-text-grey docs-font-bold docs-tracking-wide docs-uppercase docs-text-xxs">
2+
{{yield}}
3+
</h4>

addon/components/api/x-meta-panel/header/component.js

Lines changed: 0 additions & 11 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import { hbs } from 'ember-cli-htmlbars';
2-
import Component from '@ember/component';
3-
4-
export default Component.extend({
5-
tagName: '',
6-
layout: hbs`
71
<div class="docs-px-6 docs-pt-3 docs-mt-4 docs-border docs-border-grey-light docs-rounded docs-text-xs">
82
{{yield (hash
93
header=(component 'api/x-meta-panel/header')
104
)}}
11-
</div>
12-
`,
13-
});
5+
</div>

addon/components/api/x-module/component.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
<Api::XSections @sections={{hash
1+
<Api::XSections
2+
@sections={{
3+
hash
24
classes=@module.classes
35
components=@module.components
46
functions=@module.functions
57
variables=@module.variables
6-
}} />
8+
}}
9+
/>

addon/components/api/x-section/component.js renamed to addon/components/api/x-section/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Component from '@ember/component';
22
import { computed } from '@ember/object';
3-
import layout from './template';
43
import config from 'ember-get-config';
54

65
const { showImportPaths } = config['ember-cli-addon-docs'];
@@ -10,7 +9,6 @@ const { showImportPaths } = config['ember-cli-addon-docs'];
109
@hide
1110
*/
1211
export default Component.extend({
13-
layout,
1412
tagName: '',
1513

1614
showImportPaths,

addon/components/api/x-sections.hbs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{#each-in @sections as |sectionName items|}}
2+
{{#if items}}
3+
<section data-test-api-section class="item-section">
4+
<h2 data-test-section-header={{sectionName}} class="docs-h2">
5+
{{capitalize sectionName}}
6+
</h2>
7+
8+
{{#each items as |item|}}
9+
<Api::XSection @item={{item}} />
10+
{{/each}}
11+
</section>
12+
{{/if}}
13+
{{/each-in}}

addon/components/api/x-sections/component.js

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

addon/components/api/x-toggles/component.js

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

addon/components/docs-code-highlight/component.js renamed to addon/components/docs-code-highlight/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {
2-
classNameBindings,
3-
tagName,
4-
layout as templateLayout,
5-
} from '@ember-decorators/component';
1+
import { classNameBindings, tagName } from '@ember-decorators/component';
62
import Component from '@ember/component';
7-
import layout from './template';
83
import hljs from 'highlight.js/lib/core';
94

105
// Installed languages
@@ -34,7 +29,6 @@ hljs.registerLanguage('ts', typescript);
3429

3530
@tagName('pre')
3631
@classNameBindings('language')
37-
@templateLayout(layout)
3832
export default class DocsCodeHighlight extends Component {
3933
didInsertElement() {
4034
super.didInsertElement(...arguments);

addon/components/docs-demo/component.js renamed to addon/components/docs-demo/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { tagName, layout as templateLayout } from '@ember-decorators/component';
1+
import { tagName } from '@ember-decorators/component';
22
import { action, computed } from '@ember/object';
33
import { A } from '@ember/array';
44
import Component from '@ember/component';
5-
import layout from './template';
65

76
/**
87
A demo component that can be used to demonstrate code samples. Comes
@@ -29,7 +28,6 @@ import layout from './template';
2928
@yield {Component} demo.liveExample
3029
*/
3130

32-
@templateLayout(layout)
3331
@tagName('')
3432
export default class DocsDemo extends Component {
3533
// eslint-disable-next-line ember/classic-decorator-hooks

addon/components/docs-demo/x-example/component.js renamed to addon/components/docs-demo/x-example/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import {
2-
classNames,
3-
layout as templateLayout,
4-
} from '@ember-decorators/component';
1+
import { classNames } from '@ember-decorators/component';
52
import Component from '@ember/component';
6-
import layout from './template';
73

8-
@templateLayout(layout)
94
@classNames('docs-p-4')
105
export default class XExample extends Component {
116
// eslint-disable-next-line ember/classic-decorator-hooks

addon/components/docs-header/component.js renamed to addon/components/docs-header/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Component from '@ember/component';
2-
import layout from './template';
32
import config from 'ember-get-config';
43
import { computed } from '@ember/object';
54
import { classify } from '@ember/string';
@@ -31,7 +30,6 @@ const { projectName, projectHref, latestVersionName } =
3130
@yield {Component} header.link
3231
*/
3332
export default Component.extend({
34-
layout,
3533
tagName: '',
3634

3735
projectVersion: service(),

addon/components/docs-header/link/component.js renamed to addon/components/docs-header/link/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import Component from '@ember/component';
2-
import layout from './template';
32
import { inject as service } from '@ember/service';
43
import { computed } from '@ember/object';
54

65
export default Component.extend({
7-
layout,
86
tagName: '',
97

108
router: service(),

addon/components/docs-header/search-box/component.js renamed to addon/components/docs-header/search-box/index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import Component from '@ember/component';
2-
import template from './template';
32
import { task } from 'ember-concurrency';
4-
import config from 'ember-get-config';
3+
import { getOwner } from '@ember/application';
54
import { action } from '@ember/object';
65
import { inject as service } from '@ember/service';
7-
import { classNames, layout } from '@ember-decorators/component';
6+
import { classNames } from '@ember-decorators/component';
87
import { formElementHasFocus } from 'ember-cli-addon-docs/keyboard-config';
98

10-
const projectName = config['ember-cli-addon-docs'].projectName;
11-
129
@classNames('docs-ml-auto')
13-
@layout(template)
1410
export default class DocsHeaderSearchBoxComponent extends Component {
1511
@service store;
1612

1713
query = null;
1814

15+
constructor() {
16+
super(...arguments);
17+
18+
const config =
19+
getOwner(this).resolveRegistration('config:environment')[
20+
'ember-cli-addon-docs'
21+
];
22+
const { projectName } = config;
23+
24+
this.set('projectName', projectName);
25+
}
26+
1927
didInsertElement() {
2028
super.didInsertElement(...arguments);
2129

@@ -29,7 +37,7 @@ export default class DocsHeaderSearchBoxComponent extends Component {
2937
// project.
3038
@task
3139
*fetchProject() {
32-
yield this.store.findRecord('project', projectName);
40+
yield this.store.findRecord('project', this.projectName);
3341
}
3442

3543
@action

addon/components/docs-header/search-result/component.js renamed to addon/components/docs-header/search-result/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import Component from '@ember/component';
2-
import layout from './template';
32
import { computed } from '@ember/object';
43
import { bool } from '@ember/object/computed';
54

65
export default Component.extend({
7-
layout,
8-
96
result: null,
107
onClick() {},
118
onMouseEnter() {},

addon/components/docs-header/search-results/component.js renamed to addon/components/docs-header/search-results/index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { inject as service } from '@ember/service';
22
import Component from '@ember/component';
33
import { action } from '@ember/object';
4-
import template from './template';
54
import { keyResponder, onKey } from 'ember-keyboard';
6-
import { layout } from '@ember-decorators/component';
75
import { computed } from '@ember/object';
86
import { task } from 'ember-concurrency';
9-
import config from 'ember-get-config';
10-
11-
const projectName = config['ember-cli-addon-docs'].projectName;
7+
import { getOwner } from '@ember/application';
128

139
@keyResponder
14-
@layout(template)
1510
export default class DocsHeaderSearchResultsComponent extends Component {
1611
@service docsSearch;
1712
@service router;
@@ -20,6 +15,18 @@ export default class DocsHeaderSearchResultsComponent extends Component {
2015
query = null; // passed in
2116
selectedIndex = null;
2217

18+
constructor() {
19+
super(...arguments);
20+
21+
const config =
22+
getOwner(this).resolveRegistration('config:environment')[
23+
'ember-cli-addon-docs'
24+
];
25+
const { projectName } = config;
26+
27+
this.set('projectName', projectName);
28+
}
29+
2330
didInsertElement() {
2431
super.didInsertElement(...arguments);
2532

@@ -34,7 +41,7 @@ export default class DocsHeaderSearchResultsComponent extends Component {
3441
}
3542

3643
get project() {
37-
return this.store.peekRecord('project', projectName);
44+
return this.store.peekRecord('project', this.projectName);
3845
}
3946

4047
@computed('query')

addon/components/docs-header/version-selector/component.js renamed to addon/components/docs-header/version-selector/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Component from '@ember/component';
22
import { inject as service } from '@ember/service';
3-
import layout from './template';
43
import { reads } from '@ember/object/computed';
54
import { computed } from '@ember/object';
65
import { A } from '@ember/array';
@@ -11,8 +10,6 @@ import { getOwner } from '@ember/application';
1110
export default Component.extend({
1211
projectVersion: service(),
1312

14-
layout,
15-
1613
init() {
1714
this._super(...arguments);
1815
const config =

0 commit comments

Comments
 (0)