From 51d2537738439edc37aaa611e1256995a354c29d Mon Sep 17 00:00:00 2001 From: Ashley Fogarty Date: Fri, 22 Jul 2016 10:40:13 -0700 Subject: [PATCH 1/3] Accordion Component In progress - --- src/accordion-panel.js | 46 ++++++++++++++++++++++++++++++++++++++++++ src/index.js | 2 ++ 2 files changed, 48 insertions(+) create mode 100644 src/accordion-panel.js diff --git a/src/accordion-panel.js b/src/accordion-panel.js new file mode 100644 index 0000000..5310e4e --- /dev/null +++ b/src/accordion-panel.js @@ -0,0 +1,46 @@ +import React from 'react'; +import _ from 'lodash'; + +export class AccordionPanel extends React.Component { + + static propTypes = { + heading: React.PropTypes.string, + icon: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.element, + ]), + + } + + static defaultProps = { + heading: '', + icon: null, + } + + renderIcon() { + if (!this.props.icon) { + return null; + } + + return _.isString(this.props.icon) ? : this.props.icon; + } + +//
+//
+//
+// +//
+//
+//
+// ); + + render() { + return ( +

+ + {this.props.heading} {this.renderIcon()} + +

+ ); + } +} diff --git a/src/index.js b/src/index.js index 358e7ef..b76f6ad 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,5 @@ +export * from './accordion'; +export * from './accordion-panel'; export * from './alert'; export * from './breadcrumbs'; export * from './button'; From e84f61cbf7d6676ca5f1c5835a1cc304e4c71186 Mon Sep 17 00:00:00 2001 From: Ashley Fogarty Date: Fri, 22 Jul 2016 10:40:31 -0700 Subject: [PATCH 2/3] Accordion Component In Progress --- src/accordion.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/accordion.js diff --git a/src/accordion.js b/src/accordion.js new file mode 100644 index 0000000..51d308e --- /dev/null +++ b/src/accordion.js @@ -0,0 +1,66 @@ +import React from 'react'; + +export class Accordion extends React.Component { + + static propTypes = { + heading: React.PropTypes.string, + className: React.PropTypes.string, + panelOpen: React.PropTypes.number, + icon: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.element, + ]), + } + + static defaultProps = { + heading: '', + className: '', + isPanelOpen: false, + } + + // onClick() { + // if (!this.props.panelOpen) { + // return this.props.panelOpen; + // } + // } + // return null; + // } + + isPanelOpen() { + if (this.props.panelOpen) { + return this.props.panelOpen; + } + else if null; + } + + renderIcon(icon) { + if (!this.props.icon) { + return null; + } + if (this.props.icon) { + return _.isString(this.props.icon) ? : this.props.icon; + } + return ; + } + + renderAccordionPanels() { + const panels = _.isArray(this.props.children) ? this.props.children : [this.props.children]; + return _.map(panels, (panel, index) => { + // + }); + } + + render() { + return ( +
+
+
+ {this.renderAccordionPanels()} +
+
+
+ ); + } +} From c7926060d715fb8107730fd60da8d080c31ac51c Mon Sep 17 00:00:00 2001 From: Ashley Fogarty Date: Fri, 22 Jul 2016 10:41:15 -0700 Subject: [PATCH 3/3] Accordion Component In progress --- src/accordion.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/accordion.js b/src/accordion.js index 51d308e..a9a0e97 100644 --- a/src/accordion.js +++ b/src/accordion.js @@ -26,12 +26,12 @@ export class Accordion extends React.Component { // return null; // } - isPanelOpen() { - if (this.props.panelOpen) { - return this.props.panelOpen; - } - else if null; - } + // isPanelOpen() { + // if (this.props.panelOpen) { + // return this.props.panelOpen; + // } + // else if null; + // } renderIcon(icon) { if (!this.props.icon) {