Skip to content

Commit 4a39c04

Browse files
committed
[bugfix] Fixes styling for new Meta Data panel
Fixes the new metadata panel, ensuring its only shown when it actually has content. Refactored some of the API docs components to be simpler, more reusable, and drop custom styles in general as well.
1 parent 9a08bd3 commit 4a39c04

File tree

18 files changed

+184
-209
lines changed

18 files changed

+184
-209
lines changed

addon/components/api/x-class/template.hbs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@
33
{{! wrapping in a div seems to work around https://github.com/ember-learn/ember-cli-addon-docs/issues/7 }}
44
<div data-test-class-description>{{{class.description}}}</div>
55

6-
{{#if hasContents}}
7-
{{#if hasToggles}}
8-
{{api/x-toggles
9-
toggles=(hash
10-
inherited=(if component.hasInherited showInherited)
11-
protected=(if component.hasProtected showProtected)
12-
private=(if component.hasPrivate showPrivate)
13-
deprecated=(if component.hasDeprecated showDeprecated)
14-
)
15-
}}
16-
{{/if}}
6+
{{#if (or class.exportType hasToggles)}}
7+
{{#api/x-meta-panel as |panel|}}
8+
{{#if class.exportType}}
9+
{{#panel.header}}
10+
Import Path
11+
{{/panel.header}}
12+
13+
{{api/x-import-path item=class}}
14+
{{/if}}
15+
16+
{{#if hasToggles}}
17+
{{#panel.header}}
18+
Show
19+
{{/panel.header}}
1720

21+
{{#if hasToggles}}
22+
{{api/x-toggles
23+
toggles=(hash
24+
inherited=(if class.hasInherited showInherited)
25+
protected=(if class.hasProtected showProtected)
26+
private=(if class.hasPrivate showPrivate)
27+
deprecated=(if class.hasDeprecated showDeprecated)
28+
)
29+
}}
30+
{{/if}}
31+
{{/if}}
32+
{{/api/x-meta-panel}}
33+
{{/if}}
34+
35+
{{#if hasContents}}
1836
{{api/x-sections
1937
sections=(hash
2038
constructors=class.constructors

addon/components/api/x-component/template.hbs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
{{! wrapping in a div seems to work around https://github.com/ember-learn/ember-cli-addon-docs/issues/7 }}
44
<div data-test-component-name>{{{component.description}}}</div>
55

6-
{{#if hasContents}}
7-
{{#if hasToggles}}
8-
{{api/x-toggles
9-
toggles=(hash
10-
inherited=(if component.hasInherited showInherited)
11-
internal=(if component.hasInternal showInternal)
12-
protected=(if component.hasProtected showProtected)
13-
private=(if component.hasPrivate showPrivate)
14-
deprecated=(if component.hasDeprecated showDeprecated)
15-
)
6+
{{#if hasToggles}}
7+
{{#api/x-meta-panel as |panel|}}
8+
{{#panel.header}}
9+
Show
10+
{{/panel.header}}
11+
12+
{{#if hasToggles}}
13+
{{api/x-toggles
14+
toggles=(hash
15+
inherited=(if component.hasInherited showInherited)
16+
internal=(if component.hasInternal showInternal)
17+
protected=(if component.hasProtected showProtected)
18+
private=(if component.hasPrivate showPrivate)
19+
deprecated=(if component.hasDeprecated showDeprecated)
20+
)
1621

17-
onToggle=(action 'updateFilter')
18-
}}
19-
{{/if}}
22+
onToggle=(action 'updateFilter')
23+
}}
24+
{{/if}}
25+
{{/api/x-meta-panel}}
26+
{{/if}}
2027

28+
29+
{{#if hasContents}}
2130
{{api/x-sections
2231
sections=(hash
2332
constructors=constructors
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import Component from '@ember/component';
2-
import layout from './template';
2+
import hbs from 'htmlbars-inline-precompile';
33

44
export default Component.extend({
5-
layout,
6-
tagName: ''
5+
tagName: '',
6+
layout: hbs`
7+
<div class="import-path mb-6 font-mono" data-test-import-path>
8+
<span class="hljs-keyword">import</span>
9+
10+
{{#if (eq item.exportType "default")}}
11+
{{item.name}}
12+
{{else}}
13+
{ {{item.name}} }
14+
{{/if}}
15+
16+
<span class="hljs-keyword">from</span>
17+
<span class="hljs-string">'{{item.file}}'</span>;
18+
</div>
19+
`,
720
});

addon/components/api/x-import-path/style.scss

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

addon/components/api/x-import-path/template.hbs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Component from '@ember/component';
2+
import hbs from 'htmlbars-inline-precompile';
3+
4+
export default Component.extend({
5+
tagName: '',
6+
layout: hbs`
7+
<div class="px-6 pt-3 mt-4 border border-grey-light rounded text-sm">
8+
{{yield (hash
9+
header=(component 'api/x-meta-panel/header')
10+
)}}
11+
</div>
12+
`,
13+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Component from '@ember/component';
2+
import hbs from 'htmlbars-inline-precompile';
3+
4+
export default Component.extend({
5+
tagName: '',
6+
layout: hbs`
7+
<h4 class="mb-2 text-grey font-bold tracking-wide uppercase text-xs">
8+
{{yield}}
9+
</h4>
10+
`,
11+
});

addon/components/api/x-params/style.scss

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

addon/components/api/x-params/template.hbs

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export default Component.extend({
1010
* Params shouldn't be displayed when there are no descriptions and no subparams,
1111
* because the information is already displayed in the type signature and redundant
1212
*/
13-
shouldDisplayParams: computed('params.[]', function() {
14-
let params = this.get('params') || [];
13+
shouldDisplayParams: computed('item.params.[]', function() {
14+
let params = this.get('item.params') || [];
1515

1616
return params.some(p => p.description || p.name.includes('.'));
17-
})
17+
}),
1818
});

0 commit comments

Comments
 (0)