-
-
Notifications
You must be signed in to change notification settings - Fork 113
Replace jQuery animation for table of contents and remove jQuery package #771
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"application-template-wrapper": false, | ||
"default-async-observers": true, | ||
"jquery-integration": true, | ||
"jquery-integration": false, | ||
"template-only-glimmer-components": true | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 139 additions & 12 deletions
151
tests/integration/components/table-of-contents-test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,157 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render, findAll } from '@ember/test-helpers'; | ||
import { render, findAll, click } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
const TIMEOUT_FOR_ANIMATION = 600; | ||
const CLASSES = ['Descriptor', 'Ember']; | ||
const MODULES = ['@ember/application', '@ember/array']; | ||
|
||
module('Integration | Component | table of contents', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
this.set('projectId', 'Ember'); | ||
this.set('emberVersion', '2.4.3'); | ||
this.set('classesIDs', CLASSES); | ||
|
||
await render(hbs` | ||
{{ | ||
table-of-contents showPrivateClasses=true | ||
projectid=projectId | ||
version=emberVersion | ||
classesIDs=classesIDs | ||
isShowingNamespaces=true | ||
}} | ||
`); | ||
|
||
const contentTitle = document.querySelector( | ||
'[data-test-toc-title="classes"]' | ||
); | ||
const contentReference = '.toc-level-1'; | ||
|
||
assert.dom(contentTitle).hasText('Classes'); | ||
assert | ||
.dom(`${contentReference} li`) | ||
.exists({ count: 2 }, 'We have two items to display'); | ||
assert.dom(findAll(`${contentReference} li`)[0]).hasText(CLASSES[0]); | ||
assert.dom(findAll(`${contentReference} li`)[1]).hasText(CLASSES[1]); | ||
}); | ||
|
||
test('Starts with underlying content visible', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
this.set('projectId', 'Ember'); | ||
this.set('emberVersion', '2.4.3'); | ||
this.set('moduleIDs', MODULES); | ||
|
||
this.set('classesIDs', ['Descriptor', 'Ember']); | ||
await render(hbs` | ||
{{ | ||
table-of-contents showPrivateClasses=true | ||
projectid=projectId | ||
version=emberVersion | ||
moduleIDs=moduleIDs | ||
isShowingNamespaces=true | ||
}} | ||
`); | ||
|
||
await render(hbs`{{table-of-contents showPrivateClasses=true | ||
projectid=projectId | ||
version=emberVersion | ||
classesIDs=classesIDs | ||
isShowingNamespaces=true | ||
}}`); | ||
const contentReference = '.toc-level-1'; | ||
const content = document.querySelector(contentReference); | ||
const contentTitle = document.querySelector( | ||
'[data-test-toc-title="classes"]' | ||
); | ||
|
||
assert.dom(findAll('.toc-level-0 > a')[2]).hasText('Classes'); | ||
assert.dom(contentTitle).hasText('Classes'); | ||
assert.dom(content).hasClass('selected'); | ||
assert | ||
.dom('.toc-level-1 li') | ||
.dom(`${contentReference} li`) | ||
.exists({ count: 2 }, 'We have two items to display'); | ||
assert.dom(findAll('.toc-level-1 li')[0]).hasText('Descriptor'); | ||
assert.dom(findAll('.toc-level-1 li')[1]).hasText('Ember'); | ||
assert.dom(content).isVisible(); | ||
assert.dom(findAll(`${contentReference} li`)[0]).hasText(MODULES[0]); | ||
assert.dom(findAll(`${contentReference} li`)[1]).hasText(MODULES[1]); | ||
}); | ||
|
||
test('Underlying content hides once clicked', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
this.set('projectId', 'Ember'); | ||
this.set('emberVersion', '2.4.3'); | ||
this.set('moduleIDs', MODULES); | ||
|
||
await render(hbs` | ||
{{ | ||
table-of-contents showPrivateClasses=true | ||
projectid=projectId | ||
version=emberVersion | ||
moduleIDs=moduleIDs | ||
isShowingNamespaces=true | ||
}} | ||
`); | ||
|
||
const contentTitle = document.querySelector( | ||
'[data-test-toc-title="packages"]' | ||
); | ||
const contentReference = '.toc-level-1'; | ||
const content = document.querySelector(contentReference); | ||
|
||
assert.dom(contentTitle).hasText('Packages'); | ||
assert.dom(content).hasClass('selected'); | ||
assert.dom(content).isVisible(); | ||
|
||
await click(contentTitle); | ||
|
||
const done = assert.async(); | ||
setTimeout(() => { | ||
assert.dom(content).isNotVisible(); | ||
assert.dom(content).doesNotHaveClass('selected'); | ||
done(); | ||
}, TIMEOUT_FOR_ANIMATION); | ||
}); | ||
|
||
test('Underlying content should be visible after 2 clicks', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
this.set('projectId', 'Ember'); | ||
this.set('emberVersion', '2.4.3'); | ||
this.set('moduleIDs', MODULES); | ||
|
||
await render(hbs` | ||
{{ | ||
table-of-contents showPrivateClasses=true | ||
projectid=projectId | ||
version=emberVersion | ||
moduleIDs=moduleIDs | ||
isShowingNamespaces=true | ||
}} | ||
`); | ||
|
||
const titleButton = document.querySelector( | ||
'[data-test-toc-title="packages"]' | ||
); | ||
const contentReference = '.toc-level-1'; | ||
const content = document.querySelector(contentReference); | ||
|
||
assert.dom(titleButton).hasText('Packages'); | ||
assert.dom(content).hasClass('selected'); | ||
assert.dom(content).isVisible(); | ||
|
||
await click(titleButton); | ||
|
||
const done1 = assert.async(); | ||
|
||
setTimeout(async () => { | ||
assert.dom(content).isNotVisible(); | ||
assert.dom(content).doesNotHaveClass('selected'); | ||
|
||
await click(titleButton); | ||
|
||
const done2 = assert.async(); | ||
|
||
setTimeout(() => { | ||
assert.dom(content).isVisible(); | ||
assert.dom(content).hasClass('selected'); | ||
done2(); | ||
}, TIMEOUT_FOR_ANIMATION); | ||
|
||
done1(); | ||
}, TIMEOUT_FOR_ANIMATION); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be animating height or max-height?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't actually use height. For the expanded condition, we would have to give
height: auto
andAccording to the Mozilla Developer Network docs, auto values have been intentionally excluded from the CSS transitions spec.
Source: https://css-tricks.com/using-css-transitions-auto-dimensions/