Skip to content

Commit fcc15ff

Browse files
authored
Merge branch 'master' into add_padding_props
2 parents fd1c239 + 55f11ad commit fcc15ff

26 files changed

+3107
-2290
lines changed

.eslintrc

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
{
22
"parser": "babel-eslint",
3-
"extends": [
4-
"standard",
5-
"standard-react",
6-
"prettier",
7-
"eslint:recommended"
8-
],
3+
"extends": ["standard", "standard-react", "prettier", "eslint:recommended"],
94
"env": {
105
"es6": true,
116
"jest": true
127
},
13-
"plugins": [
14-
"react",
15-
"prettier"
16-
],
8+
"plugins": ["react", "prettier"],
179
"parserOptions": {
1810
"sourceType": "module",
1911
"ecmaVersion": 2018,
2012
"ecmaFeatures": {
21-
"impliedStrict": true,
13+
"impliedStrict": true,
2214
"jsx": true,
2315
"arrowFunctions": true,
2416
"blockBindings": true,
@@ -38,13 +30,15 @@
3830
}
3931
},
4032
"rules": {
33+
"react/jsx-no-bind": "off",
4134
"space-before-function-paren": 0,
4235
"react/jsx-boolean-value": 0,
43-
"max-len": [2, {"code":120,"ignoreComments":true}],
44-
"newline-per-chained-call": 0,
36+
"max-len": [2, { "code": 120, "ignoreComments": true }],
37+
"newline-per-chained-call": 0,
4538
"no-trailing-spaces": ["error"],
46-
"quotes": ["error", "double", { "avoidEscape": true }],
39+
"quotes": ["error", "single", { "avoidEscape": true }],
4740
"comma-dangle": ["error", "never"],
41+
"no-template-curly-in-string": "off",
4842
"semi": ["error", "always"],
4943
"object-curly-spacing": ["error", "always"],
5044
"quote-props": ["error", "consistent"],

.prettierrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// prettier.config.js or .prettierrc.js
2+
module.exports = {
3+
singleQuote: true,
4+
trailingComma: "none",
5+
tabWidth: 2,
6+
printWidth: 80,
7+
semi: true,
8+
bracketSpacing: true,
9+
jsxBracketSameLine: false,
10+
endOfLine: "lf"
11+
};

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cache:
33
directories:
44
- node_modules
55
node_js:
6-
- 11
6+
- 12
77
notifications:
88
email:
99
recipients:
@@ -21,6 +21,7 @@ script:
2121
- yarn
2222
- yarn build
2323
- cd ..
24+
- commitlint-travis
2425

2526
after_success:
2627
- yarn semantic-release

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
## [4.2.15](https://github.com/wwayne/react-tooltip/compare/v4.2.14...v4.2.15) (2021-02-26)
2+
3+
4+
### Bug Fixes
5+
6+
* do not delay show if tooltip is already shown ([#676](https://github.com/wwayne/react-tooltip/issues/676)) ([e8b9d84](https://github.com/wwayne/react-tooltip/commit/e8b9d84))
7+
8+
## [4.2.14](https://github.com/wwayne/react-tooltip/compare/v4.2.13...v4.2.14) (2021-02-16)
9+
10+
11+
### Bug Fixes
12+
13+
* **styles:** change style injection way ([#668](https://github.com/wwayne/react-tooltip/issues/668)) ([1e10cce](https://github.com/wwayne/react-tooltip/commit/1e10cce)), closes [#650](https://github.com/wwayne/react-tooltip/issues/650)
14+
15+
## [4.2.13](https://github.com/wwayne/react-tooltip/compare/v4.2.12...v4.2.13) (2021-01-15)
16+
17+
18+
### Bug Fixes
19+
20+
* **domexception:** revert previous changed for unexpected behavior ([85e38bb](https://github.com/wwayne/react-tooltip/commit/85e38bb)), closes [#667](https://github.com/wwayne/react-tooltip/issues/667)
21+
22+
## [4.2.12](https://github.com/wwayne/react-tooltip/compare/v4.2.11...v4.2.12) (2021-01-14)
23+
24+
25+
### Bug Fixes
26+
27+
* **style injection:** change style injection default root ([a00c5b7](https://github.com/wwayne/react-tooltip/commit/a00c5b7)), closes [#665](https://github.com/wwayne/react-tooltip/issues/665)
28+
29+
## [4.2.11](https://github.com/wwayne/react-tooltip/compare/v4.2.10...v4.2.11) (2020-11-22)
30+
31+
32+
### Bug Fixes
33+
34+
* **styles:** add styles for shadow dom ([00d1539](https://github.com/wwayne/react-tooltip/commit/00d1539)), closes [#597](https://github.com/wwayne/react-tooltip/issues/597)
35+
36+
## [4.2.10](https://github.com/wwayne/react-tooltip/compare/v4.2.9...v4.2.10) (2020-09-14)
37+
38+
39+
### Bug Fixes
40+
41+
* **build:** removing single quotes on cpy for windows shell ([#632](https://github.com/wwayne/react-tooltip/issues/632)) ([9c280af](https://github.com/wwayne/react-tooltip/commit/9c280af))
42+
43+
## [4.2.9](https://github.com/wwayne/react-tooltip/compare/v4.2.8...v4.2.9) (2020-08-27)
44+
45+
46+
### Bug Fixes
47+
48+
* **getposition:** properly determine parents with will-change: transform ([3a76250](https://github.com/wwayne/react-tooltip/commit/3a76250))
49+
50+
## [4.2.8](https://github.com/wwayne/react-tooltip/compare/v4.2.7...v4.2.8) (2020-08-06)
51+
52+
53+
### Bug Fixes
54+
55+
* **showtooltip:** check if tooltipRef is undefined ([#623](https://github.com/wwayne/react-tooltip/issues/623)) ([f63eab2](https://github.com/wwayne/react-tooltip/commit/f63eab2))
56+
157
## Change Log
258

359
### v3.9.0 (2018/11/07 00:43 +00:00)

README.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# react-tooltip
22

33
[![Version](http://img.shields.io/npm/v/react-tooltip.svg)](https://www.npmjs.org/package/react-tooltip)
4-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
4+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
55
[![npm download][download-image]][download-url]
66
[![Build Status](https://travis-ci.org/wwayne/react-tooltip.svg?branch=master)](https://travis-ci.org/wwayne/react-tooltip)
77
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
@@ -13,7 +13,7 @@
1313

1414
[![Edit ReactTooltip](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/heuristic-curran-bddeu?fontsize=14&hidenavigation=1&theme=dark)
1515

16-
Or see it on [Github Page](https://wwayne.github.io/react-tooltip/).
16+
Or see it on [Github Page](https://wwayne.github.io/react-tooltip).
1717

1818
## Maintainers
1919

@@ -39,12 +39,12 @@ yarn add react-tooltip
3939

4040
## Usage
4141

42-
**Using NPM**
42+
### Using NPM
4343

4444
1 . Require react-tooltip after installation
4545

4646
```js
47-
import ReactTooltip from "react-tooltip";
47+
import ReactTooltip from 'react-tooltip';
4848
```
4949

5050
2 . Add data-tip = "your placeholder" to your element
@@ -55,11 +55,11 @@ import ReactTooltip from "react-tooltip";
5555

5656
3 . Include react-tooltip component
5757

58-
```js
58+
```jsx
5959
<ReactTooltip />
6060
```
6161

62-
**Standalone**
62+
### Standalone
6363

6464
You can import `node_modules/react-tooltip/dist/index.js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page.
6565

@@ -71,8 +71,6 @@ Notes:
7171
- The option you set on `<ReactTooltip />` component will be implemented on every tooltip in a same page: `<ReactTooltip effect="solid" />`
7272
- The option you set on a specific element, for example: `<a data-type="warning"></a>` will only affect this specific tooltip
7373

74-
Check example: [React-tooltip Test](https://react-tooltip.netlify.com/)
75-
7674
| Global | Specific | Type | Values | Description |
7775
| :--------------- | :-------------------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7876
| place | data-place | String | top, right, bottom, left | placement |
@@ -108,9 +106,9 @@ Check example: [React-tooltip Test](https://react-tooltip.netlify.com/)
108106

109107
### Security Note
110108

111-
The `html` option allows a tooltip to directly display raw HTML. This is a security risk if any of that content is supplied by the user. Any user-supplied content must be sanitized, using a package like [sanitize-html-react](https://www.npmjs.com/package/sanitize-html-react). We chose not to include sanitization after discovering it [increased our package size](https://github.com/wwayne/react-tooltip/issues/429) too much - we don't want to penalize people who don't use the `html` option.
109+
The `html` option allows a tooltip to directly display raw HTML. This is a security risk if any of that content is supplied by the user. Any user-supplied content must be sanitized, using a package like [sanitize-html](https://www.npmjs.com/package/sanitize-html). We chose not to include sanitization after discovering it [increased our package size](https://github.com/wwayne/react-tooltip/issues/429) too much - we don't want to penalize people who don't use the `html` option.
112110

113-
##### Note:
111+
#### Note
114112

115113
1. **data-tip** is necessary, because `<ReactTooltip />` finds the tooltip via this attribute
116114
2. **data-for** corresponds to the **id** of `<ReactTooltip />`
@@ -122,7 +120,7 @@ The `html` option allows a tooltip to directly display raw HTML. This is a secur
122120

123121
> Hide the tooltip manually, the target is optional, if no target passed in, all existing tooltips will be hidden
124122
125-
```js
123+
```jsx
126124
import ReactTooltip from 'react-tooltip'
127125

128126
<p ref={ref => this.fooRef = ref} data-tip='tooltip'></p>
@@ -138,7 +136,7 @@ import ReactTooltip from 'react-tooltip'
138136

139137
> Show specific tooltip manually, for example:
140138
141-
```js
139+
```jsx
142140
import ReactTooltip from 'react-tooltip'
143141

144142
<p ref={ref => this.fooRef = ref} data-tip='tooltip'></p>
@@ -175,6 +173,46 @@ Same for empty children, if you don't want show the tooltip when the children is
175173
<ReactTooltip id='test'>{}</ReactTooltip>
176174
```
177175

176+
### 3. Tooltip not binding to dynamic content
177+
178+
When you render `<ReactTooltip>` ahead of dynamic content, and are using `data-for={id}` attributes
179+
on new dynamic content, the tooltip will not register its event listener.
180+
181+
For example, you render a generic tooltip in the root of your app, then load a list of content async.
182+
Elements in the list use the `data-for={id}` attribute to bind the tooltip on hover.
183+
Since the tooltip has already scanned for data-tip these new elements will not trigger.
184+
185+
One workaround for this is to trigger `ReactTooltip.rebuild()` after the data load to scan for the attribute again,
186+
to allow event wireup.
187+
188+
#### Example
189+
190+
```jsx
191+
<app>
192+
<ReactTooltip id="foo" />
193+
<list/>
194+
</app>
195+
```
196+
197+
```jsx
198+
199+
const dynamicList = (props) => {
200+
201+
useEffect(() => {
202+
ReactTooltip.rebuild();
203+
});
204+
205+
return(
206+
<list>
207+
{data.map((item)=> {
208+
<span data-for="foo">My late bound tooltip triggered data</span>
209+
});}
210+
</list>
211+
);
212+
};
213+
214+
```
215+
178216
## Article
179217

180218
[How I insert sass into react component](https://medium.com/@wwayne_me/how-i-insert-sass-into-my-npm-react-component-b46b9811c226#.gi4hxu44a)

bin/transferSass.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
var sass = require("node-sass");
2-
var fs = require("fs");
3-
var path = require("path");
1+
const sass = require('node-sass');
2+
const fs = require('fs');
3+
const path = require('path');
44

55
function transferSass() {
66
sass.render(
77
{
8-
file: path.resolve(__dirname, "../src/index.scss"),
9-
outputStyle: "compressed",
8+
file: path.resolve(__dirname, '../src/index.scss'),
9+
outputStyle: 'compressed'
1010
},
1111
function(err, result) {
1212
if (err) {
1313
console.log(err);
1414
return;
1515
}
16-
var cssSource = result.css.toString();
16+
const cssSource = result.css.toString();
1717
fs.writeFile(
18-
path.resolve(__dirname, "../src/style.js"),
19-
"export default '" + cssSource.replace(/\n/g, "") + "'",
18+
path.resolve(__dirname, '../src/style.js'),
19+
"export default '" + cssSource.replace(/\n/g, '') + "'",
2020
function(err) {
2121
if (err) {
2222
console.error(err);
2323
}
24-
console.log("css file has been transformed to JS successful");
24+
console.log('css file has been transformed to JS successful');
2525
fs.writeFile(
26-
path.resolve(__dirname, "../src/style.css"),
26+
path.resolve(__dirname, '../src/style.css'),
2727
cssSource,
2828
function(err) {
2929
if (err) {
3030
console.error(err);
3131
}
32-
console.log("css file has been transformed successful");
32+
console.log('css file has been transformed successful');
3333
process.exit();
3434
}
3535
);
@@ -41,7 +41,7 @@ function transferSass() {
4141

4242
transferSass();
4343

44-
fs.watch(path.resolve(__dirname, "../src/index.scss"), function(
44+
fs.watch(path.resolve(__dirname, '../src/index.scss'), function(
4545
event,
4646
filename
4747
) {

0 commit comments

Comments
 (0)