From b486500798bf1d104587a4541cd26d2513c2f078 Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 15:39:52 -0500 Subject: [PATCH 1/6] Text property added with test and example in demo --- addon/components/lazy-render-wrapper.js | 1 + .../components/lazy-render-wrapper.hbs | 10 +++++++--- tests/dummy/app/templates/index.hbs | 16 +++++++++++++++ tests/integration/components/text-test.js | 20 +++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 tests/integration/components/text-test.js diff --git a/addon/components/lazy-render-wrapper.js b/addon/components/lazy-render-wrapper.js index ce55a8f2..7f13d942 100644 --- a/addon/components/lazy-render-wrapper.js +++ b/addon/components/lazy-render-wrapper.js @@ -37,6 +37,7 @@ const PASSABLE_PROPERTIES = [ 'tooltipIsVisible', 'hideDelay', 'target', + 'text', // non-publicized attributes 'updateFor', diff --git a/addon/templates/components/lazy-render-wrapper.hbs b/addon/templates/components/lazy-render-wrapper.hbs index 89cc3bd0..3b98fa15 100644 --- a/addon/templates/components/lazy-render-wrapper.hbs +++ b/addon/templates/components/lazy-render-wrapper.hbs @@ -4,9 +4,13 @@ class=class id=id }} - {{yield (hash - hide=(action "hide") - )}} + {{#if text}} + {{text}} + {{else}} + {{yield (hash + hide=(action "hide") + )}} + {{/if}} {{/component}} {{/if}} diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index 8050854b..5ebcee00 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -52,6 +52,7 @@
  • Using custom styling
  • Using async content
  • Using a popover instead of a tooltip
  • +
  • Using in inline form
  • @@ -205,3 +206,18 @@ {{code-snippet name='popover.hbs'}} + +
    +

    Using in inline form

    + +{{!-- BEGIN-SNIPPET async-content --}} +{{#some-component}} + Tooltip has async content + + {{tooltip-on-component text='More info here'}} +{{/some-component}} +{{!-- END-SNIPPET --}} + + {{code-snippet name='async-content.hbs'}} + +
    diff --git a/tests/integration/components/text-test.js b/tests/integration/components/text-test.js new file mode 100644 index 00000000..6b45cf46 --- /dev/null +++ b/tests/integration/components/text-test.js @@ -0,0 +1,20 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('tooltip-on-element', 'Integration | Component | text', { + integration: true +}); + +test('It renders', function(assert) { + + this.render(hbs` + {{tooltip-on-element text='Here is more info'}} + `); + + assert.equal(this.$().text().trim(), 'Here is more info', + 'Should render with content equal to the text property'); + + assert.ok(this.$().find('.ember-tooltip').length, + 'Should create a tooltip element'); + +}); From aa1f7550317f92179e9912927de2d1d304a1e634 Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 15:41:24 -0500 Subject: [PATCH 2/6] Documentation added --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 8961379c..5ae8fb14 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ Version 2.4.0 introduces lazy rendering. Tooltips and popovers generally don't n The easiest way to add a tooltip to any component is with the `{{tooltip-on-component}}` component: +```hbs +{{#my-component}} + Hover for more info + + {{tooltip-on-component 'Here is more info!'}} +{{/my-component}} +``` + +Or in block form: + ```hbs {{#my-component}} Hover for more info @@ -72,6 +82,16 @@ If you want to add a tooltip to an element that is not an Ember component, you c By default, the tooltip will attach itself to its parent element: +```hbs +
    + Hover for more info + + {{tooltip-on-element text='Here is more info!'}} +
    +``` + +Or in block form: + ```hbs
    Hover for more info From cb2e9558daa78c702e5d7fc3cf19b5925ed2e38f Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 15:43:07 -0500 Subject: [PATCH 3/6] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ae8fb14..242fcde7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The easiest way to add a tooltip to any component is with the `{{tooltip-on-comp {{#my-component}} Hover for more info - {{tooltip-on-component 'Here is more info!'}} + {{tooltip-on-component text='Here is more info!'}} {{/my-component}} ``` From 0e9088f82baac5c00d4916c24ba4d0c4f1c4b518 Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 20:19:28 -0500 Subject: [PATCH 4/6] Using hasBlock instead of text in template if --- addon/templates/components/lazy-render-wrapper.hbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/templates/components/lazy-render-wrapper.hbs b/addon/templates/components/lazy-render-wrapper.hbs index 3b98fa15..e17fad28 100644 --- a/addon/templates/components/lazy-render-wrapper.hbs +++ b/addon/templates/components/lazy-render-wrapper.hbs @@ -4,12 +4,12 @@ class=class id=id }} - {{#if text}} - {{text}} - {{else}} + {{#if hasBlock}} {{yield (hash hide=(action "hide") )}} + {{else}} + {{text}} {{/if}} {{/component}} {{/if}} From e5842faa248a48ba8f1508f56959fa46f53ff945 Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 20:22:46 -0500 Subject: [PATCH 5/6] Code snippet renamed for inline-content demo --- tests/dummy/app/templates/index.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index 5ebcee00..ed89889a 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -210,7 +210,7 @@

    Using in inline form

    -{{!-- BEGIN-SNIPPET async-content --}} +{{!-- BEGIN-SNIPPET inline-content --}} {{#some-component}} Tooltip has async content @@ -218,6 +218,6 @@ {{/some-component}} {{!-- END-SNIPPET --}} - {{code-snippet name='async-content.hbs'}} + {{code-snippet name='inline-content.hbs'}}
    From e35bcbfe1324078e37acd29d5febe72fe7a4e806 Mon Sep 17 00:00:00 2001 From: Duncan Graham Walker Date: Wed, 23 Nov 2016 20:23:35 -0500 Subject: [PATCH 6/6] Copy changed in text-test --- tests/integration/components/text-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/components/text-test.js b/tests/integration/components/text-test.js index 6b45cf46..58cb7535 100644 --- a/tests/integration/components/text-test.js +++ b/tests/integration/components/text-test.js @@ -1,11 +1,11 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -moduleForComponent('tooltip-on-element', 'Integration | Component | text', { +moduleForComponent('tooltip-on-element', 'Integration | Component | inline', { integration: true }); -test('It renders', function(assert) { +test('tooltip-on-element renders with text param', function(assert) { this.render(hbs` {{tooltip-on-element text='Here is more info'}}