File tree Expand file tree Collapse file tree 4 files changed +85
-6
lines changed
sandbox/app/components/simple-list
tests/acceptance/sandbox/api Expand file tree Collapse file tree 4 files changed +85
-6
lines changed Original file line number Diff line number Diff line change @@ -84,26 +84,29 @@ const RESOLVED_TYPES = [
84
84
function generateResolvedTypeNavigationItems ( modules , type ) {
85
85
let items = modules . map ( m => {
86
86
let segments = m . file . split ( '/' ) ;
87
- let fileName = segments . pop ( ) ;
87
+ segments = segments . slice ( segments . indexOf ( type ) + 1 ) ;
88
88
89
- if ( type . match ( fileName ) ) {
90
- fileName = segments . pop ( ) ;
89
+ if ( type . match ( segments [ segments . length - 1 ] ) ) {
90
+ segments . pop ( ) ;
91
91
}
92
92
93
+ let path = segments . join ( '/' ) ;
93
94
let name ;
95
+
94
96
if ( [ 'components' , 'helpers' ] . includes ( type ) ) {
95
- name = `{{${ fileName } }}` ;
97
+ name = `{{${ path } }}` ;
96
98
} else {
99
+ let fileName = segments . pop ( ) ;
97
100
name = _ . upperFirst ( _ . camelCase ( fileName ) ) ;
98
101
}
99
102
100
103
return {
101
- path : `${ type } /${ fileName } ` ,
104
+ path : `${ type } /${ path } ` ,
102
105
name
103
106
} ;
104
107
} ) ;
105
108
106
- return _ . sortBy ( items , [ 'name ' ] ) ;
109
+ return _ . sortBy ( items , [ 'path ' ] ) ;
107
110
}
108
111
109
112
function generateModuleNavigationItems ( modules , type ) {
Original file line number Diff line number Diff line change
1
+ /** @documenter esdoc */
2
+
3
+ import Component from '@ember/component' ;
4
+ import { argument } from '@ember-decorators/argument' ;
5
+ import { type } from '@ember-decorators/argument/type' ;
6
+
7
+ /**
8
+ Pretty cool component, right?
9
+
10
+ To use it, you could enter the following in your template:
11
+
12
+ ```handlebars
13
+ {{#simple-list items=(arr 1 2 3) as |item|}}
14
+ {{#item as |value|}}
15
+ {{value}}
16
+ {{/item}}
17
+ {{/simple-list}}
18
+ ```
19
+
20
+ @yield {SimpleListItem} item
21
+ */
22
+ export default class SimpleList extends Component {
23
+ /**
24
+ The items for the list
25
+ */
26
+ @argument
27
+ @type ( 'object' )
28
+ items ;
29
+ }
Original file line number Diff line number Diff line change
1
+ /** @documenter esdoc */
2
+
3
+ import Component from '@ember/component' ;
4
+ import { argument } from '@ember-decorators/argument' ;
5
+ import { type } from '@ember-decorators/argument/type' ;
6
+
7
+ /**
8
+ Pretty cool component, right?
9
+
10
+ To use it, you could enter the following in your template:
11
+
12
+ ```handlebars
13
+ {{simple-list/item value=1}}
14
+ ```
15
+
16
+ @yield {object} value
17
+ */
18
+ export default class SimpleListItem extends Component {
19
+ /**
20
+ The count
21
+ */
22
+ @argument
23
+ @type ( 'object' )
24
+ value ;
25
+ }
Original file line number Diff line number Diff line change
1
+ import { module , test } from 'qunit' ;
2
+ import { setupApplicationTest } from 'ember-qunit' ;
3
+ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage' ;
4
+ import { currentURL , visit } from '@ember/test-helpers' ;
5
+
6
+ import modulePage from '../../../pages/api/module' ;
7
+
8
+ module ( 'Acceptance | API | components' , function ( hooks ) {
9
+ setupApplicationTest ( hooks ) ;
10
+ setupMirage ( hooks ) ;
11
+
12
+ test ( 'nested components work' , async function ( assert ) {
13
+ await visit ( '/sandbox' ) ;
14
+ await modulePage . navItems . findOne ( { text : `{{simple-list}}` } ) . click ( ) ;
15
+
16
+ assert . equal ( currentURL ( ) , `/sandbox/api/components/simple-list` , 'correct url' ) ;
17
+
18
+ await modulePage . navItems . findOne ( { text : `{{simple-list/item}}` } ) . click ( ) ;
19
+
20
+ assert . equal ( currentURL ( ) , `/sandbox/api/components/simple-list/item` , 'correct url' ) ;
21
+ } ) ;
22
+ } ) ;
You can’t perform that action at this time.
0 commit comments