Skip to content

Use colocated components #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import config from 'ember-get-config';

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

import layout from './template';

export default Component.extend({
layout,
tagName: '',

showImportPaths,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { alias, or } from '@ember/object/computed';
import { capitalize } from '@ember/string';
import { memberFilter } from '../../../utils/computed';

import layout from './template';

export default Component.extend({
layout,
tagName: '',

showInherited: false,
Expand Down
18 changes: 18 additions & 0 deletions addon/components/api/x-import-path.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="import-path docs-mb-6" data-test-import-path>
<pre class="docs-md__code docs-whitespace-no-wrap">
<span class="hljs-keyword">
import
</span>

{{#if (eq @item.exportType "default")}}
{{@item.name}}
{{else}}
{ {{@item.name}} }
{{/if}}

<span class="hljs-keyword">
from
</span>
<span class="hljs-string">'{{@item.file}}'</span>;
</pre>
</div>
22 changes: 0 additions & 22 deletions addon/components/api/x-import-path/component.js

This file was deleted.

3 changes: 3 additions & 0 deletions addon/components/api/x-meta-panel/header.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h4 class="docs-mb-2 docs-text-grey docs-font-bold docs-tracking-wide docs-uppercase docs-text-xxs">
{{yield}}
</h4>
11 changes: 0 additions & 11 deletions addon/components/api/x-meta-panel/header/component.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { hbs } from 'ember-cli-htmlbars';
import Component from '@ember/component';

export default Component.extend({
tagName: '',
layout: hbs`
<div class="docs-px-6 docs-pt-3 docs-mt-4 docs-border docs-border-grey-light docs-rounded docs-text-xs">
{{yield (hash
header=(component 'api/x-meta-panel/header')
)}}
</div>
`,
});
</div>
7 changes: 0 additions & 7 deletions addon/components/api/x-module/component.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Api::XSections @sections={{hash
<Api::XSections
@sections={{
hash
classes=@module.classes
components=@module.components
functions=@module.functions
variables=@module.variables
}} />
}}
/>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from './template';
import config from 'ember-get-config';

const { showImportPaths } = config['ember-cli-addon-docs'];
Expand All @@ -10,7 +9,6 @@ const { showImportPaths } = config['ember-cli-addon-docs'];
@hide
*/
export default Component.extend({
layout,
tagName: '',

showImportPaths,
Expand Down
13 changes: 13 additions & 0 deletions addon/components/api/x-sections.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{#each-in @sections as |sectionName items|}}
{{#if items}}
<section data-test-api-section class="item-section">
<h2 data-test-section-header={{sectionName}} class="docs-h2">
{{capitalize sectionName}}
</h2>

{{#each items as |item|}}
<Api::XSection @item={{item}} />
{{/each}}
</section>
{{/if}}
{{/each-in}}
21 changes: 0 additions & 21 deletions addon/components/api/x-sections/component.js

This file was deleted.

7 changes: 0 additions & 7 deletions addon/components/api/x-toggles/component.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
classNameBindings,
tagName,
layout as templateLayout,
} from '@ember-decorators/component';
import { classNameBindings, tagName } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from './template';
import hljs from 'highlight.js/lib/core';

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

@tagName('pre')
@classNameBindings('language')
@templateLayout(layout)
export default class DocsCodeHighlight extends Component {
didInsertElement() {
super.didInsertElement(...arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { tagName, layout as templateLayout } from '@ember-decorators/component';
import { tagName } from '@ember-decorators/component';
import { action, computed } from '@ember/object';
import { A } from '@ember/array';
import Component from '@ember/component';
import layout from './template';

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

@templateLayout(layout)
@tagName('')
export default class DocsDemo extends Component {
// eslint-disable-next-line ember/classic-decorator-hooks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
classNames,
layout as templateLayout,
} from '@ember-decorators/component';
import { classNames } from '@ember-decorators/component';
import Component from '@ember/component';
import layout from './template';

@templateLayout(layout)
@classNames('docs-p-4')
export default class XExample extends Component {
// eslint-disable-next-line ember/classic-decorator-hooks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Component from '@ember/component';
import layout from './template';
import config from 'ember-get-config';
import { computed } from '@ember/object';
import { classify } from '@ember/string';
Expand Down Expand Up @@ -31,7 +30,6 @@ const { projectName, projectHref, latestVersionName } =
@yield {Component} header.link
*/
export default Component.extend({
layout,
tagName: '',

projectVersion: service(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Component from '@ember/component';
import layout from './template';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';

export default Component.extend({
layout,
tagName: '',

router: service(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import Component from '@ember/component';
import template from './template';
import { task } from 'ember-concurrency';
import config from 'ember-get-config';
import { getOwner } from '@ember/application';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { classNames, layout } from '@ember-decorators/component';
import { classNames } from '@ember-decorators/component';
import { formElementHasFocus } from 'ember-cli-addon-docs/keyboard-config';

const projectName = config['ember-cli-addon-docs'].projectName;

@classNames('docs-ml-auto')
@layout(template)
export default class DocsHeaderSearchBoxComponent extends Component {
@service store;

query = null;

constructor() {
super(...arguments);

const config =
getOwner(this).resolveRegistration('config:environment')[
'ember-cli-addon-docs'
];
const { projectName } = config;

this.set('projectName', projectName);
}

didInsertElement() {
super.didInsertElement(...arguments);

Expand All @@ -29,7 +37,7 @@ export default class DocsHeaderSearchBoxComponent extends Component {
// project.
@task
*fetchProject() {
yield this.store.findRecord('project', projectName);
yield this.store.findRecord('project', this.projectName);
}

@action
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import Component from '@ember/component';
import layout from './template';
import { computed } from '@ember/object';
import { bool } from '@ember/object/computed';

export default Component.extend({
layout,

result: null,
onClick() {},
onMouseEnter() {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { action } from '@ember/object';
import template from './template';
import { keyResponder, onKey } from 'ember-keyboard';
import { layout } from '@ember-decorators/component';
import { computed } from '@ember/object';
import { task } from 'ember-concurrency';
import config from 'ember-get-config';

const projectName = config['ember-cli-addon-docs'].projectName;
import { getOwner } from '@ember/application';

@keyResponder
@layout(template)
export default class DocsHeaderSearchResultsComponent extends Component {
@service docsSearch;
@service router;
Expand All @@ -20,6 +15,18 @@ export default class DocsHeaderSearchResultsComponent extends Component {
query = null; // passed in
selectedIndex = null;

constructor() {
super(...arguments);

const config =
getOwner(this).resolveRegistration('config:environment')[
'ember-cli-addon-docs'
];
const { projectName } = config;

this.set('projectName', projectName);
}

didInsertElement() {
super.didInsertElement(...arguments);

Expand All @@ -34,7 +41,7 @@ export default class DocsHeaderSearchResultsComponent extends Component {
}

get project() {
return this.store.peekRecord('project', projectName);
return this.store.peekRecord('project', this.projectName);
}

@computed('query')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import layout from './template';
import { reads } from '@ember/object/computed';
import { computed } from '@ember/object';
import { A } from '@ember/array';
Expand All @@ -11,8 +10,6 @@ import { getOwner } from '@ember/application';
export default Component.extend({
projectVersion: service(),

layout,

init() {
this._super(...arguments);
const config =
Expand Down
Loading