diff --git a/addon/components/liquid-tether.js b/addon/components/liquid-tether.js index 2267502..9abc45c 100644 --- a/addon/components/liquid-tether.js +++ b/addon/components/liquid-tether.js @@ -1,14 +1,11 @@ import Ember from 'ember'; import LiquidWormhole from 'liquid-wormhole/components/liquid-wormhole'; -import layout from '../templates/components/liquid-tether'; -const { computed, get, observer, run } = Ember; +const { computed, get, run } = Ember; const { camelize } = Ember.String; export default LiquidWormhole.extend({ - layout, - classPrefix: 'liquid-tether', target: null, attachment: null, @@ -26,6 +23,10 @@ export default LiquidWormhole.extend({ }, willAppendNodes(bodyElement) { + if (this._tether) { + this.removeTether(); + } + this.addTether(bodyElement); }, @@ -75,23 +76,6 @@ export default LiquidWormhole.extend({ } }, - tetherDidChange: observer( - 'class-prefix', - 'target', - 'attachment', - 'targetAttachment', - 'offset', - 'targetOffset', - 'targetModifier', - 'constraints', - 'optimizations', - 'to', - function() { - this.removeTether(this._tether); - this.addTether(); - } - ), - _tetherTarget: computed('target', function() { let target = get(this, 'target'); if (target && target.element) { diff --git a/addon/index.js b/addon/index.js index f6bc8ec..369c61d 100644 --- a/addon/index.js +++ b/addon/index.js @@ -1,18 +1,14 @@ import Constraint from 'liquid-fire/constraint'; export function target(name) { - return new Constraint('parentElementClass', (className) => { - if (className.match('-liquid-target')) { - const targetName = className.replace('-liquid-target', ''); - return targetName.match(name); - } - }); + return new Constraint('parentElementClass', `${name}`); } + export function onOpenTether() { - return new Constraint('newValue', ({ emptyTarget }) => !emptyTarget); + return new Constraint('newValue', (value) => value !== null); } export function onCloseTether() { - return new Constraint('newValue', ({ emptyTarget }) => emptyTarget); + return new Constraint('newValue', (value) => value === null); } diff --git a/addon/styles/addon.css b/addon/styles/addon.css deleted file mode 100644 index 2e8f3b7..0000000 --- a/addon/styles/addon.css +++ /dev/null @@ -1,150 +0,0 @@ -.default-liquid-target .liquid-tether-container { - animation : none !important; - animation-delay : 0 !important; - animation-direction : normal !important; - animation-duration : 0 !important; - animation-fill-mode : none !important; - animation-iteration-count : 1 !important; - animation-name : none !important; - animation-play-state : running !important; - animation-timing-function : ease !important; - backface-visibility : visible !important; - background : 0 !important; - background-attachment : scroll !important; - background-clip : border-box !important; - background-color : transparent !important; - background-image : none !important; - background-origin : padding-box !important; - background-position : 0 0 !important; - background-position-x : 0 !important; - background-position-y : 0 !important; - background-repeat : repeat !important; - background-size : auto auto !important; - border : 0 !important; - border-style : none !important; - border-width : medium !important; - border-color : inherit !important; - border-bottom : 0 !important; - border-bottom-color : inherit !important; - border-bottom-left-radius : 0 !important; - border-bottom-right-radius : 0 !important; - border-bottom-style : none !important; - border-bottom-width : medium !important; - border-collapse : separate !important; - border-image : none !important; - border-left : 0 !important; - border-left-color : inherit !important; - border-left-style : none !important; - border-left-width : medium !important; - border-radius : 0 !important; - border-right : 0 !important; - border-right-color : inherit !important; - border-right-style : none !important; - border-right-width : medium !important; - border-spacing : 0 !important; - border-top : 0 !important; - border-top-color : inherit !important; - border-top-left-radius : 0 !important; - border-top-right-radius : 0 !important; - border-top-style : none !important; - border-top-width : medium !important; - bottom : auto !important; - box-shadow : none !important; - box-sizing : content-box !important; - caption-side : top !important; - clear : none !important; - clip : auto !important; - color : inherit !important; - columns : auto !important; - column-count : auto !important; - column-fill : balance !important; - column-gap : normal !important; - column-rule : medium none currentColor !important; - column-rule-color : currentColor !important; - column-rule-style : none !important; - column-rule-width : none !important; - column-span : 1 !important; - column-width : auto !important; - content : normal !important; - counter-increment : none !important; - counter-reset : none !important; - cursor : auto !important; - direction : ltr !important; - display : inline !important; - empty-cells : show !important; - float : none !important; - font : normal !important; - font-family : inherit !important; - font-size : medium !important; - font-style : normal !important; - font-variant : normal !important; - font-weight : normal !important; - height : auto !important; - hyphens : none !important; - left : auto !important; - letter-spacing : normal !important; - line-height : normal !important; - list-style : none !important; - list-style-image : none !important; - list-style-position : outside !important; - list-style-type : disc !important; - margin : 0 !important; - margin-bottom : 0 !important; - margin-left : 0 !important; - margin-right : 0 !important; - margin-top : 0 !important; - max-height : none !important; - max-width : none !important; - min-height : 0 !important; - min-width : 0 !important; - opacity : 1 !important; - orphans : 0 !important; - outline : 0 !important; - outline-color : invert !important; - outline-style : none !important; - outline-width : medium !important; - overflow : visible !important; - overflow-x : visible !important; - overflow-y : visible !important; - padding : 0 !important; - padding-bottom : 0 !important; - padding-left : 0 !important; - padding-right : 0 !important; - padding-top : 0 !important; - page-break-after : auto !important; - page-break-before : auto !important; - page-break-inside : auto !important; - perspective : none !important; - perspective-origin : 50% 50% !important; - position : static !important; - /* May need to alter quotes for different locales (e.g fr) */ - quotes : '\201C' '\201D' '\2018' '\2019' !important; - right : auto !important; - tab-size : 8 !important; - table-layout : auto !important; - text-align : inherit !important; - text-align-last : auto !important; - text-decoration : none !important; - text-decoration-color : inherit !important; - text-decoration-line : none !important; - text-decoration-style : solid !important; - text-indent : 0 !important; - text-shadow : none !important; - text-transform : none !important; - top : auto !important; - transform : none !important; - transform-style : flat !important; - transition : none !important; - transition-delay : 0s !important; - transition-duration : 0s !important; - transition-property : none !important; - transition-timing-function : ease !important; - unicode-bidi : normal !important; - vertical-align : baseline !important; - visibility : visible !important; - white-space : normal !important; - widows : 0 !important; - width : auto !important; - word-spacing : normal !important; - z-index : auto !important; -} diff --git a/addon/templates/components/liquid-tether.hbs b/addon/templates/components/liquid-tether.hbs deleted file mode 100644 index 69517aa..0000000 --- a/addon/templates/components/liquid-tether.hbs +++ /dev/null @@ -1,5 +0,0 @@ -
-
- {{yield}} -
-
diff --git a/app/transitions/tether.js b/app/transitions/tether.js deleted file mode 100644 index 29b14cc..0000000 --- a/app/transitions/tether.js +++ /dev/null @@ -1,8 +0,0 @@ -import explode from './explode'; - -export default function tether(transition, options = {}) { - return explode.apply(this, [{ - pick: '.liquid-tether-element > :first-child', - use: [transition, options] - }]); -} diff --git a/package.json b/package.json index 43ca2e2..f3203c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "liquid-tether", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.2", "description": "Modals made easy", "directories": { "doc": "doc", @@ -34,7 +34,6 @@ "ember-cli-test-loader": "^1.1.0", "ember-cli-uglify": "^1.2.0", "ember-cli-markdown-compiler": "pzuraq/ember-cli-markdown-compiler#example-site-fixes", - "ember-code-snippet": "1.1.3", "liquid-fire": "0.26.1", "ui-tabs": "firefly-ui/ui-tabs", "phantomjs": "^2.0.0", @@ -42,7 +41,6 @@ "ember-export-application-global": "^1.0.5", "ember-load-initializers": "^0.5.1", "ember-resolver": "^2.0.3", - "ember-try": "^0.1.2", "loader.js": "^4.0.1" }, "keywords": [ @@ -51,7 +49,7 @@ "dependencies": { "broccoli-funnel": "^0.2.8", "broccoli-merge-trees": "^0.2.3", - "liquid-wormhole": "pzuraq/liquid-wormhole#v2.0.0-beta.1", + "liquid-wormhole": "v2.0.0-beta.2", "tether": "pzuraq/tether#adds-option-to-specify-body-element", "ember-cli-htmlbars": "^1.0.3", "ember-cli-babel": "^5.1.6" diff --git a/tests/acceptance/demo-test.js b/tests/acceptance/demo-test.js index a28ec49..0335f62 100644 --- a/tests/acceptance/demo-test.js +++ b/tests/acceptance/demo-test.js @@ -1,4 +1,4 @@ -/* global ranTetherTransition, ranOverlayTransition, noTransitionsYet */ +/* global ranWormholeTransition, noTransitionsYet */ import moduleForAcceptance from '../helpers/module-for-acceptance'; import { injectTransitionSpies } from '../helpers/integration'; @@ -13,82 +13,66 @@ moduleForAcceptance('Acceptance | Demos', { } }); -test('target container exists and is empty on load', function() { - visit('/examples'); - - andThen(() => { - noTransitionsYet(); - equal(find('.liquid-target-container').length, 1, 'it exists'); - equal(find('.liquid-target-container > .liquid-target').length, 0, 'it\'s empty'); - }); -}); - test('target container is cleaned when empty', function() { - visit('/examples'); + visit('/docs'); click('#hello-world-button'); click('#hello-world-button'); andThen(() => { - equal(find('.liquid-target-container > .liquid-target').length, 0, 'it\'s empty'); + equal(find('.default-liquid-destination .liquid-destination-stack').length, 0, 'it\'s empty'); }); }); test('basic liquid-tether works correctly', function() { - visit('/examples'); + visit('/docs'); noTransitionsYet(); click('#hello-world-button'); andThen(() => { - equal(find('.liquid-target-container .liquid-tether').length, 1, 'it exists'); - ranTetherTransition('fade-left'); + equal(find('.default-liquid-destination .liquid-wormhole-element').length, 1, 'it exists'); + ranWormholeTransition('fade-down'); }); }); -test('tethers can determine context', function() { - visit('/examples'); +test('tethers can determine context with stacks', function() { + visit('/docs/stacks'); click('#animation-with-context-button'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); + andThen(() => ranWormholeTransition('fade')); click('button:contains(Next)'); - andThen(() => ranTetherTransition('to-left')); + andThen(() => ranWormholeTransition('to-left')); click('button:contains(Back)'); - andThen(() => ranTetherTransition('to-right')); + andThen(() => ranWormholeTransition('to-right')); click('button:contains(Cancel)'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); + andThen(() => ranWormholeTransition('fade')); }); -test('routed tethers can determine context', function() { - visit('/examples/step-one'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); +test('routed tethers can determine context with stacks', function() { + visit('/docs/routed-tethers/step-one'); + andThen(() => ranWormholeTransition('fade')); - visit('/examples/step-two'); - andThen(() => ranTetherTransition('to-left')); + visit('/docs/routed-tethers/step-two'); + andThen(() => ranWormholeTransition('to-left')); - visit('/examples/step-one'); - andThen(() => ranTetherTransition('to-right')); + visit('/docs/routed-tethers/step-one'); + andThen(() => ranWormholeTransition('to-right')); - visit('/examples'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); + visit('/docs'); + andThen(() => ranWormholeTransition('fade')); }); test('clickable overlay responds and has correct class', function() { - visit('/examples'); + visit('/docs/stacks'); click('#animation-with-context-button'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); + andThen(() => ranWormholeTransition('fade')); andThen(() => { - equal(find('.liquid-tether-overlay.clickable').length, 1, 'clickable overlay exists'); + equal(find('.modal-backdrop').length, 1, 'overlay exists'); }); - click('.liquid-tether-overlay.clickable'); - andThen(() => ranTetherTransition('fade')); - andThen(() => ranOverlayTransition('fade')); + click('.modal-backdrop'); + andThen(() => ranWormholeTransition('fade')); }); diff --git a/tests/acceptance/scenarios-test.js b/tests/acceptance/scenarios-test.js index 63b2859..7881d26 100644 --- a/tests/acceptance/scenarios-test.js +++ b/tests/acceptance/scenarios-test.js @@ -1,4 +1,3 @@ -/* global ranTetherTransition */ import moduleForAcceptance from '../helpers/module-for-acceptance'; import { injectTransitionSpies } from '../helpers/integration'; @@ -13,16 +12,16 @@ moduleForAcceptance('Acceptance | Scenarios', { } }); -test('components are not destroyed until animation has finished', function() { +test('components are not destroyed until animation has finished', function(assert) { visit('/scenarios/component-in-tether'); andThen(() => { find('button:contains(Toggle)').click(); - equal(find('.velocity-animating').text().trim(), 'testing', 'component markup still exists'); + assert.equal(find('.liquid-wormhole-element').text().trim(), 'testing', 'component markup still exists'); }); }); -test('nested tethers work properly', function() { +test('nested tethers work properly', function(assert) { visit('/scenarios/nested-tethers'); click('button'); @@ -31,51 +30,46 @@ test('nested tethers work properly', function() { const redbox = find('.red-box'); const greenbox = find('.green-box'); const bluebox = find('.blue-box'); + const yellowbox = find('.yellow-box'); const redboxOffset = redbox.offset(); const greenboxOffset = greenbox.offset(); const blueboxOffset = bluebox.offset(); + const yellowboxOffset = yellowbox.offset(); const greenboxHeight = greenbox.outerHeight(); const redboxHeight = redbox.outerHeight(); - const redboxWidth = redbox.outerWidth(); + const blueboxHeight = bluebox.outerHeight(); - ok(withinTolerance(greenboxOffset.top + greenboxHeight, redboxOffset.top), 'redbox vertical pos within tolerance'); - ok(withinTolerance(greenboxOffset.left, redboxOffset.left), 'redbox horizontal pos within tolerance'); + assert.ok(withinTolerance(greenboxOffset.top + greenboxHeight, redboxOffset.top), 'redbox vertical pos within tolerance'); + assert.ok(withinTolerance(greenboxOffset.left, redboxOffset.left), 'redbox horizontal pos within tolerance'); - ok(withinTolerance(redboxOffset.top + redboxHeight, blueboxOffset.top), 'bluebox vertical pos within tolerance'); - ok(withinTolerance(redboxOffset.left + redboxWidth, blueboxOffset.left), 'bluebox horizontal pos within tolerance'); + assert.ok(withinTolerance(redboxOffset.top + redboxHeight, blueboxOffset.top), 'bluebox vertical pos within tolerance'); + assert.ok(withinTolerance(redboxOffset.left, blueboxOffset.left), 'bluebox horizontal pos within tolerance'); + + assert.ok(withinTolerance(blueboxOffset.top + blueboxHeight, yellowboxOffset.top), 'yellowbox vertical pos within tolerance'); + assert.ok(withinTolerance(blueboxOffset.left, yellowboxOffset.left), 'yellowbox horizontal pos within tolerance'); }); }); -test('target only shows one tether at a time', function() { +test('stacked tethers only shows one tether at a time', function(assert) { visit('/scenarios/multiple-tethers'); andThen(() => { - equal(find('.liquid-target-container').text().trim(), '456'); + assert.equal(find('.default-liquid-destination').text().trim(), '456'); }); }); -test('container has correct class if targets are present', function() { - ok(find('.liquid-target-container.has-targets').length === 0, 'No targets class'); +test('destination container has correct class if wormholes are present', function(assert) { + assert.ok(find('.default-liquid-destination.has-wormholes').length === 0, 'No wormholes class'); visit('/scenarios/multiple-tethers'); andThen(() => { - ok(find('.liquid-target-container.has-targets').length > 0, 'Has targets class'); + assert.ok(find('.default-liquid-destination.has-wormholes').length > 0, 'Has wormholes class'); }); }); -test('multiple targets can use the same animation via regex', function() { - visit('/scenarios/multiple-targets-same-animation'); - - andThen(() => ranTetherTransition('fade')); - click('.second-tether'); - andThen(() => ranTetherTransition('to-up')); - click('.third-tether'); - andThen(() => ranTetherTransition('fade')); -}); - function withinTolerance(offset1, offset2) { return Math.abs(offset1 - offset2) <= 3; diff --git a/tests/dummy/app/pods/application/template.hbs b/tests/dummy/app/pods/application/template.hbs index 77ea699..1218a03 100644 --- a/tests/dummy/app/pods/application/template.hbs +++ b/tests/dummy/app/pods/application/template.hbs @@ -1,5 +1,7 @@ -{{main-nav}} -
+
+ {{main-nav}} +
+ {{outlet}}
diff --git a/tests/dummy/app/pods/basics/template.hbs b/tests/dummy/app/pods/basics/template.md similarity index 81% rename from tests/dummy/app/pods/basics/template.hbs rename to tests/dummy/app/pods/basics/template.md index 82d9eec..21767d4 100644 --- a/tests/dummy/app/pods/basics/template.hbs +++ b/tests/dummy/app/pods/basics/template.md @@ -14,9 +14,7 @@ about the peculiarities of positioning elements with CSS - It Just Works.

-{{#scroll-spier id="parameters" on-pass="addPassedAnchor" on-unpass="removePassedAnchor"}} - Parameters -{{/scroll-spier}} +## Parameters

Every Liquid Tether requires the following attributes: @@ -66,9 +64,7 @@

  • optimizations
  • -{{#scroll-spier id="transitions" on-pass="addPassedAnchor" on-unpass="removePassedAnchor"}} - Transitions -{{/scroll-spier}} +## Transitions

    Liquid Tether introduces the target constraint for matching @@ -76,7 +72,7 @@

    - {{code-snippet name="target-signature.js"}} +

    @@ -89,7 +85,7 @@

    - {{code-snippet name="open-tether-example.js"}} +

    @@ -103,8 +99,8 @@

    - {{code-snippet name="value-matching-example.hbs"}} - {{code-snippet name="value-matching-example.js"}} + +

    @@ -112,7 +108,7 @@

    - {{code-snippet name="tether-transition-signature.js"}} +

    @@ -120,7 +116,7 @@

    - {{code-snippet name="tether-transition-code.js"}} +

    @@ -131,28 +127,24 @@ to apply (if any) to the background overlay.

    -{{#scroll-spier id="dom-structure-and-styles" on-pass="addPassedAnchor" on-unpass="removePassedAnchor"}} - DOM Structure and Styles -{{/scroll-spier}} +## DOM Structure and Styles

    Liquid Tether creates the following DOM structure:

    - {{code-snippet name="tether-dom-structure.hbs"}} +

    You can use the overlayClass and tetherClass properties to apply a class directly to either the overlay or the tethered - element. You can also apply a class directly to the liquid-target that + element. You can also apply a class directly to the liquid-destination that contains your tethered element using the targetClass property.

    -{{#scroll-spier id="ember-compatibility" on-pass="addPassedAnchor" on-unpass="removePassedAnchor"}} - Ember Compatibility -{{/scroll-spier}} +## Ember Compatibility

    Liquid Tether is tested on all versions of Ember >= 1.13. Long term support will diff --git a/tests/dummy/app/pods/components/hello-component/component.js b/tests/dummy/app/pods/components/hello-component/component.js new file mode 100644 index 0000000..240e533 --- /dev/null +++ b/tests/dummy/app/pods/components/hello-component/component.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; +import layout from './template'; + +export default Ember.Component.extend({ + layout: layout +}); diff --git a/tests/dummy/app/pods/components/hello-component/template.hbs b/tests/dummy/app/pods/components/hello-component/template.hbs new file mode 100644 index 0000000..a4ab9d2 --- /dev/null +++ b/tests/dummy/app/pods/components/hello-component/template.hbs @@ -0,0 +1,6 @@ +

    +
    +
    + Hello! +
    +
    diff --git a/tests/dummy/app/pods/components/main-nav/template.hbs b/tests/dummy/app/pods/components/main-nav/template.hbs index 9e8a406..c09d511 100644 --- a/tests/dummy/app/pods/components/main-nav/template.hbs +++ b/tests/dummy/app/pods/components/main-nav/template.hbs @@ -3,19 +3,19 @@ - Liquid Tether + Liquid Tether {{/liquid-tether}} diff --git a/tests/dummy/app/pods/examples/routed-tethers/step-one/template.hbs b/tests/dummy/app/pods/docs/routed-tethers/step-two/template.hbs similarity index 61% rename from tests/dummy/app/pods/examples/routed-tethers/step-one/template.hbs rename to tests/dummy/app/pods/docs/routed-tethers/step-two/template.hbs index 7a16713..71db53f 100644 --- a/tests/dummy/app/pods/examples/routed-tethers/step-one/template.hbs +++ b/tests/dummy/app/pods/docs/routed-tethers/step-two/template.hbs @@ -1,6 +1,7 @@ +{{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} {{#liquid-tether - stack="modal" - index=1 + stack="modal-dialog" + value=2 target="document.body" targetModifier="visible" @@ -20,8 +21,8 @@ {{/liquid-tether}} diff --git a/tests/dummy/app/pods/docs/routed-tethers/template.md b/tests/dummy/app/pods/docs/routed-tethers/template.md new file mode 100644 index 0000000..01c9e2d --- /dev/null +++ b/tests/dummy/app/pods/docs/routed-tethers/template.md @@ -0,0 +1,71 @@ +Oftentimes modals should appear in the context of a route. If that's the case +in your application, it's as simple as creating a route and template with just +a `liquid-tether`. + +
    + {{#link-to "docs.routed-tethers.step-one" class="btn btn-primary btn-embossed"}} + Open Routed Tether + {{/link-to}} + + {{outlet}} +
    + +``` +{{#link-to "docs.routed-tethers.step-one"}} + Open Routed Tether +{{/link-to}} + +{{outlet}} +``` + +``` + +{{#liquid-tether + stack="modal-dialog" + index=1 + + target="document.body" + targetModifier="visible" + attachment="middle center" +}} + ... +{{/liquid-tether}} +``` + +``` + +{{#liquid-tether + stack="modal-dialog" + index=2 + + target="document.body" + targetModifier="visible" + attachment="middle center" +}} + ... +{{/liquid-tether}} +``` + +``` +this.transition( + this.matchSelector('#modal-backdrop'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') +); + +this.transition( + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') +); + +this.transition( + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => { + return toValue && fromValue && toValue.index > fromValue.index; + }), + this.use('to-left', options), + this.reverse('to-right', options) +); + +``` diff --git a/tests/dummy/app/pods/docs/stacks/controller.js b/tests/dummy/app/pods/docs/stacks/controller.js new file mode 100644 index 0000000..8b4e514 --- /dev/null +++ b/tests/dummy/app/pods/docs/stacks/controller.js @@ -0,0 +1,75 @@ +import Ember from 'ember'; + +const { computed } = Ember; + +export default Ember.Controller.extend({ + exampleConstraints: [{ + to: 'scrollParent', + attachment: 'together', + pin: true + }], + + showFirstModalDialog: computed.equal('currentModalDialogStep', 1), + showSecondModalDialog: computed.equal('currentModalDialogStep', 2), + showThirdModalDialog: computed.equal('currentModalDialogStep', 3), + + showFirstFlytoDialog: computed.gte('currentFlytoDialogStep', 1), + showSecondFlytoDialog: computed.gte('currentFlytoDialogStep', 2), + showThirdFlytoDialog: computed.gte('currentFlytoDialogStep', 3), + + actions: { + toggleHello() { + this.toggleProperty('showHello'); + }, + + toggleFlyout() { + this.toggleProperty('showFlyout'); + }, + + openModalDialog() { + this.set('currentModalDialogStep', 1); + }, + + prevModalDialog() { + this.decrementProperty('currentModalDialogStep'); + }, + + nextModalDialog() { + this.incrementProperty('currentModalDialogStep'); + }, + + closeModalDialog() { + this.set('currentModalDialogStep', 0); + }, + + openFlytoDialog() { + this.set('currentFlytoDialogStep', 1); + }, + + prevFlytoDialog() { + this.decrementProperty('currentFlytoDialogStep'); + }, + + nextFlytoDialog() { + this.incrementProperty('currentFlytoDialogStep'); + }, + + closeFlytoDialog() { + this.set('currentFlytoDialogStep', 0); + }, + + addPassedAnchor(anchor) { + Ember.run(() => { + this.get('passedAnchors').pushObject(anchor); + Ember.run.scheduleOnce('afterRender', this, 'updateAnchor'); + }); + }, + + removePassedAnchor(anchor) { + Ember.run(() => { + this.get('passedAnchors').removeObject(anchor); + Ember.run.scheduleOnce('afterRender', this, 'updateAnchor'); + }); + } + } +}); diff --git a/tests/dummy/app/pods/docs/stacks/template.md b/tests/dummy/app/pods/docs/stacks/template.md new file mode 100644 index 0000000..d941c5e --- /dev/null +++ b/tests/dummy/app/pods/docs/stacks/template.md @@ -0,0 +1,159 @@ +At times you may want to animate between different tethers - for a complicated +modal flow, or an onboarding sequence, or something else. You can do this by +specifying a stack name with the `stack` property. New tethers will be pushed onto +an existing stack, and only the most recent tether will be showing. When matching in +`toValue`, `fromValue`, or `betweenValues`, the `value` property of both the +previous tether on the stack and the next one will be passed in. You can pass in +any value you want in the property and match based on that. + +The stack name will be applied as the id to the tethers, allow you to match them using +the `matchSelector` helper from liquid-fire. + +
    + + {{#if showFirstModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=1 + target="document.body" + targetModifier="visible" + attachment="middle center" + class="modal-content" + }} + + + + {{/liquid-tether}} + {{/if}} + {{#if showSecondModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=2 + target="document.body" + targetModifier="visible" + attachment="middle center" + class="modal-content" + }} + + + + {{/liquid-tether}} + {{/if}} + {{#if showThirdModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=3 + target="document.body" + targetModifier="visible" + attachment="middle center" + class="modal-content" + }} + + + + {{/liquid-tether}} + {{/if}} +
    + +``` + + +{{#if showFirstModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=1 + + target="document.body" + targetModifier="visible" + attachment="middle center" + + class="modal-content" + }} + ... + {{/liquid-tether}} +{{/if}} + +{{#if showSecondModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=2 + + target="document.body" + targetModifier="visible" + attachment="middle center" + + class="modal-content" + }} + ... + {{/liquid-tether}} +{{/if}} + +{{#if showThirdModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether + stack="modal-dialog" + value=3 + + target="document.body" + targetModifier="visible" + attachment="middle center" + + class="modal-content" + }} + ... + {{/liquid-tether}} +{{/if}} +``` + +``` +this.transition( + this.matchSelector('#modal-backdrop'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') +); + +this.transition( + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') +); + +this.transition( + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => return toValue && fromValue && toValue > fromValue), + this.use('to-left', options), + this.reverse('to-right', options) +); +``` diff --git a/tests/dummy/app/pods/docs/template.hbs b/tests/dummy/app/pods/docs/template.hbs new file mode 100644 index 0000000..d8d0ff0 --- /dev/null +++ b/tests/dummy/app/pods/docs/template.hbs @@ -0,0 +1,17 @@ +
    +
    + +
    + +
    + {{outlet}} +
    +
    diff --git a/tests/dummy/app/pods/examples/routed-tethers/template.md b/tests/dummy/app/pods/examples/routed-tethers/template.md deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/pods/examples/stacks/template.md b/tests/dummy/app/pods/examples/stacks/template.md deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/pods/examples/template.md b/tests/dummy/app/pods/examples/template.md deleted file mode 100644 index fda4386..0000000 --- a/tests/dummy/app/pods/examples/template.md +++ /dev/null @@ -1,364 +0,0 @@ -# Examples - -## Hello World - -Below is the basic Hello World example seen on the front page. The template -code is embedded directly in the context of this page, hidden by an -if statement. Toggling that if inserts the element -into the DOM, which triggers the animation. - -
    - - - {{#if showHello}} - {{#liquid-tether - target="#hello-world-button" - attachment="middle left" - targetAttachment="middle right" - - class="hello-world" - }} -
    -
    -
    - Hello! -
    -
    - {{/liquid-tether}} - {{/if}} -
    - -``` -{{#liquid-tether - target="#hello-world-button" - attachment="middle left" - - class="hello-world" -}} -
    -
    -
    - Hello! -
    -
    -{{/liquid-tether}} -``` - -``` -this.transition( - this.hasClass('hello-world'), - this.use('tether', 'fade-left', { duration: 400, easing: [600, 22] }) -); -``` - -## Test - -
    -
    - {{#liquid-tether - target="#something" - attachment="middle center" - constraints=exampleConstraints - class="blue-box" - }} - Testing123 - {{/liquid-tether}} -
    -
    - -## Animation With Context - -This example shows different animations based on context. It uses the index -constraint shorthands to differentiate between transitioning to the first -modal, in between modals, and from the last modal. This way we can animate -without losing spacial context from the perspective of the user (e.g. if a -modal moves out toward the left side using to-left, the in -reverse the modal with move in from the left side using to-right) - -
    - - - {{#if showFirstModalDialog}} - {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} - {{#liquid-tether - stack="modal" - id="my-modal" - index=1 - target="document.body" - targetModifier="visible" - attachment="middle center" - class="modal-content" - }} - - - - {{/liquid-tether}} - {{/if}} - - {{#if showSecondModalDialog}} - {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} - {{#liquid-tether - stack="modal" - id="my-modal" - index=2 - target="document.body" - targetModifier="visible" - attachment="middle center" - class="modal-content" - }} - - - - {{/liquid-tether}} - {{/if}} - - {{#if showThirdModalDialog}} - {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} - {{#liquid-tether - stack="modal" - id="my-modal" - index=3 - target="document.body" - targetModifier="visible" - attachment="middle center" - class="modal-content" - }} - - - - {{/liquid-tether}} - {{/if}} -
    - - - - -## Moving Modals - -All of the standard Liquid Fire animations work with Liquid Tether out of the -box, meaning the `fly-to` animation can be used to animate tethers -around the page! - - - - diff --git a/tests/dummy/app/pods/index/template.md b/tests/dummy/app/pods/index/template.md index e60a323..7bbefe6 100644 --- a/tests/dummy/app/pods/index/template.md +++ b/tests/dummy/app/pods/index/template.md @@ -1,40 +1,45 @@ -# Modals made easy - - ``` - - - {{#if showHello}} - {{#liquid-tether - target="#hello-world-button" - attachment="middle left" - class="hello-world" - }} - ... - {{/liquid-tether}} - {{/if}} - ``` - -
    -
    - - - {{#if showHello}} - {{#liquid-tether - target="#hello-world-button" - attachment="middle left" - class="hello-world" - }} -
    -
    -
    - Hello! -
    +
    + + Liquid-Fire meets Ember-Tether + +
    +
    + + {{#if showHello}} + {{#liquid-tether + target="#hello-world-button" + attachment="top center" + class="hello-world" + }} +
    +
    +
    + Hello, World!
    - {{/liquid-tether}} - {{/if}} -
    +
    + {{/liquid-tether}} + {{/if}}
    + +``` +{{#liquid-tether + target="#hello-world-button" + attachment="top center" + class="hello-world" +}} + Hello, World +{{/liquid-tether}} +``` +``` +this.transition( + this.hasClass('hello-world'), + this.use('fade') +) +``` + +Liquid Tether combines [Tether.js](http://tether.io/) with +[Liquid Fire](http://ember-animation.github.io/liquid-fire/) to make animating +your modals, popups, tooltips, and more easy. Just add `liquid-tether`s to your +templates and transitions to your transition map and you're on your way! diff --git a/tests/dummy/app/pods/scenarios/multiple-tethers/template.hbs b/tests/dummy/app/pods/scenarios/multiple-tethers/template.hbs index a6f25fc..edcbf40 100644 --- a/tests/dummy/app/pods/scenarios/multiple-tethers/template.hbs +++ b/tests/dummy/app/pods/scenarios/multiple-tethers/template.hbs @@ -1,7 +1,7 @@ -{{#liquid-tether target="document.body" attachment="middle center" class="multiple"}} +{{#liquid-tether stack="multiple" target="document.body" attachment="middle center" class="multiple"}} 123 {{/liquid-tether}} -{{#liquid-tether target="document.body" attachment="middle center" class="multiple"}} +{{#liquid-tether stack="multiple" target="document.body" attachment="middle center" class="multiple"}} 456 {{/liquid-tether}} diff --git a/tests/dummy/app/pods/scenarios/nested-tethers.hbs/controller.js b/tests/dummy/app/pods/scenarios/nested-tethers/controller.js similarity index 100% rename from tests/dummy/app/pods/scenarios/nested-tethers.hbs/controller.js rename to tests/dummy/app/pods/scenarios/nested-tethers/controller.js diff --git a/tests/dummy/app/pods/scenarios/nested-tethers.hbs/template.hbs b/tests/dummy/app/pods/scenarios/nested-tethers/template.hbs similarity index 54% rename from tests/dummy/app/pods/scenarios/nested-tethers.hbs/template.hbs rename to tests/dummy/app/pods/scenarios/nested-tethers/template.hbs index 63fe928..1ac26e0 100644 --- a/tests/dummy/app/pods/scenarios/nested-tethers.hbs/template.hbs +++ b/tests/dummy/app/pods/scenarios/nested-tethers/template.hbs @@ -13,28 +13,18 @@ {{#liquid-tether target=".red-box" attachment="top left" + targetAttachment="bottom left" class="blue-box" }} Middle Tether - - - - {{#if showingInner}} - {{#liquid-tether - target=".blue-box" - attachment="top left" - class="orange-box" - }} - Inner Tether - {{/liquid-tether}} - {{/if}} {{/liquid-tether}} {{/liquid-tether}} - +{{/liquid-tether}} diff --git a/tests/dummy/app/pods/upgrading/template.md b/tests/dummy/app/pods/upgrading/template.md new file mode 100644 index 0000000..7981da5 --- /dev/null +++ b/tests/dummy/app/pods/upgrading/template.md @@ -0,0 +1,205 @@ +# Upgrading from Liquid Tether v1 + +One of the overall goals of Liquid Tether v2 was to simplify the API and bring +it more inline with vanilla Liquid Fire. Several breaking changes have been +made, and this article is meant as a guide to summarize them and describe an +upgrade path. + +## Removing the `to` attribute and `target` helper + +In v2, the `to` attribute is no longer needed by default, and `target` is not +used to match transitions. You can either change `to` to `stack`, or add it to +your tether's classes. You'll then be able to match it in your transitions +file using `this.matchSelector` or `this.hasClass` respectively. + +### Old: +```hbs +{{liquid-tether to="popup"}} +``` +```js +this.transition( + target('popup') +); +``` + +### New: +```hbs +{{liquid-tether class="popup"}} + + + +{{liquid-tether stack="popup"}} +``` +```js +this.transition( + this.hasClass('popup') +); + +// or + +this.transition( + this.matchSelector('#popup') +); +``` + +## Removing `tether` transitions + +The `tether` transition is no longer included or necessary. You can now use any +liquid-fire transition as if it were a normal transition: + +### Old: +``` +this.transition( + this.use('tether', 'to-left'); +) +``` + +### New: +``` +this.transition( + this.use('to-left'); +) +``` + + +## Replacing the `onOpenTether` and `onCloseTether` helpers + +The `onOpenTether` and `onCloseTether` helpers are deprecated in favor of +using the standard `toValue`, `fromValue`, and `betweenValues` matcher +functions. Whenever a tether is opening for the first time, the `fromValue` +will be `null`, and whenever a tether is closing, the so will the `toValue`. + +### Old: +```js +this.transition( + onOpenTether() +); + +this.transition( + onCloseTether() +); +``` + +### New: +```js +this.transition( + this.toValue(true) +); + +this.transition( + this.toValue(false) +); +``` + +Note: You may need to guard against objects being `null` if you were checking +properties on your tethers before. + +### Old: +```js +this.transition( + this.toValue((toValue, fromValue) => toValue.index > oldValue.index) +); +``` + +### New: +```js +this.transition( + this.toValue((toValue, fromValue) => { + return toValue && fromValue && toValue.index > oldValue.index; + }) +); +``` + +## Replacing `toValue` and `fromValue` matchers + +Wormholes are no longer directly passed in to their transition matchers. +Instead, the `value` property for a wormhole is passed in. You can move any of +the properties that you had into a `hash` helper and everything should work. +Remember, you may need to perform null checking. + +### Old: +```hbs +{{liquid-wormhole index=1}} +``` + +```js +this.transition( + this.toValue((toValue, fromValue) => toValue.index > oldValue.index) +); +``` + +### New: +```hbs +{{liquid-wormhole value=(hash index=1)}} +``` + +```js +this.transition( + this.toValue((toValue, fromValue) => { + return toValue && fromValue && toValue.index > oldValue.index; + }) +); +``` + +## Replacing `tetherClass` + +Classes that are applied to a tether will now work without anything extra, no +need to pass in a `tetherClass` attribute. + +### Old: +``` +{{liquid-tether tetherClass="modal"}} +``` + +### New: +``` +{{liquid-tether class="modal"}} +``` + +## Replacing Overlays + +Overlays were a feature in Liquid Tether v1, but were always awkward to deal +with. Their animations were tied to their Tether's animation, making it +difficult to have generic overlays, and you could only style them through the +`overlayClass`, and only make them actionable with `onOverlayClick`. + +The recommended approach to overlays is to now use a separate `liquid-wormhole` +with your overlay styles, actions, and transitions completely broken out from +your Tethers. This makes your code much cleaner and separates things by concern. + +Note: Tethers/Wormholes are applied in-order, so you will need to make sure that +overlays come _before_ the tethers in your templates. + +### Old: +``` +{{liquid-tether + to="modal" + overlayClass="modal-overlay" + onOverlayClick=(action "closeModal") +}} +``` + +``` +this.transition( + target('modal'), + this.use('tether', 'to-down', 'fade') +); +``` + +### New: +``` +{{liquid-wormhole class="modal-overlay" click=(action "closeModal")}} +{{liquid-tether class="modal"}} +``` + +``` +this.transition( + this.hasClass('modal'), + this.use('to-down') +); + +this.transition( + this.hasClass('modal-overlay'), + this.use('fade') +); +``` diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index 4080c49..74782d7 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -7,16 +7,22 @@ const Router = Ember.Router.extend({ }); Router.map(function() { - this.route('basics'); - this.route('examples', function() { - this.route('step-one'); - this.route('step-two'); + this.route('docs', function() { + this.route('parameters'); + this.route('stacks'); + this.route('routed-tethers', function() { + this.route('step-one'); + this.route('step-two'); + }); + this.route('dynamic-targets'); + this.route('destinations'); + this.route('components'); }); + this.route('upgrading'); this.route('scenarios', function() { this.route('multiple-tethers'); this.route('component-in-tether'); this.route('nested-tethers'); - this.route('multiple-targets-same-animation'); }); }); diff --git a/tests/dummy/app/styles/_bootstrap.scss b/tests/dummy/app/styles/_bootstrap.scss index f8ced14..dea6f4f 100644 --- a/tests/dummy/app/styles/_bootstrap.scss +++ b/tests/dummy/app/styles/_bootstrap.scss @@ -12,7 +12,7 @@ @return fade-out($color, 1 - ($percent / 100%)); } -// $brand-secondary: #d35400; +$brand-secondary: #d35400; // Flat UI Variables @import "flat-ui/variables"; @@ -109,7 +109,7 @@ $link-hover-color: $carrot; @import "flat-ui/modules/switch"; @import "flat-ui/modules/share"; -// Examples +// Docs @import "flat-ui/modules/palette"; @import "flat-ui/modules/tile"; @import "flat-ui/modules/todo"; diff --git a/tests/dummy/app/styles/_navigation.scss b/tests/dummy/app/styles/_navigation.scss index 84602ab..368f2b1 100644 --- a/tests/dummy/app/styles/_navigation.scss +++ b/tests/dummy/app/styles/_navigation.scss @@ -1,21 +1,36 @@ .navbar { - .navbar-brand { - font-weight: 400; + @media screen and (max-width: 768px) { + border-top-right-radius: 0; + border-top-left-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; } - .nav-item { - font-weight: 400; + .navbar-brand { + font-size: 20px; + line-height: 26px; + font-weight: 100; - &:first-child > a, &:last-child > a { - border-top-right-radius: 0; - border-top-left-radius: 0; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; + &:hover { + color: white; } } - .navbar-nav.navbar-left:first-child { - margin: 0; + .navbar-nav.navbar-left { + li > a { + font-weight: 400; + } + + &:first-child { + margin: 0; + + li:first-child > a { + border-top-right-radius: 0; + border-top-left-radius: 0; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + } + } } .navbar-toggle.fa { diff --git a/tests/dummy/app/styles/_popovers.scss b/tests/dummy/app/styles/_popovers.scss index 86db5bc..34864ea 100644 --- a/tests/dummy/app/styles/_popovers.scss +++ b/tests/dummy/app/styles/_popovers.scss @@ -3,15 +3,17 @@ // -------------------------------------------------- .popover { - background-color: white; + background-color: $belize-hole; + color: white; border: none; - border-left: solid 1px mix($brand-primary, white, 13%); - border-right: solid 1px mix($brand-primary, white, 13%); + border-left: solid 1px mix($wet-asphalt, $belize-hole, 20%); + border-right: solid 1px mix($wet-asphalt, $belize-hole, 20%); + border-bottom: solid 2px mix($wet-asphalt, $belize-hole, 20%); padding: 0; border-radius: 3px; display: block; position: relative; - @include box-shadow(0px 2px rgba(0,0,0,0.15)); + @include box-shadow(0px 2px rgba(0,0,0,0.25)); .arrow { width: 18px; @@ -21,32 +23,37 @@ -ms-transform: rotate(45deg); -webkit-transform: rotate(45deg); - background-color: mix($brand-primary, white, 1%); + background-color: $belize-hole; + color: white; } &.right .arrow { border: none; left: -9px; margin-top: -9px; - @include box-shadow(2px 2px rgba(0,0,0,0.15)); + @include box-shadow(2px 2px rgba(0,0,0,0.25)); } &.left .arrow { border: none; right: -9px; margin-top: -9px; - @include box-shadow(2px 2px rgba(0,0,0,0.15)); + @include box-shadow(2px 2px rgba(0,0,0,0.25)); } - &.bottom .arrow { - border: none; - margin-right: -9px; - top: -9px; - @include box-shadow(2px 2px rgba(0,0,0,0.15)); + &.bottom { + margin-top: 0; + top: 15px; + .arrow { + border: none; + margin-right: -9px; + top: -9px; + @include box-shadow(2px 2px rgba(0,0,0,0.25)); + } } &.top .arrow { border: none; bottom: -9px; margin-left: -9px; - @include box-shadow(2px 2px rgba(0,0,0,0.15)); + @include box-shadow(2px 2px rgba(0,0,0,0.25)); } .arrow { border-width: 9px; @@ -60,27 +67,41 @@ // Popover Title .popover-title { position: relative; - background-color: mix($brand-primary, white, 1%); - color: $text-color; + background-color: $belize-hole; + color: white; font-size: $component-font-size-base; line-height: 1.5; font-weight: 100; font-size: 1.2em; padding: 10px 20px 11px; - border-top-left-radius: 3px; - border-top-right-radius: 3px; + border-radius: 3px; white-space: nowrap; + border-bottom: none; } // Popover Content .popover-content { font-weight: 100; position: relative; - background-color: mix($brand-primary, white, 1%); - padding: 9px 20px 9px; + background-color: $belize-hole; + color: white; + padding: 0px 20px 9px; + text-align: right; + + border-radius: 3px; - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; + a { + display: inline-block; + color: white; + text-decoration: underline; + + margin-left: 5px; + font-size: 14px; + + &:hover { + color: cloud; + } + } p { font-size: ceil($component-font-size-base * 0.933); // ~14px diff --git a/tests/dummy/app/styles/_typography.scss b/tests/dummy/app/styles/_typography.scss index 6457fcc..2cc671d 100644 --- a/tests/dummy/app/styles/_typography.scss +++ b/tests/dummy/app/styles/_typography.scss @@ -4,19 +4,37 @@ a { cursor: pointer; } +p { + font-size: 1em; +} + h1 { font-size: 2em; - font-weight: 100; + font-weight: normal; + margin-top: 0; } h2 { font-size: 1.5em; - font-weight: 100; + font-weight: normal; margin-top: 0; } +h3 { + font-size: 1.25em; + font-weight: normal; + margin-top: 0; +} + +// Tab content pre, pre.hljs { - background-color: transparent; - padding: 0; - border: none; + border: 2px solid #ddd; + background-color: #fff; + border-radius: $nav-border-radius; + margin-bottom: 20px; + padding: 20px; + + code { + white-space: pre; + } } diff --git a/tests/dummy/app/styles/app.scss b/tests/dummy/app/styles/app.scss index 835367e..7c08e83 100644 --- a/tests/dummy/app/styles/app.scss +++ b/tests/dummy/app/styles/app.scss @@ -8,32 +8,44 @@ body { margin: 0; - background-color: $clouds; - font-weight: 100; + font-size: 14px; // don't show scrollbars for certain transitions overflow-x: hidden; } .main-container { - padding: 80px 20px 100px; + @extend .container; @media screen and (min-width: 768px) { - padding: 0 20px 100px; + padding: 20px; } } +.top-right { + position: fixed; + top: 20px; + right: 20px; + margin: 0; +} + +.feature-example { + font-size: 10em; + text-align: center; +} + .example-button-container { margin: 40px; + text-align: center; +} - &.frontpage { - #hello-world { - margin: 60px 0; - } - } +.front-page-container-1 { + margin-bottom: 20px; + text-align: center; } -#hello-world-popover { - max-width: 430px; +.front-page-container-2 { + margin-bottom: 40px; + text-align: center; } .fixed-to-bottom { @@ -59,10 +71,104 @@ body { background-color: green; } -.orange-box { - background-color: orange; -} - .yellow-box { background-color: yellow; } + +/* +github.com style (c) Vasily Polovnyov +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} + +.hljs-comment, +.hljs-quote { + color: #998; + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} + +.hljs-string, +.hljs-doctag { + color: #d14; +} + +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} + +.hljs-subst { + font-weight: normal; +} + +.hljs-type, +.hljs-class .hljs-title { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} + +.hljs-regexp, +.hljs-link { + color: #009926; +} + +.hljs-symbol, +.hljs-bullet { + color: #990073; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/tests/dummy/app/transitions.js b/tests/dummy/app/transitions.js index 8ba9d76..e18979d 100644 --- a/tests/dummy/app/transitions.js +++ b/tests/dummy/app/transitions.js @@ -1,86 +1,51 @@ -import { onOpenTether } from 'liquid-tether'; - -const options = { duration: 500, easing: [200, 22] }; +const options = { duration: 800, easing: [200, 22] }; export default function() { this.transition( this.hasClass('hello-world'), - this.use('fade-left', { duration: 400, easing: [600, 22] }) + this.use('fade-down', { duration: 400, easing: [600, 22] }) ); - /* Modal Examples */ + /* Modal Docs */ this.transition( - this.matchSelector('#my-modal'), + this.matchSelector('#modal-backdrop'), this.toValue((toValue, fromValue) => toValue === null || fromValue === null), this.use('fade') ); this.transition( - this.matchSelector('#my-modal'), - this.toValue((toValue, fromValue) => toValue && fromValue && toValue.index > fromValue.index), - this.use('to-left', options), - this.reverse('to-right', options) + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') ); - - /* Flyto Example */ - this.transition( - this.hasClass('flyto'), - this.toValue(({ index }) => !index), - this.use('to-left', options) + this.matchSelector('#modal-dialog'), + this.toValue((toValue, fromValue) => toValue && fromValue && toValue > fromValue), + this.use('to-left', options), + this.reverse('to-right', options) ); - this.transition( - this.hasClass('flyto'), - this.toValue(({ index: newIndex }, { index: oldIndex }) => newIndex > oldIndex), - this.use('tether', 'fly-to', options), - this.reverse('tether', 'fly-to', options) - ); + + /* Dynamic Targets Example */ this.transition( - this.hasClass('flyto'), - this.toValue(({ index }) => index === 1), - this.use('to-right', options) + this.hasClass('tour'), + this.toValue((toValue, fromValue) => toValue === null || fromValue === null), + this.use('fade') ); - /* Flyout Example */ - this.transition( - this.hasClass('flyout'), - onOpenTether(), - this.use('explode', { - pick: '.flyout', - use: ['to-left', { duration: 400, easing: [200, 22] }] - }, { - pick: '.modal-backdrop', - use: 'fade' - }), - this.reverse('explode', { - pick: '.flyout', - use: ['to-right', { duration: 400, easing: [200, 22] }] - }, { - pick: '.modal-backdrop', - use: 'fade' - }) + this.hasClass('tour'), + this.use('fly-to') ); /* Scenarios */ this.transition( this.hasClass('component-in-tether'), - this.use('tether', ['fade', options]) - ); - - this.transition( - this.hasClass(/multiple-[1,3]/), - this.use('tether', ['fade', options]) - ); - - this.transition( - this.hasClass(/multiple-2/), - this.use('tether', ['to-up', options]) + this.use('fade', options) ); this.transition( diff --git a/tests/dummy/app/transitions/fade-direction.js b/tests/dummy/app/transitions/fade-direction.js new file mode 100644 index 0000000..cee6bd8 --- /dev/null +++ b/tests/dummy/app/transitions/fade-direction.js @@ -0,0 +1,47 @@ +import { isAnimating, finish, timeSpent, animate, stop } from 'liquid-fire'; + +export default function fade(dimension, direction, opts, offset=20) { + const oldParams = { opacity: 0 }, + newParams = { opacity: [(opts.maxOpacity || 1), 0] }, + fadingElement = findFadingElement(this); + + let outOpts = opts, + firstStep; + + if (dimension.toLowerCase() === 'x') { + oldParams.translateX = `${(direction * offset)}px`; + newParams.translateX = ['0px', `${(direction * offset)}px`]; + } else { + oldParams.translateY = `${(direction * offset)}px`; + newParams.translateY = ['0px', `${(direction * offset)}px`]; + } + + if (fadingElement) { + // We still have some older version that is in the process of + // fading out, so out first step is waiting for it to finish. + firstStep = finish(fadingElement, 'fade-out'); + } else { + if (isAnimating(this.oldElement, 'fade-in')) { + // if the previous view is partially faded in, scale its + // fade-out duration appropriately. + outOpts = { duration: timeSpent(this.oldElement, 'fade-in') }; + } + stop(this.oldElement); + firstStep = animate(this.oldElement, oldParams, outOpts, 'fade-out'); + } + return firstStep.then(() => { + return animate(this.newElement, newParams, opts, 'fade-in'); + }); +} + +function findFadingElement(context) { + for (var i = 0; i < context.older.length; i++) { + var entry = context.older[i]; + if (isAnimating(entry.element, 'fade-out')) { + return entry.element; + } + } + if (isAnimating(context.oldElement, 'fade-out')) { + return context.oldElement; + } +} diff --git a/tests/dummy/app/transitions/fade-down.js b/tests/dummy/app/transitions/fade-down.js new file mode 100644 index 0000000..1ecc2bc --- /dev/null +++ b/tests/dummy/app/transitions/fade-down.js @@ -0,0 +1,4 @@ +import fadeDirection from './fade-direction'; +export default function(opts={}) { + return fadeDirection.call(this, 'y', -1, opts, opts.offset); +} diff --git a/tests/dummy/app/transitions/fade-left.js b/tests/dummy/app/transitions/fade-left.js new file mode 100644 index 0000000..325f7da --- /dev/null +++ b/tests/dummy/app/transitions/fade-left.js @@ -0,0 +1,4 @@ +import fadeDirection from './fade-direction'; +export default function(opts={}) { + return fadeDirection.call(this, 'x', -1, opts, opts.offset); +} diff --git a/tests/dummy/app/transitions/fade-right.js b/tests/dummy/app/transitions/fade-right.js new file mode 100644 index 0000000..9e8906a --- /dev/null +++ b/tests/dummy/app/transitions/fade-right.js @@ -0,0 +1,4 @@ +import fadeDirection from './fade-direction'; +export default function(opts={}) { + return fadeDirection.call(this, 'x', 1, opts, opts.offset); +} diff --git a/tests/dummy/app/transitions/fade-up.js b/tests/dummy/app/transitions/fade-up.js new file mode 100644 index 0000000..f336220 --- /dev/null +++ b/tests/dummy/app/transitions/fade-up.js @@ -0,0 +1,4 @@ +import fadeDirection from './fade-direction'; +export default function(opts={}) { + return fadeDirection.call(this, 'y', 1, opts, opts.offset); +} diff --git a/tests/dummy/snippets/routed-modal.hbs b/tests/dummy/snippets/routed-modal.hbs index be3244a..74d526b 100644 --- a/tests/dummy/snippets/routed-modal.hbs +++ b/tests/dummy/snippets/routed-modal.hbs @@ -1,7 +1,7 @@ - +
    - {{#link-to "examples.modal"}}Open Routed Modal{{/link-to}} + {{#link-to "docs.modal"}}Open Routed Modal{{/link-to}}
    @@ -26,8 +26,8 @@
    {{/liquid-tether}} diff --git a/tests/dummy/snippets/tether-dom-structure.hbs b/tests/dummy/snippets/tether-dom-structure.hbs index 3656eab..8f08358 100644 --- a/tests/dummy/snippets/tether-dom-structure.hbs +++ b/tests/dummy/snippets/tether-dom-structure.hbs @@ -1,6 +1,6 @@ -
    -
    +
    +
    diff --git a/tests/helpers/integration.js b/tests/helpers/integration.js index ce9e0df..945ba84 100644 --- a/tests/helpers/integration.js +++ b/tests/helpers/integration.js @@ -5,48 +5,22 @@ function transitionMap(app) { return app.__container__.lookup('service:liquid-fire-transitions'); } -function transitionName(name) { +function wormholeTransitionName(name) { return sinon.match(function(value) { - return value.animation ? value.animation.name === name : false; - }, 'expected transition ' + name); -} - -function tetherTransitionName(name) { - return sinon.match(function(value) { - if (value.animation) { - return Array.isArray(value.animation.args[0]) ? value.animation.args[0][0] === name : value.animation.args[0] === name; + if (value.animation && value.animation.name === 'wormhole') { + return value.animation.args[0].use.name === name; } - }, 'expected transition ' + name); -} -function overlayTransitionName(name) { - return sinon.match(function(value) { - if (value.animation) { - return Array.isArray(value.animation.args[1]) ? value.animation.args[1][0] === name : value.animation.args[1] === name; - } + return false; }, 'expected transition ' + name); } Ember.Test.registerHelper( - 'ranTransition', + 'ranWormholeTransition', function(app, name) { - ok(transitionMap(app).transitionFor.returned(transitionName(name)), `expected transition ${name}`); + ok(transitionMap(app).transitionFor.returned(wormholeTransitionName(name)), `expected transition ${name}`); }); -Ember.Test.registerHelper( - 'ranTetherTransition', - function(app, name) { - ok(transitionMap(app).transitionFor.returned(tetherTransitionName(name)), `expected transition ${name}`); - } -); - -Ember.Test.registerHelper( - 'ranOverlayTransition', - function(app, name) { - ok(transitionMap(app).transitionFor.returned(overlayTransitionName(name)), `expected transition ${name}`); - } -); - Ember.Test.registerHelper( 'noTransitionsYet', function(app) { diff --git a/tests/index.html b/tests/index.html index 4cc6add..f5d531c 100644 --- a/tests/index.html +++ b/tests/index.html @@ -14,40 +14,6 @@ - - {{content-for "head-footer"}} {{content-for "test-head-footer"}}