diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-13 23:31:05 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-13 23:31:05 +0200 |
commit | d9c3cb418ac772085fe2cec2769c17ee86bd697c (patch) | |
tree | 4c21fa05e9e9d2c989686bf9ecbb05879178decc /packages/gitbook-core/src/components/Tooltipped.js | |
parent | 12c7ac1498e108a4a9af0204e5e21a3a6de6ff41 (diff) | |
download | gitbook-d9c3cb418ac772085fe2cec2769c17ee86bd697c.zip gitbook-d9c3cb418ac772085fe2cec2769c17ee86bd697c.tar.gz gitbook-d9c3cb418ac772085fe2cec2769c17ee86bd697c.tar.bz2 |
Add component tooltip from gitbook-core
Diffstat (limited to 'packages/gitbook-core/src/components/Tooltipped.js')
-rw-r--r-- | packages/gitbook-core/src/components/Tooltipped.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/gitbook-core/src/components/Tooltipped.js b/packages/gitbook-core/src/components/Tooltipped.js new file mode 100644 index 0000000..4d297fd --- /dev/null +++ b/packages/gitbook-core/src/components/Tooltipped.js @@ -0,0 +1,44 @@ +const React = require('react'); +const classNames = require('classnames'); + +const POSITIONS = { + BOTTOM_RIGHT: 'e', + BOTTOM_LEFT: 'w', + TOP_LEFT: 'nw', + TOP_RIGHT: 'ne', + BOTTOM: '', + TOP: 'n' +}; + +const Tooltipped = React.createClass({ + propTypes: { + title: React.PropTypes.string.isRequired, + position: React.PropTypes.string, + open: React.PropTypes.bool, + children: React.PropTypes.node + }, + + statics: { + POSITIONS + }, + + render() { + const { title, position, open, children } = this.props; + + const className = classNames( + 'GitBook-Tooltipped', + position ? 'Tooltipped-' + position : '', + { + 'Tooltipped-o': open + } + ); + + return ( + <div className={className} aria-label={title}> + {children} + </div> + ); + } +}); + +module.exports = Tooltipped; |