From f71be55c909a1d6a04d850ded0d92c711235d07f Mon Sep 17 00:00:00 2001 From: Kyle Bishop Date: Wed, 30 Aug 2017 21:15:48 -0700 Subject: [PATCH] feat(attach-tooltip component) has expected tooltip defaults --- addon/components/attach-tooltip.js | 24 ++++ addon/components/ember-attacher.js | 1 + app/components/attach-tooltip.js | 1 + tests/dummy/app/styles/app.scss | 77 ++++++------ .../components/attachment-example.hbs | 116 ++++++++++-------- .../components/attach-tooltip-test.js | 43 +++++++ 6 files changed, 173 insertions(+), 89 deletions(-) create mode 100644 addon/components/attach-tooltip.js create mode 100644 app/components/attach-tooltip.js create mode 100644 tests/integration/components/attach-tooltip-test.js diff --git a/addon/components/attach-tooltip.js b/addon/components/attach-tooltip.js new file mode 100644 index 00000000..a4833eb8 --- /dev/null +++ b/addon/components/attach-tooltip.js @@ -0,0 +1,24 @@ +import EmberAttacher from './ember-attacher'; +import { computed } from '@ember/object'; + +const DEFAULT_TOOLTIP_CLASS = 'ember-attacher-popper ember-attacher-tooltip'; + +export default EmberAttacher.extend({ + actions: { + onFoundTarget(target) { + this._super(...arguments); + + target.setAttribute('aria-describedby', this.id); + } + }, + + class: computed({ + get() { + return DEFAULT_TOOLTIP_CLASS; + }, + + set(_key, value) { + return `${DEFAULT_TOOLTIP_CLASS} ${value}`; + } + }) +}); diff --git a/addon/components/ember-attacher.js b/addon/components/ember-attacher.js index c8a075d5..5320ad21 100644 --- a/addon/components/ember-attacher.js +++ b/addon/components/ember-attacher.js @@ -62,6 +62,7 @@ export default Component.extend({ interactive: DEFAULTS.interactive, isOffset: DEFAULTS.isOffset, isShown: DEFAULTS.isShown, + onChange: null, placement: DEFAULTS.placement, popperContainer: DEFAULTS.popperContainer, popperOptions: DEFAULTS.popperOptions, diff --git a/app/components/attach-tooltip.js b/app/components/attach-tooltip.js new file mode 100644 index 00000000..e6e328bb --- /dev/null +++ b/app/components/attach-tooltip.js @@ -0,0 +1 @@ +export { default } from 'ember-attacher/components/attach-tooltip'; \ No newline at end of file diff --git a/tests/dummy/app/styles/app.scss b/tests/dummy/app/styles/app.scss index 9330dedb..776531c6 100644 --- a/tests/dummy/app/styles/app.scss +++ b/tests/dummy/app/styles/app.scss @@ -2,12 +2,12 @@ body { color: #fcfcfc; - margin: 0; font-family: helvetica; font-size: 18px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - max-height:100vh; + margin: 0; + max-height: 100vh; overflow: auto; } @@ -45,50 +45,51 @@ p { .nav { background-color: #eee; color: #333; + cursor: pointer; font-size: 16px; padding: 8px; -} -.nav.active { - background-color: #ddd; - font-weight: bold; + &.active { + background-color: #ddd; + font-weight: bold; + } } -.edit-section, .section { +.edit-section, +.section { padding: 18px; padding-bottom: 0; } .button { - position: relative; - border-top: 1px solid #aaaaaa; + background-color: #fff; border-bottom: 1px solid #aaaaaa; - border-right: 1px solid #aaaaaa; border-left: 1px solid #aaaaaa; border-radius: 4px; - background-color: #ffffff; - line-height: 1.75; + border-right: 1px solid #aaaaaa; + border-top: 1px solid #aaaaaa; color: #333; - background-color: #fff; - font-size: inherit; font-family: monospace; + font-size: inherit; + line-height: 1.75; margin: 1px; + position: relative; text-align: center; -} -.button.medium { - min-width: 80px; - width: 80px; -} + &.medium { + min-width: 80px; + width: 80px; + } -.button.large { - min-width: 145px; - width: 145px; -} + &.large { + min-width: 145px; + width: 145px; + } -.button.xlarge { - min-width: 185px; - width: 185px; + &.xlarge { + min-width: 185px; + width: 185px; + } } .edit-me { @@ -122,26 +123,26 @@ p { background-color: #fff; border: 1px solid #ddd; color: #333; - padding: 0.5rem 1rem; + padding: .5rem 1rem; position: relative; &.ember-attacher-fill { - overflow: hidden; background-color: transparent; + overflow: hidden; } > div[x-circle] { background-color: #fff; - position: absolute; - will-change: transform; border-radius: 50%; - width: 120%; - width: calc(100% + 2rem); left: 50%; - transition: all ease-out; - z-index: -1; opacity: 0; overflow: hidden; + position: absolute; + transition: all ease-out; + width: 120%; + width: calc(100% + 2rem); + will-change: transform; + z-index: -1; &::before { content: ''; @@ -178,7 +179,8 @@ p { width: 160px; } - .edit-me, .nav { + .edit-me, + .nav { font-size: 15px; } @@ -188,8 +190,9 @@ p { } } -@media(max-width: 330px) { - .edit-me, .nav { +@media(max-width: 331px) { + .edit-me, + .nav { font-size: 14px; } } diff --git a/tests/dummy/app/templates/components/attachment-example.hbs b/tests/dummy/app/templates/components/attachment-example.hbs index f78790a4..b5e6ec90 100644 --- a/tests/dummy/app/templates/components/attachment-example.hbs +++ b/tests/dummy/app/templates/components/attachment-example.hbs @@ -1,13 +1,12 @@ -

Drop an \{{#ember-attacher}} in any element or component to get started.

+

Drop an \{{#attach-tooltip}} or \{{#ember-attacher}} in any element or component to get started.

@@ -202,11 +210,11 @@ onChange - {{#ember-attacher class="ember-attacher-popper ember-attacher-tooltip"}} + {{#attach-tooltip}} An action to be fired when the attachment's visibility changes. - {{/ember-attacher}} + {{/attach-tooltip}} - =(action (mut service.isShown)) + =(action (mut isShown)) @@ -228,7 +236,7 @@ renderInPlace - {{#ember-attacher animation="shift" class="ember-attacher-popper ember-attacher-tooltip"}} + {{#attach-tooltip animation="shift"}} Elements that exist deep within the document tree are given an implicitly lower z-index value than elements that aren't as deep in the tree; this has the effect of hiding our popper behind less-nested elements. Due to the way z-indexing works, we cannot simply @@ -236,7 +244,7 @@ on the document body, giving it the highest default z-index value. Toggling renderInPlace will prevent the popper from being rendered elsewhere, but may cause the aforementioned z-index issues. - {{/ember-attacher}} + {{/attach-tooltip}} =