Skip to content

Commit dc111e5

Browse files
authored
Merge pull request #254 from jonbeller/issue-242-add-className-prop
Add support for className prop
2 parents 6e48f15 + 184a81b commit dc111e5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Global|Specific |Type |Values | Description
5757
isCapture | data-iscapture | Bool | true, false | when set to true, custom event's propagation mode will be capture
5858
offset | data-offset | Object | top, right, bottom, left | `data-offset="{'top': 10, 'left': 10}"` for specific and `offset={{top: 10, left: 10}}` for global
5959
multiline | data-multiline | Bool | true, false | support `<br>`, `<br />` to make multiline
60-
class | data-class | String | | extra custom class, can use !important to overwrite react-tooltip's default class
60+
className | data-class | String | | extra custom class, can use !important to overwrite react-tooltip's default class
6161
html | data-html | Bool | true, false | `<p data-tip="<p>HTML tooltip</p>" data-html={true}></p>` or `<ReactTooltip html={true} />`
6262
delayHide | data-delay-hide | Number | | `<p data-tip="tooltip" data-delay-hide='1000'></p>` or `<ReactTooltip delayHide={1000} />`
6363
delayShow | data-delay-show | Number | | `<p data-tip="tooltip" data-delay-show='1000'></p>` or `<ReactTooltip delayShow={1000} />`
@@ -116,7 +116,7 @@ The component was designed to set a `<Reactooltip />` one place then use tooltip
116116

117117
1. Put `<ReactTooltip />` out of the `<Modal>`
118118
2. Use `ReactTooltip.rebuild()` when opening the modal
119-
3. If your modal's z-index happens to higher than the tooltip, use the attribute `class` to custom your tooltip's z-index
119+
3. If your modal's z-index happens to higher than the tooltip, use the attribute `className` to custom your tooltip's z-index
120120

121121
>I suggest always put `<ReactTooltip />` in the Highest level or smart component of Redux, so you might need these static
122122
method to control tooltip's behaviour in some situations

example/src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,18 @@ const Test = React.createClass({
182182
<div className="side">
183183
<a data-for='custom-class' data-tip='hover on me will keep the tootlip'>(・ω´・ )</a>
184184
{/* <a data-for='custom-class' data-tip='' data-tip-disable='true'>empty testing</a> */}
185-
<ReactTooltip id='custom-class' class='extraClass' delayHide={1000} effect='solid'/>
185+
<ReactTooltip id='custom-class' className='extraClass' delayHide={1000} effect='solid'/>
186186
</div>
187187
<div className="side">
188188
<a data-for='custom-theme' data-tip='custom theme'>(・ω´・ )</a>
189-
<ReactTooltip id='custom-theme' class='customeTheme'/>
189+
<ReactTooltip id='custom-theme' className='customeTheme'/>
190190
</div>
191191
</div>
192192
<br />
193193
<pre className='example-pre'>
194194
<div>
195195
<p>{"<a data-tip='hover on me will keep the tootlip'>(・ω´・ )́)</a>\n" +
196-
"<ReactTooltip class='extraClass' delayHide={1000} effect='solid'/>\n" +
196+
"<ReactTooltip className='extraClass' delayHide={1000} effect='solid'/>\n" +
197197
".extraClass {\n" +
198198
" font-size: 20px !important;\n" +
199199
" pointer-events: auto !important;\n" +
@@ -205,7 +205,7 @@ const Test = React.createClass({
205205
</div>
206206
<div>
207207
<p>{"<a data-tip='custom theme'>(・ω´・ )́)</a>\n" +
208-
"<ReactTooltip class='customeTheme'/>\n" +
208+
"<ReactTooltip className='customeTheme'/>\n" +
209209
" .customeTheme {\n" +
210210
" color: #ff6e00 !important;\n" +
211211
" background-color: orange !important;\n" +
@@ -252,4 +252,4 @@ const Test = React.createClass({
252252
}
253253
})
254254

255-
render(<Test />, document.getElementById('main'))
255+
render(<Test />, document.getElementById('main'))

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ReactTooltip extends Component {
3232
border: PropTypes.bool,
3333
insecure: PropTypes.bool,
3434
class: PropTypes.string,
35+
className: PropTypes.string,
3536
id: PropTypes.string,
3637
html: PropTypes.bool,
3738
delayHide: PropTypes.number,
@@ -277,7 +278,7 @@ class ReactTooltip extends Component {
277278
border: e.currentTarget.getAttribute('data-border')
278279
? e.currentTarget.getAttribute('data-border') === 'true'
279280
: (this.props.border || false),
280-
extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || '',
281+
extraClass: e.currentTarget.getAttribute('data-class') || this.props.class || this.props.className || '',
281282
disable: e.currentTarget.getAttribute('data-tip-disable')
282283
? e.currentTarget.getAttribute('data-tip-disable') === 'true'
283284
: (this.props.disable || false)

0 commit comments

Comments
 (0)