-
-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathcomponent.js
73 lines (57 loc) · 1.72 KB
/
component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import Component from '@ember/component';
import layout from './template';
import config from 'dummy/config/environment';
import { computed } from '@ember/object';
import { classify } from '@ember/string';
import { addonLogo } from 'ember-cli-addon-docs/utils/computed';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
const { projectName, projectHref, latestVersionName } = config['ember-cli-addon-docs'];
/**
Render a header showing a link to your documentation, your project logo, a
search bar, and a link to your repo on GitHub.
Yields a `link` contextual component which can be used to add additional
header links.
```hbs
{{#docs-header as |header|}}
{{#header.link 'sandbox'}}
Sandbox
{{/header.link}}
{{/docs-header}}
```
@class DocsHeader
@public
@yield {Hash} header
@yield {Component} header.link
*/
export default Component.extend({
layout,
tagName: '',
projectVersion: service(),
store: service(),
projectHref,
latestVersionName,
didInsertElement() {
this._super(...arguments);
this.get('projectVersion').loadAvailableVersions();
},
logo: addonLogo(projectName),
name: computed(function() {
let name = projectName;
name = name.replace('ember-data-', '');
name = name.replace('ember-cli-', '');
name = name.replace('ember-', '');
return classify(name);
}),
currentVersion: reads('projectVersion.currentVersion'),
project: computed('store', function() {
return this.get('store').peekRecord('project', projectName);
}),
actions: {
didVisitPage() {
this.set('query', null);
let search = document.querySelector('[data-search-box-input]');
search.blur();
}
}
});