From 3c46a09353e8e8e2867437fff5fdf2d3243ca2b0 Mon Sep 17 00:00:00 2001 From: Christopher Garrett Date: Wed, 31 Aug 2016 17:46:04 -0700 Subject: [PATCH 1/2] Initial cut --- addon/components/liquid-tether.js | 67 +++--- addon/styles/addon.css | 151 ++++++++++++- addon/templates/components/liquid-tether.hbs | 7 +- app/transitions/tether.js | 20 +- package.json | 6 +- tests/acceptance/demo-test.js | 15 +- tests/acceptance/scenarios-test.js | 15 +- tests/dummy/app/styles/_flyouts.scss | 17 +- tests/dummy/app/styles/_modals.scss | 1 + tests/dummy/app/styles/_tabs.scss | 2 +- tests/dummy/app/styles/app.scss | 2 +- tests/dummy/app/templates/examples.hbs | 200 +++++++++--------- .../dummy/app/templates/examples/step-one.hbs | 7 +- .../dummy/app/templates/examples/step-two.hbs | 7 +- tests/dummy/app/templates/index.hbs | 12 +- tests/dummy/app/transitions.js | 56 +++-- tests/helpers/app-lifecycle.js | 25 --- 17 files changed, 359 insertions(+), 251 deletions(-) delete mode 100644 tests/helpers/app-lifecycle.js diff --git a/addon/components/liquid-tether.js b/addon/components/liquid-tether.js index 73e1042..26ed3cf 100644 --- a/addon/components/liquid-tether.js +++ b/addon/components/liquid-tether.js @@ -9,8 +9,6 @@ const { camelize } = Ember.String; export default LiquidWormhole.extend({ layout: layout, - to: 'liquid-tether', - classPrefix: 'liquid-tether', target: null, attachment: null, @@ -21,14 +19,24 @@ export default LiquidWormhole.extend({ constraints: null, optimizations: null, + _containerClass: 'liquid-tether-container', + didInsertElement() { - this._tetherElement = this.$('.liquid-tether')[0]; + this._tetherElement = this.element.firstChild; this._super.apply(this, arguments); }, + willAppendNodes(bodyElement) { + this.addTether(bodyElement); + }, + didAppendNodes() { - this.addTether(); + this._tether.position(); + }, + + willRemoveNodes() { + this._tether.position(); }, willDestroyElement() { @@ -39,10 +47,28 @@ export default LiquidWormhole.extend({ }); }, - addTether() { - if (get(this, '_tetherTarget')) { - this._tether = new Tether(this._tetherOptions()); - } + addTether(bodyElement) { + const target = this.get('_tetherTarget'); + const element = this._tetherElement; + + const options = { element, target, bodyElement }; + + [ 'classPrefix', + 'attachment', + 'targetAttachment', + 'offset', + 'targetOffset', + 'targetModifier', + 'constraints', + 'optimizations' + ].forEach((k) => { + const v = get(this, k); + if (!Ember.isNone(v)) { + options[camelize(k)] = v; + } + }); + + this._tether = new Tether(options); }, removeTether() { @@ -61,7 +87,7 @@ export default LiquidWormhole.extend({ 'targetModifier', 'constraints', 'optimizations', - 'liquidTarget', + 'to', function() { this.removeTether(this._tether); this.addTether(); @@ -78,29 +104,6 @@ export default LiquidWormhole.extend({ return target; }), - _tetherOptions() { - let options = { - element: this._tetherElement, - target: get(this, '_tetherTarget'), - moveRoot: false - }; - [ 'classPrefix', - 'attachment', - 'targetAttachment', - 'offset', - 'targetOffset', - 'targetModifier', - 'constraints', - 'optimizations' - ].forEach((k) => { - const v = get(this, k); - if (!Ember.isNone(v)) { - options[camelize(k)] = v; - } - }); - return options; - }, - actions: { clickOverlay() { if (this.get('on-overlay-click')) { diff --git a/addon/styles/addon.css b/addon/styles/addon.css index a4050a0..2e8f3b7 100644 --- a/addon/styles/addon.css +++ b/addon/styles/addon.css @@ -1,3 +1,150 @@ -.liquid-tether-element { - position: absolute; +.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 index 0f4a273..2ceb1ec 100644 --- a/addon/templates/components/liquid-tether.hbs +++ b/addon/templates/components/liquid-tether.hbs @@ -1,4 +1,5 @@ -
-
- {{yield}} +
+
+ {{yield}} +
diff --git a/app/transitions/tether.js b/app/transitions/tether.js index 99dec6a..29b14cc 100644 --- a/app/transitions/tether.js +++ b/app/transitions/tether.js @@ -1,18 +1,8 @@ import explode from './explode'; -export default function tether(tetherUse, overlayUse) { - const transitions = []; - transitions.push({ - pick: '.liquid-tether > :first-child', - use: tetherUse - }); - - if (overlayUse) { - transitions.unshift({ - pick: '.liquid-tether-overlay', - use: overlayUse - }); - } - - return explode.apply(this, transitions); +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 3017187..06e6955 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "ember-cli-sri": "^2.1.0", "ember-cli-uglify": "^1.2.0", "ember-code-snippet": "1.1.3", - "liquid-fire": "0.22.1", + "liquid-fire": "0.24.1", "ui-tabs": "firefly-ui/ui-tabs", "phantomjs": "^2.0.0", "ember-data": "^2.4.0", @@ -51,8 +51,8 @@ "dependencies": { "broccoli-funnel": "^0.2.8", "broccoli-merge-trees": "^0.2.3", - "liquid-wormhole": "^1.0.0", - "tether": "pzuraq/tether#move-root-disable-1.3.1", + "liquid-wormhole": "pzuraq/liquid-wormhole#v2.0.0-beta.1", + "tether": "pzuraq/tether#adds-option-to-specify-body-element", "ember-cli-htmlbars": "^1.0.1", "ember-cli-babel": "^5.1.5" }, diff --git a/tests/acceptance/demo-test.js b/tests/acceptance/demo-test.js index f916e3c..a28ec49 100644 --- a/tests/acceptance/demo-test.js +++ b/tests/acceptance/demo-test.js @@ -1,22 +1,15 @@ /* global ranTetherTransition, ranOverlayTransition, noTransitionsYet */ -import { startApp, destroyApp } from '../helpers/app-lifecycle'; +import moduleForAcceptance from '../helpers/module-for-acceptance'; import { injectTransitionSpies } from '../helpers/integration'; -let app; - -module('Acceptance: Demos', { - setup: function() { - app = startApp(); +moduleForAcceptance('Acceptance | Demos', { + beforeEach() { // Conceptually, integration tests shouldn't be digging around in // the container. But animations are slippery, and it's easier to // just spy on them to make sure they're being run than to try to // observe their behavior more directly. - injectTransitionSpies(app); - }, - - teardown: function() { - destroyApp(app); + injectTransitionSpies(this.application); } }); diff --git a/tests/acceptance/scenarios-test.js b/tests/acceptance/scenarios-test.js index 0ce055d..63b2859 100644 --- a/tests/acceptance/scenarios-test.js +++ b/tests/acceptance/scenarios-test.js @@ -1,22 +1,15 @@ /* global ranTetherTransition */ -import { startApp, destroyApp } from '../helpers/app-lifecycle'; +import moduleForAcceptance from '../helpers/module-for-acceptance'; import { injectTransitionSpies } from '../helpers/integration'; -let app; - -module('Acceptance: Scenarios', { - setup: function() { - app = startApp(); +moduleForAcceptance('Acceptance | Scenarios', { + beforeEach() { // Conceptually, integration tests shouldn't be digging around in // the container. But animations are slippery, and it's easier to // just spy on them to make sure they're being run than to try to // observe their behavior more directly. - injectTransitionSpies(app); - }, - - teardown: function() { - destroyApp(app); + injectTransitionSpies(this.application); } }); diff --git a/tests/dummy/app/styles/_flyouts.scss b/tests/dummy/app/styles/_flyouts.scss index bf91fa9..f46d912 100644 --- a/tests/dummy/app/styles/_flyouts.scss +++ b/tests/dummy/app/styles/_flyouts.scss @@ -3,8 +3,8 @@ position: fixed; top: 0; bottom: 0; - right: 0; - padding: 20px 24px 20px; + right: -50px; + padding: 20px 74px 20px 24px; transform: translateX(0); -ms-transform: translateX(0); @@ -16,3 +16,16 @@ border-left: 2px solid $modal-content-border-color; @include box-shadow(0px 2px rgba(0,0,0,0.15)); } + +.notification { + width: 500px; + position: fixed; + top: 10px; + right: 10px; + + z-index: $zindex-modal; + + background-color: $modal-content-bg; + border-left: 2px solid $modal-content-border-color; + @include box-shadow(0px 2px rgba(0,0,0,0.15)); +} diff --git a/tests/dummy/app/styles/_modals.scss b/tests/dummy/app/styles/_modals.scss index f40bdd7..0f35b9a 100644 --- a/tests/dummy/app/styles/_modals.scss +++ b/tests/dummy/app/styles/_modals.scss @@ -32,6 +32,7 @@ $zindex-modal: 1050; // Container that the modal scrolls within .modal { display: block; + position: static; margin: 0; z-index: $zindex-modal-background; } diff --git a/tests/dummy/app/styles/_tabs.scss b/tests/dummy/app/styles/_tabs.scss index 7baa3ad..f5d86a6 100644 --- a/tests/dummy/app/styles/_tabs.scss +++ b/tests/dummy/app/styles/_tabs.scss @@ -216,7 +216,7 @@ $nav-list-gap: 13px; padding: 20px 20px 5px; position: relative; z-index: 1; - max-height: 700px; + height: 700px; overflow: scroll; > div { diff --git a/tests/dummy/app/styles/app.scss b/tests/dummy/app/styles/app.scss index a16ddb1..bab0e7a 100644 --- a/tests/dummy/app/styles/app.scss +++ b/tests/dummy/app/styles/app.scss @@ -39,7 +39,7 @@ body { .fixed-to-bottom { position: fixed; bottom: 0; - padding: 20px 24px 20px 0; + padding: 20px 74px 20px 0; } .red-box, .blue-box, .green-box { diff --git a/tests/dummy/app/templates/examples.hbs b/tests/dummy/app/templates/examples.hbs index f6c5afe..1c3894c 100644 --- a/tests/dummy/app/templates/examples.hbs +++ b/tests/dummy/app/templates/examples.hbs @@ -18,11 +18,11 @@ {{#if showHello}} {{#liquid-tether - to="hello-world" target="#hello-world-button" attachment="middle left" targetAttachment="middle right" - class="container123" + + class="hello-world" tetherClass="tether123" overlayClass="overlay123" }} @@ -68,86 +68,89 @@
{{#if showFirstModalDialog}} + {{liquid-wormhole stack="modal-backdrop" class="modal-backdrop"}} + {{#liquid-tether - to="modal-dialog" + stack="my-modal" index=1 + target="document.body" targetModifier="visible" attachment="middle center" - tetherClass="modal-dialog" - overlayClass="modal-backdrop" - on-overlay-click="closeModalDialog"}} -