-
Notifications
You must be signed in to change notification settings - Fork 7
How to tooltip
This is quick instruction with examples about how to add tooltip support for custom component.
Let's one have a component named my-component
and one should add tooltip support for it. How to do that?
Below is the prototype of the Polymer component called: my-component
:
<link rel="import" href="/resources/polymer/polymer/polymer.html">
<!-- Other html imports goes here. -->
<dom-module id="my-component">
<template>
<style>
/* Styles goes here. */
</style>
<!-- component's template goes here -->
</template>
<script>
Polymer({
is: 'my-component',
/* my-component's prototype goes here. */
</script>
</dom-module>
In order to add tooltips one should mixin the TgTooltipBehavior
, that is in Polymer.TgBehaviors
package, and add tooltip-text
attribute to elements those should have tooltips. The value for tooltip-text
attribute should contain the text of tooltip. Below is the example of my-component
component with added tooltips:
<link rel="import" href="/resources/polymer/polymer/polymer.html">
<link rel="import" href="/resources/components/tg-tooltip-behavior.html">
<link rel="import" href="/resources/polymer/iron-icon/iron-icon.html">
<!-- Other html imports goes here. -->
<dom-module id="my-component">
<template>
<style>
/* Styles goes here. */
</style>
<div id="div_1" tooltip-text="Element's tooltip">Element with tooltip</div>
<div id="div_2" tooltip-text$="[[_getTooltip()]]">Element with calculated tooltip</div>
</template>
<script>
Polymer({
is: 'my-component',
behaviors: [Polymer.TgBehaviors.TgTooltipBehavior],
_getTooltip: function () {
return "<i>Calculated</i> tooltip with icon <iron-icon icon='attachement'></iron-icon>"
}
/* my-component's prototype goes here. */
</script>
</dom-module>
The above example has two elements with tooltips. First one, with div_1
id, has simple text without binding and the other one ,with div_2
id, has calculated tooltip that is bind (using $=
) to the tooltip-text
attribute. Also it is possible to add tooltip to the component itself by specifying tooltip-text
attribute value in hostAttributes
object of the component. The example below shows how to do that:
<link rel="import" href="/resources/polymer/polymer/polymer.html">
<link rel="import" href="/resources/components/tg-tooltip-behavior.html">
<link rel="import" href="/resources/polymer/iron-icon/iron-icon.html">
<!-- Other html imports goes here. -->
<dom-module id="my-component">
<template>
<style>
/* Styles goes here. */
</style>
<div id="div_1" tooltip-text="Element's tooltip">Element with tooltip</div>
<div id="div_2" tooltip-text$="[[_getTooltip()]]">Element with calculated tooltip</div>
</template>
<script>
Polymer({
is: 'my-component',
behaviors: [Polymer.TgBehaviors.TgTooltipBehavior],
hostAttributes: {
'tooltip-text': "The component's tooltip."
},
_getTooltip: function () {
return "<i>Calculated</i> tooltip with icon <iron-icon icon='attachement'></iron-icon>"
}
/* my-component's prototype goes here. */
</script>
</dom-module>
Per aspera ad astra
- Web UI Design and Web API
- Safe Communication and User Authentication
- Gitworkflow
- JavaScript: Testing with Maven
- Java Application Profiling
-
TG Development Guidelines
- TLS and HAProxy for development
- TG Development Checklist
- Entities and their validation
- Entity Properties
- Entity Type Enhancement
- EQL
- Tooltip How To
- All about Matchers
- All about Fetch Models
- Streaming data
- Synthetic entities
- Activatable entities
- Jasper Reports
- Opening Compound Master from another Compound Master
- Window management test plan
- Multi Time Zone Environment
- GraphQL Web API
- Guice
- Maven
- Full Text Search
- Deployment recipes
- Application Configuration
- JRebel Installation and Integration
- Compile-time mechanisms
- Work in progress