aboutsummaryrefslogtreecommitdiff
path: root/catapult/third_party/polymer/components/paper-tooltip/demo/index.html
blob: c0bad5e4bc40a826b203483f37023ae7c2df74ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html lang="en">
<head>
  <title>paper-tooltip demo</title>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">

  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
  <link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
  <link rel="import" href="../../iron-icons/iron-icons.html">
  <link rel="import" href="../../paper-icon-button/paper-icon-button.html">
  <link rel="import" href="../../paper-styles/color.html">
  <link rel="import" href="../paper-tooltip.html">
  <link rel="import" href="test-button.html">

  <style is="custom-style" include="demo-pages-shared-styles">
    paper-icon-button, input, .avatar {
      margin: 0 10px;
    }

    .avatar {
      box-sizing: border-box;
      width: 40px;
      height: 40px;
      padding: 8px;
      border-radius: 50%;
      cursor: pointer;
    }

    .blue {
      background-color: var(--paper-light-blue-300);
    }
    .orange {
      background-color: var(--paper-amber-500);
    }
    .green {
      background-color: var(--paper-green-500);
    }
    .red {
      background-color: var(--paper-pink-500);
    }
  </style>
</head>
<body unresolved>
  <div class="vertical-section-container centered">
    <h3>Tooltips can be anchored to elements using their ID</h3>
    <demo-snippet class="centered-demo">
      <template>
        <paper-icon-button id="id_1" icon="favorite" alt="heart"></paper-icon-button>
        <paper-icon-button id="id_2" icon="alarm-on" alt="go back"></paper-icon-button>
        <div id="id_3" class="avatar blue" tabindex="0"></div>
        <div id="id_4" class="avatar orange" tabindex="0"></div>

        <!-- paper-icon-buttons have an inherent padding that will push the tooltip down. offset undoes it -->
        <paper-tooltip for="id_1" offset="0">&lt;3 &lt;3 &lt;3 </paper-tooltip>
        <paper-tooltip for="id_2" offset="0">wake up!</paper-tooltip>
        <paper-tooltip for="id_3" offset="0">halp I am trapped in a tooltip</paper-tooltip>
        <paper-tooltip for="id_4" offset="0">meow!</paper-tooltip>
      </template>
    </demo-snippet>

    <h3>Tooltips can be anchored to elements relative to their parent</h3>
    <demo-snippet class="centered-demo">
      <template>
        <!-- Adding a tabindex so that we can show the tooltip when the whole box is tabbed to -->
        <div tabindex="0">
          <input type="checkbox">allosaurus
          <paper-tooltip>the name means "different lizard"</paper-tooltip>
        </div>
        <div tabindex="0">
          <input type="checkbox">brontosaurus
          <paper-tooltip>the name means "thunder lizard"</paper-tooltip>
        </div>
        <div tabindex="0">
          <input type="checkbox">megalosaurus
          <paper-tooltip>the name means "roof lizard"</paper-tooltip>
        </div>
      </div>
      </template>
    </demo-snippet>

    <h3>Tooltips can open in different directions</h3>
    <demo-snippet class="centered-demo">
      <template>
        <div id="dir_1" class="avatar red" tabindex="0"></div>
        <div id="dir_2" class="avatar blue" tabindex="0"></div>
        <div id="dir_3" class="avatar green" tabindex="0"></div>
        <div id="dir_4" class="avatar orange" tabindex="0"></div>

        <paper-tooltip for="dir_1" position="left" animation-delay="0">👈</paper-tooltip>
        <paper-tooltip for="dir_2" position="right" animation-delay="0">👉</paper-tooltip>
        <paper-tooltip for="dir_3" position="top" animation-delay="0">👍</paper-tooltip>
        <paper-tooltip for="dir_4" position="bottom" animation-delay="0">👎</paper-tooltip>
      </template>
    </demo-snippet>

    <h3>Tooltips can contain rich text (though against the Material Design spec)</h3>
    <demo-snippet class="centered-demo">
      <template>
        <style is="custom-style">
          paper-tooltip.custom img {
            width: 40px;
            padding-right: 10px;
            padding-bottom: 10px;
            float: left;
          }
          .custom {
            --paper-tooltip-background: black;
            --paper-tooltip-text-color: var(--paper-pink-100);
            width: 160px;
          }
        </style>
        <paper-icon-button id="demo4_icon1" icon="favorite" alt="heart"></paper-icon-button>
        <paper-tooltip for="demo4_icon1" class="custom" animation-delay="0">
          <img src="https://placekitten.com/50/50">
          Rich-text tooltips are doable but against the Material Design spec.
        </paper-tooltip>
      </template>
    </demo-snippet>
  </div>
</body>
</html>