Tooltip refactoring

Let's refactor some tooltip code into a reusable component.

Summary

In this video we'll refactor some existing tooltip code into a reusable component.

Originally, using a tooltip on EmberMap would involve copying and pasting this block of handlebars.

{{#tether-dialog
  target=".target"
  targetAttachment='top center'
  attachment='bottom center'
  containerClassNames='z-index-200'}}
    <div class="pb1">
      <div class="tooltip-arrow-wrapper">
        <div class="tooltip-arrow-parent">
          <div class="br2 pa2 bg-dark-gray white f6">
            Tooltip text
          </div>
          <div class="tooltip-arrow"></div>
        </div>
      </div>
    </div>
{{/tether-dialog}}

However, this is error prone and it doesn't even look like a tooltip! Instead, let's create a new API that's more concise and expressive.

{{#em-tooltip target=".target"}}
  Tooltip text
{{/em-tooltip}}

Later in the video, we'll add the new tooltip to an internal styleguide so other developers to can see how the component is used within the application.

👋 Hey there, Ember dev!

We hope you enjoyed this free video 🙂

If you like it and want to keep learning with us, we've written a free 6-lesson email course about the fundamental patterns of modern component design in Ember.

To get the first lesson now, enter your best email address below:

You can also check out more details about the course by clicking here.

Questions?

Send us a tweet:

Or ask us in Inside EmberMap, our private Slack workspace for subscribers.