Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/security csp style src #223

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ devJS:

devCSS:
@$(NODE_BIN)/node-sass $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css
@$(NODE_BIN)/node-sass $(SRC)/index.scss $(EXAMPLE_DIST)/style.css
@$(NODE_BIN)/node-sass -w $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css

devServer:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class | data-class | String | | extra custom class, can use !important to
html | data-html | Bool | true, false | `<p data-tip="<p>HTML tooltip</p>" data-html={true}></p>` or `<ReactTooltip html={true} />`
delayHide | data-delay-hide | Number | | `<p data-tip="tooltip" data-delay-hide='1000'></p>` or `<ReactTooltip delayHide={1000} />`
delayShow | data-delay-show | Number | | `<p data-tip="tooltip" data-delay-show='1000'></p>` or `<ReactTooltip delayShow={1000} />`
insecure | null | Bool | true, false | Whether to inject the style header into the page dynamically (violates CSP style-src but is a convenient default)
border | data-border | Bool | true, false | Add one pixel white border
getContent | null | Func or Array | () => {}, [() => {}, Interval] | Generate the tip content dynamically
afterShow | null | Func | () => {} | Function that will be called after tooltip show
Expand Down
13 changes: 10 additions & 3 deletions bin/transferSass.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ function transferSass () {
console.log(err)
return
}
fs.writeFile(path.resolve(__dirname, '../src/style.js'), "export default '" + result.css.toString().replace(/\n/g, '') + "'", function (err) {
var cssSource = result.css.toString()
fs.writeFile(path.resolve(__dirname, '../src/style.js'), "export default '" + cssSource.replace(/\n/g, '') + "'", function (err) {
if (err) {
console.error(err)
}
console.log('css file has been transformed successful')
process.exit()
console.log('css file has been transformed to JS successful')
fs.writeFile(path.resolve(__dirname, '../src/style.css'), cssSource, function (err) {
if (err) {
console.error(err)
}
console.log('css file has been transformed successful')
process.exit()
})
})
})
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dist/",
"standalone/",
"src/style.js",
"src/style.css",
"example/"
]
},
Expand Down
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ReactTooltip extends Component {
offset: PropTypes.object,
multiline: PropTypes.bool,
border: PropTypes.bool,
insecure: PropTypes.bool,
class: PropTypes.string,
id: PropTypes.string,
html: PropTypes.bool,
Expand All @@ -48,6 +49,7 @@ class ReactTooltip extends Component {
};

static defaultProps = {
insecure: true,
resizeHide: true
};

Expand Down Expand Up @@ -100,9 +102,12 @@ class ReactTooltip extends Component {
}

componentDidMount () {
this.setStyleHeader() // Set the style to the <link>
const { insecure, resizeHide } = this.props
if (insecure) {
this.setStyleHeader() // Set the style to the <link>
}
this.bindListener() // Bind listener for tooltip
this.bindWindowEvents(this.props.resizeHide) // Bind global event for static method
this.bindWindowEvents(resizeHide) // Bind global event for static method
}

componentWillReceiveProps (props) {
Expand Down
1 change: 1 addition & 0 deletions src/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading