diff --git a/addon/components/api/x-class/component.js b/addon/components/api/x-class/component.js index 0f984abbf..37456f5e2 100644 --- a/addon/components/api/x-class/component.js +++ b/addon/components/api/x-class/component.js @@ -1,5 +1,6 @@ import Component from '@ember/component'; import { computed } from '@ember/object'; +import { or } from '@ember/object/computed'; import { capitalize } from '@ember/string'; import { memberFilter } from '../../../utils/computed'; @@ -7,6 +8,7 @@ import layout from './template'; export default Component.extend({ layout, + tagName: '', showInherited: false, showProtected: false, @@ -17,6 +19,13 @@ export default Component.extend({ methods: memberFilter('class', 'methods'), fields: memberFilter('class', 'fields'), + hasToggles: or( + 'component.hasInherited', + 'component.hasProtected', + 'component.hasPrivate', + 'component.hasDeprecated', + ), + hasContents: computed('class', { get() { let klass = this.get('class'); diff --git a/addon/components/api/x-class/template.hbs b/addon/components/api/x-class/template.hbs index f2b5dc8b7..3ff6e124d 100644 --- a/addon/components/api/x-class/template.hbs +++ b/addon/components/api/x-class/template.hbs @@ -4,32 +4,23 @@
{{{class.description}}}
{{#if hasContents}} -
- {{api/x-index - options=(hash - inherited=inherited - protected=protected - private=private - deprecated=deprecated - ) - - onOptionToggle=(action 'updateFilter') - - sections=(hash - constructors=constructors - fields=fields - accessors=accessors - methods=methods + {{#if hasToggles}} + {{api/x-toggles + toggles=(hash + inherited=(if component.hasInherited showInherited) + protected=(if component.hasProtected showProtected) + private=(if component.hasPrivate showPrivate) + deprecated=(if component.hasDeprecated showDeprecated) ) }} + {{/if}} - {{api/x-sections - sections=(hash - constructors=class.constructors - fields=class.fields - accessors=class.accessors - methods=class.methods - ) - }} -
+ {{api/x-sections + sections=(hash + constructors=class.constructors + fields=class.fields + accessors=class.accessors + methods=class.methods + ) + }} {{/if}} diff --git a/addon/components/api/x-component/component.js b/addon/components/api/x-component/component.js index a1660c3c3..22a062554 100644 --- a/addon/components/api/x-component/component.js +++ b/addon/components/api/x-component/component.js @@ -1,6 +1,6 @@ import Component from '@ember/component'; import { computed } from '@ember/object'; -import { alias } from '@ember/object/computed'; +import { alias, or } from '@ember/object/computed'; import { capitalize } from '@ember/string'; import { memberFilter } from '../../../utils/computed'; @@ -8,6 +8,7 @@ import layout from './template'; export default Component.extend({ layout, + tagName: '', showInherited: false, showInternal: false, @@ -22,6 +23,14 @@ export default Component.extend({ methods: memberFilter('component', 'methods'), fields: memberFilter('component', 'fields'), + hasToggles: or( + 'component.hasInherited', + 'component.hasInternal', + 'component.hasProtected', + 'component.hasPrivate', + 'component.hasDeprecated', + ), + hasContents: computed('component', { get() { let component = this.get('component'); diff --git a/addon/components/api/x-component/template.hbs b/addon/components/api/x-component/template.hbs index b9040361f..a9fc968d7 100644 --- a/addon/components/api/x-component/template.hbs +++ b/addon/components/api/x-component/template.hbs @@ -4,37 +4,28 @@
{{{component.description}}}
{{#if hasContents}} -
- {{api/x-index - options=(hash - inherited=(hash shouldShow=component.hasInherited value=showInherited) - internal=(hash shouldShow=component.hasInternal value=showInternal) - protected=(hash shouldShow=component.hasProtected value=showProtected) - private=(hash shouldShow=component.hasPrivate value=showPrivate) - deprecated=(hash shouldShow=component.hasDeprecated value=showDeprecated) + {{#if hasToggles}} + {{api/x-toggles + toggles=(hash + inherited=(if component.hasInherited showInherited) + internal=(if component.hasInternal showInternal) + protected=(if component.hasProtected showProtected) + private=(if component.hasPrivate showPrivate) + deprecated=(if component.hasDeprecated showDeprecated) ) - onOptionToggle=(action 'updateFilter') - - sections=(hash - constructors=constructors - yields=yields - arguments=arguments - fields=fields - accessors=accessors - methods=methods - ) + onToggle=(action 'updateFilter') }} + {{/if}} - {{api/x-sections - sections=(hash - constructors=constructors - yields=yields - arguments=arguments - fields=fields - accessors=accessors - methods=methods - ) - }} -
+ {{api/x-sections + sections=(hash + constructors=constructors + yields=yields + arguments=arguments + fields=fields + accessors=accessors + methods=methods + ) + }} {{/if}} diff --git a/addon/components/api/x-index/template.hbs b/addon/components/api/x-index/template.hbs deleted file mode 100644 index dbe6285d2..000000000 --- a/addon/components/api/x-index/template.hbs +++ /dev/null @@ -1,40 +0,0 @@ - diff --git a/addon/components/api/x-module/component.js b/addon/components/api/x-module/component.js index ab273cde1..24a0cb09d 100644 --- a/addon/components/api/x-module/component.js +++ b/addon/components/api/x-module/component.js @@ -2,5 +2,6 @@ import Component from '@ember/component'; import layout from './template'; export default Component.extend({ - layout + layout, + tagName: '', }); diff --git a/addon/components/api/x-module/template.hbs b/addon/components/api/x-module/template.hbs index 481b50d0c..7082902f1 100644 --- a/addon/components/api/x-module/template.hbs +++ b/addon/components/api/x-module/template.hbs @@ -1,19 +1,8 @@ -
- {{api/x-index - sections=(hash - classes=module.classes - components=module.components - functions=module.functions - variables=module.variables - ) - }} - - {{api/x-sections - sections=(hash - classes=module.classes - components=module.components - functions=module.functions - variables=module.variables - ) - }} -
+{{api/x-sections + sections=(hash + classes=module.classes + components=module.components + functions=module.functions + variables=module.variables + ) +}} diff --git a/addon/components/api/x-sections/style.scss b/addon/components/api/x-sections/style.scss index b9a179d99..2cd466036 100644 --- a/addon/components/api/x-sections/style.scss +++ b/addon/components/api/x-sections/style.scss @@ -16,26 +16,9 @@ } .item-section__item-header { - margin-left: -1em; - a { color: #333; text-decoration: none; - - &:before { - content: '\B6'; - cursor: pointer; - display: block; - float: left; - width: 1em; - visibility: hidden; - - color: #aaa; - } - - &:hover:before { - visibility: visible; - } } } diff --git a/addon/components/api/x-sections/template.hbs b/addon/components/api/x-sections/template.hbs index 0a8672ee1..571068f14 100644 --- a/addon/components/api/x-sections/template.hbs +++ b/addon/components/api/x-sections/template.hbs @@ -1,48 +1,46 @@ -
- {{#each-in sections as |section items|}} - {{#if items}} -
-

- {{capitalize section}} -

+{{#each-in sections as |section items|}} + {{#if items}} +
+

+ {{capitalize section}} +

- {{#each items as |item|}} -
- {{#if (or item.isClass item.isComponent)}} -

- {{#link-to 'docs.api.item' (concat 'root/' item.id)}} - {{#if (eq item.exportType 'default')}} - Default - {{/if}} - {{item.name}} - {{/link-to}} -

+ {{#each items as |item|}} +
+ {{#if (or item.isClass item.isComponent)}} +

+ {{#link-to 'docs.api.item' (concat 'root/' item.id)}} + {{#if (eq item.exportType 'default')}} + Default + {{/if}} + {{item.name}} + {{/link-to}} +

- {{{item.description}}} - {{else}} -

- - {{#if (eq item.exportType 'default')}} - Default - {{/if}} + {{{item.description}}} + {{else}} +

+ + {{#if (eq item.exportType 'default')}} + Default + {{/if}} - {{type-signature item}} - -

+ {{type-signature item}} + +

- {{#if item.exportType}} - {{api/x-import-path data-test-import-path=true item=item}} - {{/if}} + {{#if item.exportType}} + {{api/x-import-path data-test-import-path=true item=item}} + {{/if}} -

- {{{item.description}}} -

+

+ {{{item.description}}} +

- {{api/x-params data-test-item-params=true params=item.params}} - {{/if}} -
- {{/each}} -
- {{/if}} - {{/each-in}} -
+ {{api/x-params data-test-item-params=true params=item.params}} + {{/if}} + + {{/each}} + + {{/if}} +{{/each-in}} diff --git a/addon/components/api/x-index/component.js b/addon/components/api/x-toggles/component.js similarity index 100% rename from addon/components/api/x-index/component.js rename to addon/components/api/x-toggles/component.js diff --git a/addon/components/api/x-toggles/template.hbs b/addon/components/api/x-toggles/template.hbs new file mode 100644 index 000000000..2903fbb30 --- /dev/null +++ b/addon/components/api/x-toggles/template.hbs @@ -0,0 +1,19 @@ +Show: + + diff --git a/addon/components/docs-viewer/component.js b/addon/components/docs-viewer/component.js index c22a064c4..2f1b8aaaf 100644 --- a/addon/components/docs-viewer/component.js +++ b/addon/components/docs-viewer/component.js @@ -67,5 +67,4 @@ export default Component.extend(EKMixin, { searchIsNotFocused() { return !(document.querySelector('[data-search-box-input]') === document.activeElement); } - }); diff --git a/addon/components/docs-viewer/template.hbs b/addon/components/docs-viewer/template.hbs index ce4e19df7..49ec279f2 100644 --- a/addon/components/docs-viewer/template.hbs +++ b/addon/components/docs-viewer/template.hbs @@ -1,6 +1,8 @@
{{yield (hash nav=(component 'docs-viewer/x-nav') - main=(component 'docs-viewer/x-main') + main=(component 'docs-viewer/x-main' onReindex=(action (mut pageIndex))) )}} + + {{docs-viewer/x-page-index pageIndex=pageIndex}}
diff --git a/addon/components/docs-viewer/x-main/component.js b/addon/components/docs-viewer/x-main/component.js index 447c09dc9..e86f6aa3e 100644 --- a/addon/components/docs-viewer/x-main/component.js +++ b/addon/components/docs-viewer/x-main/component.js @@ -1,24 +1,67 @@ -import { inject as service } from '@ember/service'; import Component from '@ember/component'; -import layout from './template'; +import { inject as service } from '@ember/service'; +import { bind } from '@ember/runloop'; import { computed } from '@ember/object'; import appFiles from 'ember-cli-addon-docs/app-files'; import addonFiles from 'ember-cli-addon-docs/addon-files'; import config from 'dummy/config/environment'; import { getOwner } from '@ember/application'; +import layout from './template'; + const projectHref = config['ember-cli-addon-docs'].projectHref; +const tagToSize = { H2: 'xs', H3: 'xs' }; +const tagToIndent = { H2: '0', H3: '4' }; +const tagToMarginTop = { H2: '2', H3: '2' }; +const tagToMarginBottom = { H2: '0', H3: '0' }; + export default Component.extend({ layout, - docsRoutes: service(), router: service(), + docsRoutes: service(), + pageIndex: service(), + + tagName: 'main', + classNames: ['lg:w-4/5', 'xl:w-3/5', 'max-w-md', 'lg:max-w-none', 'mx-auto', 'lg:mx-0', 'mt-6', 'flex-no-shrink'], + + didInsertElement() { + this._super(...arguments); + + let target = this.element.querySelector('[data-page-index-target]') + + this._mutationObserver = new MutationObserver(bind(this, this.reindex, target)) + + this._mutationObserver.observe(target, { subtree: true, childList: true }); + + this.reindex(target); + }, + + willDestroyElement() { + this._super(...arguments); + + this._mutationObserver.disconnect(); + }, - tagName: '', + reindex(target) { + let headers = Array.from( + target.querySelectorAll('.docs-h2, .docs-h3, .docs-md__h2, .docs-md__h3') + ); - // elementId: 'docs-viewer__scroll-body', - // classNames: 'docs-viewer__main', + this.get('onReindex')( + headers.map((header) => { + return { + id: header.id, + text: header.dataset.text || header.textContent, + size: tagToSize[header.tagName], + indent: tagToIndent[header.tagName], + marginTop: tagToMarginTop[header.tagName], + marginBottom: tagToMarginBottom[header.tagName], + }; + }) + ); + }, editCurrentPageUrl: computed('router.currentRouteName', function() { let path = this.get('router.currentRouteName'); diff --git a/addon/components/docs-viewer/x-main/template.hbs b/addon/components/docs-viewer/x-main/template.hbs index 6a5454490..a5ee6bc43 100644 --- a/addon/components/docs-viewer/x-main/template.hbs +++ b/addon/components/docs-viewer/x-main/template.hbs @@ -1,44 +1,42 @@ -
-
- {{yield}} - - +
+ {{yield}} + -
-
-
- {{#if docsRoutes.previous}} -
- Previous -
- {{#link-to params=docsRoutes.previous.route - class='text-grey-darkest text-2xl font-light no-underline - border-b border-grey hover:border-grey-darkest transition'}} - {{docsRoutes.previous.label}} - {{/link-to}} - {{/if}} -
+
+ +
+
+
+ {{#if docsRoutes.previous}} +
+ Previous +
+ {{#link-to params=docsRoutes.previous.route + class='text-grey-darkest text-2xl font-light no-underline + border-b border-grey hover:border-grey-darkest transition'}} + {{docsRoutes.previous.label}} + {{/link-to}} + {{/if}} +
-
- {{#if docsRoutes.next}} -
- Next -
- {{#link-to params=docsRoutes.next.route - class='text-grey-darkest text-2xl font-light no-underline - border-b border-grey hover:border-grey-darkest transition'}} - {{docsRoutes.next.label}} - {{/link-to}} - {{/if}} -
+
+ {{#if docsRoutes.next}} +
+ Next +
+ {{#link-to params=docsRoutes.next.route + class='text-grey-darkest text-2xl font-light no-underline + border-b border-grey hover:border-grey-darkest transition'}} + {{docsRoutes.next.label}} + {{/link-to}} + {{/if}}
-
+ diff --git a/addon/components/docs-viewer/x-page-index/component.js b/addon/components/docs-viewer/x-page-index/component.js new file mode 100644 index 000000000..6a0f24a05 --- /dev/null +++ b/addon/components/docs-viewer/x-page-index/component.js @@ -0,0 +1,12 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; +import layout from './template'; + +export default Component.extend({ + + layout, + + tagName: '', + + pageIndex: service() +}); diff --git a/addon/components/docs-viewer/x-page-index/template.hbs b/addon/components/docs-viewer/x-page-index/template.hbs new file mode 100644 index 000000000..469f4e672 --- /dev/null +++ b/addon/components/docs-viewer/x-page-index/template.hbs @@ -0,0 +1,30 @@ + diff --git a/addon/router.js b/addon/router.js new file mode 100644 index 000000000..ded6377cf --- /dev/null +++ b/addon/router.js @@ -0,0 +1,18 @@ +import EmberRouter from '@ember/routing/router'; +import RouterScroll from 'ember-router-scroll'; + +export default EmberRouter.extend(RouterScroll); + +export function docsRoute(router, callback) { + router.route('docs', function() { + callback.apply(this); + + apiRoute(this); + }); +} + +export function apiRoute(router) { + router.route('api', function() { + this.route('item', { path: '/*path' }); + }); +} diff --git a/addon/services/page-index.js b/addon/services/page-index.js new file mode 100644 index 000000000..81104e722 --- /dev/null +++ b/addon/services/page-index.js @@ -0,0 +1,51 @@ +import Service from '@ember/service'; +import { scheduleOnce } from '@ember/runloop'; + +let tagToSize = { + H2: 'sm', + H3: 'xs', +}; + +let tagToIndent = { + H2: '2', + H3: '4', +}; + +let tagToMarginTop = { + H2: '2', + H3: '0', +}; + +let tagToMarginBottom = { + H2: '1', + H3: '0', +}; + +export default Service.extend({ + reindex(target) { + scheduleOnce('afterRender', this, '_reindex', target); + }, + + _reindex(target) { + let mainSection = document.querySelector('main'); + + if (!mainSection) { + return; + } + + let headers = Array.from( + mainSection.querySelectorAll('h2, h3') + ); + + this.set('index', headers.map((header) => { + return { + id: header.id, + text: header.dataset.text || header.textContent, + size: tagToSize[header.tagName], + indent: tagToIndent[header.tagName], + marginTop: tagToMarginTop[header.tagName], + marginBottom: tagToMarginBottom[header.tagName], + }; + })); + } +}); diff --git a/addon/styles/addon.scss b/addon/styles/addon.scss index c3f3709b3..786b8807b 100644 --- a/addon/styles/addon.scss +++ b/addon/styles/addon.scss @@ -38,3 +38,41 @@ svg { .ember-modal-dialog { z-index: 10; } + +h1 > a:before, +h2 > a:before, +h3 > a:before { + content: '\B6'; + cursor: pointer; + display: block; + float: left; + visibility: hidden; + + color: #aaa; +} + +h1 > a:hover:before, +h2 > a:hover:before, +h3 > a:hover:before { + visibility: visible; +} + +h1 > a:before { + font-size: 0.7em; + width: 0.7em; + padding: 0.2em 0; + margin-left: -0.9em; +} + +h2 > a:before { + font-size: 0.85em; + width: 0.8em; + padding: 0.1em 0em; + margin-left: -0.9em; +} + +h3 > a:before { + font-size: 1em; + width: 0em; + margin-left: -0.9em; +} diff --git a/addon/tailwind/components/docs-md.css b/addon/tailwind/components/docs-md.css index 09575576d..c106b0084 100644 --- a/addon/tailwind/components/docs-md.css +++ b/addon/tailwind/components/docs-md.css @@ -3,17 +3,26 @@ } .docs-md__h1, -.docs-h1 { - @apply mb-6 text-grey-darkest text-4xl font-extrabold leading-tight; +.docs-h1, +.docs-md__h1 a, +.docs-h1 a { + @apply mb-6 text-grey-darkest text-4xl font-extrabold leading-tight no-underline; } + .docs-md__h2, -.docs-h2 { - @apply mt-8 mb-4 text-grey-darkest leading-tight; +.docs-h2, +.docs-md__h2 a, +.docs-h2 a { + @apply pt-8 mb-4 text-grey-darkest leading-tight no-underline; } + .docs-md__h3, -.docs-h3 { - @apply mb-2 text-grey-darkest leading-tight; +.docs-h3, +.docs-md__h3 a, +.docs-h3 a { + @apply pt-4 mb-2 text-grey-darkest leading-tight no-underline; } + .docs-md p { @apply mb-4; } diff --git a/addon/tailwind/config/margin.js b/addon/tailwind/config/margin.js index f51474e09..9492e6deb 100644 --- a/addon/tailwind/config/margin.js +++ b/addon/tailwind/config/margin.js @@ -25,4 +25,5 @@ export default { '8': '2rem', '12': '3rem', '16': '4rem', + '20': '5rem', }; diff --git a/lib/utils/compile-markdown.js b/lib/utils/compile-markdown.js index 82ba6ee3a..b7e670256 100644 --- a/lib/utils/compile-markdown.js +++ b/lib/utils/compile-markdown.js @@ -102,7 +102,13 @@ class HBSRenderer extends marked.Renderer { heading(text, level) { let id = text.toLowerCase().replace(/<\/?.*?>/g, '').replace(/[^\w]+/g, '-'); - return `${text}`; + return ` + + + ${text} + + + `; } hr() { diff --git a/public/.DS_Store b/public/.DS_Store index d8d844af3..7596da1f7 100644 Binary files a/public/.DS_Store and b/public/.DS_Store differ diff --git a/public/icons/link.svg b/public/icons/link.svg new file mode 100644 index 000000000..11a696f84 --- /dev/null +++ b/public/icons/link.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/acceptance/sandbox/api/components-test.js b/tests/acceptance/sandbox/api/components-test.js index 189055766..a765e2654 100644 --- a/tests/acceptance/sandbox/api/components-test.js +++ b/tests/acceptance/sandbox/api/components-test.js @@ -19,4 +19,30 @@ module('Acceptance | API | components', function(hooks) { assert.equal(currentURL(), `/sandbox/api/components/simple-list/item`, 'correct url'); }); + + test('component page index works', async function(assert) { + await visit('/sandbox'); + await modulePage.navItems.findOne({ text: `{{esdoc-component}}` }).click(); + + assert.equal(currentURL(), `/sandbox/api/components/esdoc-component`, 'correct url'); + + let indexItems = modulePage.index.items.map(i => i.text); + + assert.equal(indexItems.length, 7, 'correct number of items rendered'); + assert.ok(indexItems.includes('Yields') && indexItems.includes('Arguments'), 'correct sections rendered'); + + await modulePage.toggles.findOne({ text: 'Internal' }).click(); + + indexItems = modulePage.index.items.map(i => i.text); + + assert.equal(indexItems.length, 12, 'correct number of items rendered'); + assert.ok(indexItems.includes('Fields') && indexItems.includes('Methods'), 'correct sections rendered'); + + await modulePage.toggles.findOne({ text: 'Private' }).click(); + + indexItems = modulePage.index.items.map(i => i.text); + + assert.equal(indexItems.length, 13, 'correct number of items rendered'); + assert.ok(indexItems.includes('_privateField'), 'private field rendered'); + }); }); diff --git a/tests/acceptance/sandbox/api/guides-test.js b/tests/acceptance/sandbox/api/guides-test.js new file mode 100644 index 000000000..82aab3a52 --- /dev/null +++ b/tests/acceptance/sandbox/api/guides-test.js @@ -0,0 +1,22 @@ +import { module, test } from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { currentURL, visit } from '@ember/test-helpers'; + +import modulePage from '../../../pages/api/module'; + +module('Acceptance | sandbox | guides', function(hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + test('page index works', async function(assert) { + await visit('/sandbox'); + + assert.equal(currentURL(), `/sandbox`, 'correct url'); + + let indexItems = modulePage.index.items.map(i => i.text); + + assert.equal(indexItems.length, 2, 'correct number of items rendered'); + assert.ok(indexItems.includes('Subsection') && indexItems.includes('Sub-subsection'), 'correct sections rendered'); + }); +}); diff --git a/tests/dummy/app/pods/sandbox/index/template.md b/tests/dummy/app/pods/sandbox/index/template.md index f357d5fb5..76322fc10 100644 --- a/tests/dummy/app/pods/sandbox/index/template.md +++ b/tests/dummy/app/pods/sandbox/index/template.md @@ -3,3 +3,11 @@ Welcome to the Ember CLI Addon Docs Sandbox! This area of the site demonstrates the many different ways you can document your addon code. + +## Subsection + +This is a subsection + +### Sub-subsection + +This is a sub-subsection diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index 6acae74de..951a9e3ee 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -1,15 +1,14 @@ -import EmberRouter from '@ember/routing/router'; +import AddonDocsRouter, { docsRoute, apiRoute } from 'ember-cli-addon-docs/router'; import config from './config/environment'; -import RouterScroll from 'ember-router-scroll'; -const Router = EmberRouter.extend(RouterScroll, { +const Router = AddonDocsRouter.extend({ location: config.locationType, - rootURL: config.rootURL + rootURL: config.rootURL, }); Router.map(function() { - this.route('docs', function() { + docsRoute(this, function() { this.route('usage'); this.route('quickstart'); this.route('patterns'); @@ -23,16 +22,10 @@ Router.map(function() { this.route('docs-viewer'); this.route('docs-demo'); }); - - this.route('api', function() { - this.route('item', { path: '/*path' }); - }); }); this.route('sandbox', function() { - this.route('api', function() { - this.route('item', { path: '/*path' }); - }); + apiRoute(this); }); this.route('not-found', { path: '/*path' }); diff --git a/tests/pages/api/module.js b/tests/pages/api/module.js index 0e188c90a..6406f05f0 100644 --- a/tests/pages/api/module.js +++ b/tests/pages/api/module.js @@ -3,6 +3,10 @@ import PageObject, { collection, text } from 'ember-classy-page-object'; const ModulePage = PageObject.extend({ navItems: collection({ scope: '[data-test-id="nav-item"]' }), + toggles: collection({ + scope: '[data-test-toggle]' + }), + sections: collection({ scope: '[data-test-api-section]', @@ -19,7 +23,16 @@ const ModulePage = PageObject.extend({ scope: '[data-test-item-params] [data-test-item-param]' }) }) - }) + }), + + // eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects + index: { + scope: '[data-test-page-index]', + + items: collection({ + scope: '[data-test-index-item]' + }) + } }); export default ModulePage.create(); diff --git a/tests/pages/guide.js b/tests/pages/guide.js new file mode 100644 index 000000000..d6c7def38 --- /dev/null +++ b/tests/pages/guide.js @@ -0,0 +1,16 @@ +import PageObject, { collection } from 'ember-classy-page-object'; + +const GuidePage = PageObject.extend({ + navItems: collection({ scope: '[data-test-id="nav-item"]' }), + + // eslint-disable-next-line ember/avoid-leaking-state-in-ember-objects + index: { + scope: '[data-test-page-index]', + + items: collection({ + scope: '[data-test-index-item]' + }) + } +}); + +export default GuidePage.create();