summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-10-13 17:54:27 +0200
committerSamy Pesse <samypesse@gmail.com>2016-10-13 17:57:09 +0200
commit37920c758b7f3859f95ab4c806c9c3da6d8f9e0c (patch)
tree43219f2ebc6fc4cc44f57576a120c7fa3711aebd /packages/gitbook-core/src
parent52f9409e2498e7e083f976ac9d9113781c3681d0 (diff)
downloadgitbook-37920c758b7f3859f95ab4c806c9c3da6d8f9e0c.zip
gitbook-37920c758b7f3859f95ab4c806c9c3da6d8f9e0c.tar.gz
gitbook-37920c758b7f3859f95ab4c806c9c3da6d8f9e0c.tar.bz2
Normalize style of dropdown
Diffstat (limited to 'packages/gitbook-core/src')
-rw-r--r--packages/gitbook-core/src/components/Dropdown.js43
1 files changed, 27 insertions, 16 deletions
diff --git a/packages/gitbook-core/src/components/Dropdown.js b/packages/gitbook-core/src/components/Dropdown.js
index 78bad8d..83a377f 100644
--- a/packages/gitbook-core/src/components/Dropdown.js
+++ b/packages/gitbook-core/src/components/Dropdown.js
@@ -38,11 +38,30 @@ const DropdownContainer = React.createClass({
});
/**
- * A dropdown item, which is always a link, and can contain a nested
- * DropdownMenu.
+ * A dropdown item which can contains informations.
*/
const DropdownItem = React.createClass({
propTypes: {
+ children: React.PropTypes.node
+ },
+
+ render() {
+ const { children } = this.props;
+
+ return (
+ <div className="GitBook-DropdownItem">
+ {children}
+ </div>
+ );
+ }
+});
+
+
+/**
+ * A dropdown item, which is always a link.
+ */
+const DropdownItemLink = React.createClass({
+ propTypes: {
children: React.PropTypes.node,
onClick: React.PropTypes.func,
href: React.PropTypes.string
@@ -64,26 +83,17 @@ const DropdownItem = React.createClass({
},
render() {
- const { children, href, onClick, ...otherProps } = this.props;
-
- let inner = children;
-
- if (href || onClick) {
- inner = (
- <a className="GitBook-DropdownItemLink" href={href || '#'} onClick={this.onClick} {...otherProps} >
- {inner}
- </a>
- );
- }
+ const { children, href, ...otherProps } = this.props;
return (
- <div className="GitBook-DropdownItem">
- {inner}
- </div>
+ <a {...otherProps} className="GitBook-DropdownItemLink" href={href || '#'} onClick={this.onClick} >
+ {children}
+ </a>
);
}
});
+
/**
* A DropdownMenu to display DropdownItems. Must be inside a
* DropdownContainer.
@@ -108,6 +118,7 @@ const DropdownMenu = React.createClass({
const Dropdown = {
Item: DropdownItem,
+ ItemLink: DropdownItemLink,
Menu: DropdownMenu,
Container: DropdownContainer
};