Skip to content

Commit

Permalink
Making tooltips conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Fechner authored and Florian Fechner committed Jun 26, 2017
1 parent 50ddaf6 commit f04ea1d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A Web Component for visualizing an chemical element built with Polymer 2

## Preview
## Preview

![Screenshot](https://florianfe.github.io/screenshots/chemical-element-visualisation/screenshot-1.png)

Expand All @@ -14,7 +14,7 @@ A Web Component for visualizing an chemical element built with Polymer 2
<custom-element-demo>
<template>
<link rel="import" href="chemical-element-visualisation.html">
<chemical-element-visualisation symbol="he"></chemical-element-visualisation>
<chemical-element-visualisation symbol="he" tooltip="true"></chemical-element-visualisation>
</template>
</custom-element-demo>
```
Expand Down
10 changes: 7 additions & 3 deletions chemical-element-visualisation.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
<g id="ring-group"></g>
<g id="electron-group"></g>
</svg>
<paper-tooltip for="element" position="bottom" animation-delay="0">
[[_element.name]]
</paper-tooltip>
<dom-if if="[[tooltip]]">
<template>
<paper-tooltip for="element" position="bottom" animation-delay="0">
[[_element.name]]
</paper-tooltip>
</template>
</dom-if>
</template>

<script src="chemical-element-visualisation.js"></script>
Expand Down
5 changes: 5 additions & 0 deletions chemical-element-visualisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class ChemicalElementVisualisation extends Polymer.Element
{
return {
symbol: String,
tooltip:
{
type: Boolean,
value: false
},
_elements:
{
type: Object,
Expand Down
43 changes: 43 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,49 @@ <h4>Magnesium</h4>
</template>
</demo-snippet>

<h3>Tooltips</h3>
<demo-snippet>
<template>
<style>

.container
{
display: flex;
}

.item
{
flex: 1;
}

</style>

<div class="container">
<div class="item">
<h4>Hydrogen</h4>
<chemical-element-visualisation
symbol="h"
tooltip="true"
></chemical-element-visualisation>
</div>
<div class="item">
<h4>Helium</h4>
<chemical-element-visualisation
symbol="he"
tooltip="true"
></chemical-element-visualisation>
</div>
<div class="item">
<h4>Magnesium</h4>
<chemical-element-visualisation
symbol="mg"
tooltip="true"
></chemical-element-visualisation>
</div>
</div>
</template>
</demo-snippet>

<h3>Change Element Type Colors</h3>
<demo-snippet>
<template>
Expand Down

0 comments on commit f04ea1d

Please sign in to comment.