Skip to content

Commit f3824f5

Browse files
committed
Example for custom class and delay
1 parent 553840d commit f3824f5

File tree

5 files changed

+93
-13
lines changed

5 files changed

+93
-13
lines changed

example/src/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,54 @@ const Test = React.createClass({
173173
</div>
174174
</pre>
175175
</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='customer-class' data-tip='hover on me will keep the tootlip'>(・ω´・ )</a>
184+
<ReactTooltip id='customer-class' class='extraClass' delayHide={1000} effect='solid'/>
185+
</div>
186+
187+
<div className="side">
188+
<a data-for='customer-theme' data-tip='custom theme'>(・ω´・ )</a>
189+
<ReactTooltip id='customer-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>
176224
</section>
177225
</div>
178226
)

example/src/index.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,25 @@ html, body{
206206
line-height: 30px;
207207
}
208208
}
209+
210+
// Extra class for demonstration
211+
.extraClass {
212+
font-size: 20px !important;
213+
pointer-events: auto !important;
214+
&:hover {
215+
visibility: visible !important;
216+
opacity: 1 !important;
217+
}
218+
}
219+
220+
.customeTheme {
221+
color: #ff6e00 !important;
222+
background-color: orange !important;
223+
&.place-top {
224+
&:after {
225+
border-top-color: orange !important;
226+
border-top-style: solid !important;
227+
border-top-width: 6px !important;
228+
}
229+
}
230+
}

src/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ReactTooltip extends Component {
6666
}
6767

6868
componentDidMount () {
69-
this.setStyleHeader() // Set default style to the <link>
69+
this.setStyleHeader() // Set the style to the <link>
7070
this.bindListener() // Bind listener for tooltip
7171
this.bindWindowEvents() // Bind global event for static method
7272
}
@@ -172,10 +172,10 @@ class ReactTooltip extends Component {
172172
delayHide: e.currentTarget.getAttribute('data-delay-hide') || this.props.delayHide || 0,
173173
border: e.currentTarget.getAttribute('data-border') === 'true' || this.props.border || false,
174174
extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || ''
175+
}, () => {
176+
this.addScrollListener()
177+
this.updateTooltip(e)
175178
})
176-
177-
this.addScrollListener()
178-
this.updateTooltip(e)
179179
}
180180

181181
/**
@@ -244,7 +244,6 @@ class ReactTooltip extends Component {
244244
this.updatePosition()
245245
})
246246
}
247-
248247
// Set tooltip position
249248
node.style.left = result.position.left + 'px'
250249
node.style.top = result.position.top + 'px'
@@ -283,11 +282,14 @@ class ReactTooltip extends Component {
283282

284283
if (html) {
285284
return (
286-
<div className={`${tooltipClass} ${extraClass}`} data-id='tooltip' dangerouslySetInnerHTML={{__html: placeholder}}></div>
285+
<div className={`${tooltipClass} ${extraClass}`}
286+
data-id='tooltip'
287+
dangerouslySetInnerHTML={{__html: placeholder}}></div>
287288
)
288289
} else {
289290
return (
290-
<div className={`${tooltipClass} ${extraClass}`} data-id='tooltip'>{placeholder}</div>
291+
<div className={`${tooltipClass} ${extraClass}`}
292+
data-id='tooltip'>{placeholder}</div>
291293
)
292294
}
293295
}

src/index.scss

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
background-color: $background-color;
33
&.place-top {
44
&:after {
5-
border-top: 6px solid $background-color;
5+
border-top-color: $background-color;
6+
border-top-style: solid;
7+
border-top-width: 6px;
68
}
79
}
810
&.place-bottom {
911
&:after {
10-
border-bottom: 6px solid $background-color;
12+
border-bottom-color: $background-color;
13+
border-bottom-style: solid;
14+
border-bottom-width: 6px;
1115
}
1216
}
1317
&.place-left {
1418
&:after {
15-
border-left: 6px solid $background-color;
19+
border-left-color: $background-color;
20+
border-left-style: solid;
21+
border-left-width: 6px;
1622
}
1723
}
1824
&.place-right {
1925
&:after {
20-
border-right: 6px solid $background-color;
26+
border-right-color: $background-color;
27+
border-right-style: solid;
28+
border-right-width: 6px;
2129
}
2230
}
2331
}
@@ -188,4 +196,4 @@
188196
padding: 2px 0px;
189197
text-align: center;
190198
}
191-
}
199+
}

0 commit comments

Comments
 (0)