1
1
'use strict'
2
2
3
3
import React from 'react'
4
- import { render } from 'react-dom'
4
+ import { render , findDOMNode } from 'react-dom'
5
5
import ReactTooltip from '../../src'
6
6
7
7
const Test = React . createClass ( {
@@ -11,7 +11,8 @@ const Test = React.createClass({
11
11
place : 'top' ,
12
12
type : 'dark' ,
13
13
effect : 'float' ,
14
- condition : false
14
+ condition : false ,
15
+ disable : true
15
16
}
16
17
} ,
17
18
@@ -39,219 +40,24 @@ const Test = React.createClass({
39
40
} )
40
41
} ,
41
42
43
+ showError ( ) {
44
+ this . setState ( {
45
+ disable : false
46
+ } , ( ) => {
47
+ ReactTooltip . show ( findDOMNode ( this . refs . btn ) )
48
+ } )
49
+ } ,
50
+
51
+ giveError ( ) {
52
+ return 'error'
53
+ } ,
54
+
42
55
render ( ) {
43
- let { place, type, effect } = this . state
56
+ let { place, type, effect, disable } = this . state
44
57
return (
45
58
< div >
46
- < section className = 'tooltip-example' >
47
- < h4 className = 'title' > React Tooltip</ h4 >
48
- < div className = 'demonstration' >
49
- < a data-for = 'main' data-tip = "Hello<br />multiline<br />tooltip" >
50
- ◕‿‿◕
51
- </ a >
52
- </ div >
53
- < div className = 'control-panel' >
54
- < div className = 'button-group' >
55
- < div className = 'item' >
56
- < p > Place</ p >
57
- < a className = { place === 'top' ? 'active' : '' } onClick = { this . changePlace . bind ( this , 'top' ) } > Top< span className = 'mark' > (default)</ span > </ a >
58
- < a className = { place === 'right' ? 'active' : '' } onClick = { this . changePlace . bind ( this , 'right' ) } > Right</ a >
59
- < a className = { place === 'bottom' ? 'active' : '' } onClick = { this . changePlace . bind ( this , 'bottom' ) } > Bottom</ a >
60
- < a className = { place === 'left' ? 'active' : '' } onClick = { this . changePlace . bind ( this , 'left' ) } > Left</ a >
61
- </ div >
62
- < div className = 'item' >
63
- < p > Type</ p >
64
- < a className = { type === 'dark' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'dark' ) } > Dark< span className = 'mark' > (default)</ span > </ a >
65
- < a className = { type === 'success' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'success' ) } > Success</ a >
66
- < a className = { type === 'warning' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'warning' ) } > Warning</ a >
67
- < a className = { type === 'error' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'error' ) } > Error</ a >
68
- < a className = { type === 'info' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'info' ) } > Info</ a >
69
- < a className = { type === 'light' ? 'active' : '' } onClick = { this . changeType . bind ( this , 'light' ) } > Light</ a >
70
- </ div >
71
- < div className = 'item' >
72
- < p > Effect</ p >
73
- < a className = { effect === 'float' ? 'active' : '' } onClick = { this . changeEffect . bind ( this , 'float' ) } > Float< span className = 'mark' > (default)</ span > </ a >
74
- < a className = { effect === 'solid' ? 'active' : '' } onClick = { this . changeEffect . bind ( this , 'solid' ) } > Solid</ a >
75
- </ div >
76
- </ div >
77
- < pre >
78
- < div >
79
- < p className = 'label' > Code</ p >
80
- < hr > </ hr >
81
- < p > { '<a data-tip="React-tooltip"> ◕‿‿◕ </a>' } </ p >
82
- < p > { '<ReactTooltip place="' + place + '" type="' + type + '" effect="' + effect + '"/>' } </ p >
83
- </ div >
84
- </ pre >
85
- </ div >
86
- < ReactTooltip id = 'main' place = { place } type = { type } effect = { effect } multiline = { true } />
87
- </ section >
88
- < section className = "advance" >
89
- < div className = "section" >
90
- < h4 className = 'title' > Advance features</ h4 >
91
- < p className = "sub-title" > Use everything as tooltip</ p >
92
-
93
- < div className = "example-jsx" >
94
- < div className = "side" style = { { transform : 'translate3d(5px, 5px, 5px)' } } >
95
- < a data-tip data-for = 'happyFace' > d(`・∀・)b </ a >
96
- < ReactTooltip id = 'happyFace' type = "error" > < span > Show happy face</ span > </ ReactTooltip >
97
- </ div >
98
- < div className = "side" >
99
- < a data-tip data-for = 'sadFace' > இдஇ </ a >
100
- < ReactTooltip id = 'sadFace' type = "warning" effect = "solid" > < span > Show sad face</ span > </ ReactTooltip >
101
- </ div >
102
- </ div >
103
- < br />
104
- < pre className = 'example-pre' >
105
- < div >
106
- < p > { "<a data-tip data-for='happyFace'> d(`・∀・)b </a>\n" +
107
- "<ReactTooltip id='happyFace' type='error'>\n" +
108
- " " + " " + "<span>Show happy face</span>\n" +
109
- "</ReactTooltip>\n" +
110
- "<a data-tip data-for='sadFace'> இдஇ </a>\n" +
111
- "<ReactTooltip id='sadFace' type='warning' effect='solid'>\n" +
112
- " " + " " + "<span>Show sad face</span>\n" +
113
- "</ReactTooltip>" } </ p >
114
- </ div >
115
- </ pre >
116
-
117
- < div className = "example-jsx" >
118
- < div className = "side" > < a data-tip data-for = 'global' > σ`∀´)σ </ a > </ div >
119
- < div className = "side" > < a data-tip data-for = 'global' > (〃∀〃) </ a > </ div >
120
- < ReactTooltip id = 'global' aria-haspopup = "true" role = "example" >
121
- < p > This is a global react component tooltip</ p >
122
- < p > You can put every thing here</ p >
123
- < ul >
124
- < li > Word</ li >
125
- < li > Chart</ li >
126
- < li > Else</ li >
127
- </ ul >
128
- </ ReactTooltip >
129
- </ div >
130
- < pre className = 'example-pre' >
131
- < div >
132
- < p > { "<a data-tip data-for='global'> σ`∀´)σ </a>\n" +
133
- "<a data-tip data-for='global'> (〃∀〃) </a>\n" +
134
- "<ReactTooltip id='global' aria-haspopup='true' role='example'>\n" +
135
- " <p>This is a global react component tooltip</p>\n" +
136
- " <p>You can put every thing here</p>\n" +
137
- " <ul>\n" +
138
- " " + " " + " <li>Word</li>\n" +
139
- " " + " " + " <li>Chart</li>\n" +
140
- " " + " " + " <li>Else</li>\n" +
141
- " </ul>\n" +
142
- "</ReactTooltip>" } </ p >
143
- </ div >
144
- </ pre >
145
- </ div >
146
- </ section >
147
-
148
- < section className = "advance" >
149
- < div className = "section" >
150
- < h4 className = 'title' > Custom event</ h4 >
151
- < p className = "sub-title" > </ p >
152
-
153
- < div className = "example-jsx" >
154
- < div className = "side" >
155
- < a data-for = 'custom-event' data-tip = 'custom show' data-event = 'click focus' > ( •̀д•́)</ a >
156
- < ReactTooltip id = 'custom-event' globalEventOff = 'click' />
157
- </ div >
158
-
159
- < div className = "side" >
160
- < a data-for = 'custom-off-event' data-tip = 'custom show and hide' data-event = 'click' data-event-off = 'dblclick' > ( •̀д•́)</ a >
161
- < ReactTooltip id = 'custom-off-event' />
162
- </ div >
163
- </ div >
164
- < br />
165
- < pre className = 'example-pre' >
166
- < div >
167
- < p > { "<a data-tip='custom show' data-event='click focus'>( •̀д•́)</a>\n" +
168
- "<ReactTooltip globalEventOff='click' />" } </ p >
169
- </ div >
170
- < div >
171
- < p > { "<a data-tip='custom show and hide' data-event='click' data-event-off='dblclick'>( •̀д•́)</a>\n" +
172
- "<ReactTooltip/>" } </ p >
173
- </ div >
174
- </ pre >
175
- </ div >
176
-
177
- < div className = "section" >
178
- < h4 className = 'title' > Theme and delay</ h4 >
179
- < p className = "sub-title" > </ p >
180
-
181
- < div className = "example-jsx" >
182
- < div className = "side" >
183
- < a data-for = 'custom-class' data-tip = 'hover on me will keep the tootlip' > (・ω´・ )</ a >
184
- < ReactTooltip id = 'custom-class' class = 'extraClass' delayHide = { 1000 } effect = 'solid' />
185
- </ div >
186
-
187
- < div className = "side" >
188
- < a data-for = 'custom-theme' data-tip = 'custom theme' > (・ω´・ )</ a >
189
- < ReactTooltip id = 'custom-theme' class = 'customeTheme' />
190
- </ div >
191
- </ div >
192
- < br />
193
- < pre className = 'example-pre' >
194
- < div >
195
- < p > { "<a data-tip='hover on me will keep the tootlip'>(・ω´・ )́)</a>\n" +
196
- "<ReactTooltip class='extraClass' delayHide={1000} effect='solid'/>\n" +
197
- ".extraClass {\n" +
198
- " font-size: 20px !important;\n" +
199
- " pointer-events: auto !important;\n" +
200
- " &:hover {\n" +
201
- "visibility: visible !important;\n" +
202
- "opacity: 1 !important;\n" +
203
- " }\n" +
204
- "}" } </ p >
205
- </ div >
206
-
207
- < div >
208
- < p > { "<a data-tip='custom theme'>(・ω´・ )́)</a>\n" +
209
- "<ReactTooltip class='customeTheme'/>\n" +
210
- " .customeTheme {\n" +
211
- " color: #ff6e00 !important;\n" +
212
- " background-color: orange !important;\n" +
213
- " &.place-top {\n" +
214
- " &:after {\n" +
215
- " border-top-color: orange !important;\n" +
216
- " border-top-style: solid !important;\n" +
217
- " border-top-width: 6px !important;\n" +
218
- " }\n" +
219
- " }\n" +
220
- "}" } </ p >
221
- </ div >
222
- </ pre >
223
- </ div >
224
-
225
- < div className = "section" >
226
- < h4 className = 'title' > Update tip content over time</ h4 >
227
- < p className = "sub-title" > </ p >
228
-
229
- < div className = "example-jsx" >
230
- < div className = "side" >
231
- < a data-for = 'getContent' data-tip > =( •̀д•́)</ a >
232
- < ReactTooltip id = 'getContent' getContent = { ( ) => Math . floor ( Math . random ( ) * 100 ) } />
233
- </ div >
234
-
235
- < div className = "side" >
236
- < a data-for = 'overTime' data-tip > =( •̀д•́)</ a >
237
- < ReactTooltip id = 'overTime'
238
- getContent = { [ ( ) => { return new Date ( ) . toISOString ( ) } , 1000 ] } />
239
- </ div >
240
- </ div >
241
- < br />
242
- < pre className = 'example-pre' >
243
- < div >
244
- < p > { "<a data-for='getContent' data-tip>=( •̀д•́)</a>\n" +
245
- "<ReactTooltip id='getContent' getContent={() => Math.floor(Math.random() * 100)} />" } </ p >
246
- </ div >
247
-
248
- < div >
249
- < p > { "<a data-for='overTime' data-tip>=( •̀д•́)</a>\n" +
250
- "<ReactTooltip id='overTime' getContent={[() => {return new Date().toISOString()}, 1000]}/>" } </ p >
251
- </ div >
252
- </ pre >
253
- </ div >
254
- </ section >
59
+ < button ref = 'btn' data-tip onClick = { this . showError } data-tip-disable = { disable } > CLick</ button >
60
+ < ReactTooltip getContent = { this . giveError } place = 'bottom' delayHide = { 1000 } />
255
61
</ div >
256
62
)
257
63
}
0 commit comments