Skip to content

Commit 534268a

Browse files
author
Parth Shah
committed
adding tabs, icons , filePicker
1 parent 8aab14b commit 534268a

File tree

12 files changed

+162
-24
lines changed

12 files changed

+162
-24
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React, { PropTypes } from 'react'
2+
import _ from 'lodash'
3+
import filepicker from 'filepicker-js'
4+
5+
class FilePicker extends React.Component {
6+
constructor(props) {
7+
super(props)
8+
this.onChange = this.onChange.bind(this)
9+
}
10+
11+
onChange(event) {
12+
this.props.onSuccess(this.props.options.multiple ? event.fpfiles : event.fpfile)
13+
}
14+
15+
componentDidMount() {
16+
const filepickerElement = this.refs.filepicker
17+
filepicker.setKey(this.props.apiKey)
18+
filepicker.constructWidget(filepickerElement)
19+
filepickerElement.addEventListener('change', this.onChange, false);
20+
}
21+
22+
componentWillUnmount() {
23+
this.refs.filepicker.removeEventListener('change', this.onChange, false);
24+
}
25+
26+
render() {
27+
const { apiKey, onSuccess, mode, options } = this.props
28+
const element = this.refs.target
29+
30+
// add data-fp- prefix to all keys
31+
const opts = _.mapKeys(options, (v,k) => {
32+
const hyphenated = k.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase()
33+
return `data-fp-${hyphenated}`
34+
})
35+
return <input type={mode} ref="filepicker" onchange={this.onChange} {...opts} />
36+
}
37+
}
38+
39+
FilePicker.propTypes = {
40+
apiKey: PropTypes.string.isRequired,
41+
mode: PropTypes.string.isRequired,
42+
options: PropTypes.object.isRequired,
43+
onSuccess: PropTypes.func.isRequired
44+
}
45+
46+
export default FilePicker

components/Forms/BaseInputField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import { Component, PropTypes } from 'react'
3+
import React, { Component, PropTypes } from 'react'
44
import _ from 'lodash'
55

66
/**

components/Forms/Fields.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SubmitButton from './SubmitButton'
44
import TextInput from './TextInput'
55
import TextareaInput from './TextareaInput'
66
import RadioGroupInput from './RadioGroupInput'
7+
import RadioButton from './RadioButton'
78
import SliderRadioGroupInput from './SliderRadioGroupInput'
89
import TiledCheckboxInput from './TiledCheckboxInput'
910

@@ -14,6 +15,7 @@ export default {
1415
TextInput,
1516
TextareaInput,
1617
RadioGroupInput,
18+
RadioButton,
1719
SliderRadioGroupInput,
1820
TiledCheckboxInput
1921
}

components/Forms/RadioButton.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
import React, { Component } from 'react'
4+
5+
class RadioButton extends Component {
6+
render() {
7+
const { name, index, label, selectedValue, value, onChange } = this.props
8+
const id = [name, 'option', index].join('-')
9+
return (
10+
<div className="radio">
11+
<input type="radio"
12+
name={name} id={id} value={value}
13+
checked={value === selectedValue}
14+
onChange={onChange}
15+
/>
16+
<label htmlFor={id}>{label}</label>
17+
</div>
18+
)
19+
}
20+
}
21+
22+
export default RadioButton

components/Forms/RadioGroupInput.jsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,7 @@ import React, { Component, PropTypes } from 'react'
44
import _ from 'lodash'
55
import classNames from 'classnames'
66
import BaseInputField from './BaseInputField'
7-
8-
class RadioButton extends Component {
9-
render() {
10-
const { name, index, label, selectedValue, value, onChange } = this.props
11-
const id = [name, 'option', index].join('-')
12-
return (
13-
<div className="radio">
14-
<input type="radio"
15-
name={name} id={id} value={value}
16-
checked={value === selectedValue}
17-
onChange={onChange}
18-
/>
19-
<label htmlFor={id}>{label}</label>
20-
</div>
21-
)
22-
}
23-
}
7+
import RadioButton from './RadioButton'
248

259
class RadioGroupInput extends BaseInputField {
2610
constructor(props) {

components/Icons/CloseIcon.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
3+
const CloseIcon = ({ width = '14px', height = '14px' }) => {
4+
return (
5+
<svg width={width} height={height} viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg">
6+
<title>Fill 75</title>
7+
<desc>Created with Sketch.</desc>
8+
<defs></defs>
9+
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fill-rule="evenodd">
10+
<g id="Settings-form-elements" transform="translate(-1160.000000, -2822.000000)" fill="#DCDCE0">
11+
<polygon id="Fill-75" points="1171.14085 2822 1167 2826.23944 1162.85915 2822 1160 2824.85915 1164.23944 2829 1160 2833.14085 1162.85915 2836 1167 2831.76056 1171.14085 2836 1174 2833.14085 1169.76056 2829 1174 2824.85915"></polygon>
12+
</g>
13+
</g>
14+
</svg>
15+
)
16+
}
17+
18+
export default CloseIcon

components/Icons/EditIcon.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
3+
const EditIcon = ({ width = '16px', height = '16px' }) => {
4+
return (
5+
<svg width={width} height={height} viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
6+
<title>Fill 146</title>
7+
<desc>Created with Sketch.</desc>
8+
<defs></defs>
9+
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fill-rule="evenodd">
10+
<g id="Settings-form-elements" transform="translate(-1122.000000, -1407.000000)" fill="#888894">
11+
<path d="M1134,1413.6 L1131.4,1411 L1133,1409.4 L1135.6,1412 L1134,1413.6 Z M1126.6,1421 L1124,1421 L1124,1418.4 L1130,1412.4 L1132.6,1415 L1126.6,1421 Z M1133.7,1407.3 C1133.3,1406.9 1132.7,1406.9 1132.3,1407.3 L1122.3,1417.3 C1122.1,1417.5 1122,1417.7 1122,1418 L1122,1422 C1122,1422.6 1122.4,1423 1123,1423 L1127,1423 C1127.3,1423 1127.5,1422.9 1127.7,1422.7 L1137.7,1412.7 C1138.1,1412.3 1138.1,1411.7 1137.7,1411.3 L1133.7,1407.3 Z" id="Fill-146"></path>
12+
</g>
13+
</g>
14+
</svg>
15+
)
16+
}
17+
18+
export default EditIcon

components/Icons/SaveIcon.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
3+
const SaveIcon = ({ width = '14px', height = '14px' }) => {
4+
return (
5+
<svg width={width} height={height} viewBox="0 0 16 13" version="1.1" xmlns="http://www.w3.org/2000/svg">
6+
<title>Fill 88</title>
7+
<desc>Created with Sketch.</desc>
8+
<defs></defs>
9+
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fill-rule="evenodd">
10+
<g id="Settings-form-elements" transform="translate(-1122.000000, -1505.000000)" fill="#1A85FF">
11+
<polygon id="Fill-88" points="1127.6 1513 1124.4 1509.8 1122 1512.2 1127.6 1517.8 1138 1507.4 1135.6 1505"></polygon>
12+
</g>
13+
</g>
14+
</svg>
15+
)
16+
}
17+
18+
export default SaveIcon

components/Icons/TrashIcon.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
3+
const TrashIcon = ({ width = '16px', height = '16px' }) => {
4+
return (
5+
<svg width={width} height={height} viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
6+
<title>Combined Shape</title>
7+
<desc>Created with Sketch.</desc>
8+
<defs></defs>
9+
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fill-rule="evenodd">
10+
<g id="Settings-form-elements" transform="translate(-1156.000000, -1407.000000)" fill="#888894">
11+
<path d="M1168,1408 C1168,1407.4 1167.6,1407 1167,1407 L1161,1407 C1160.4,1407 1160,1407.4 1160,1408 L1160,1410 L1156,1410 L1156,1412 L1157,1412 L1157,1422 C1157,1422.6 1157.4,1423 1158,1423 L1170,1423 C1170.6,1423 1171,1422.6 1171,1422 L1171,1412 L1172,1412 L1172,1410 L1168,1410 L1168,1408 Z M1169,1421 L1159,1421 L1159,1412 L1169,1412 L1169,1421 Z M1162,1409 L1166,1409 L1166,1410 L1162,1410 L1162,1409 Z M1161,1414 L1163,1414 L1163,1420 L1161,1420 L1161,1414 Z M1165,1414 L1167,1414 L1167,1420 L1165,1420 L1165,1414 Z" id="Combined-Shape"></path>
12+
</g>
13+
</g>
14+
</svg>
15+
)
16+
}
17+
18+
export default TrashIcon

components/Tabs/Tabs.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ require('./Tabs.scss')
66

77
const Tabs = ({activeKey, children, onSelect}) => {
88
const renderTabPill = ({props: {title, eventKey}}) => (
9-
<li key={eventKey} className={cn({active: activeKey === eventKey})}>
10-
<a onClick={function(e) { onSelect(eventKey, e)} }>{title}</a>
9+
<li key={eventKey} onClick={function(e) { onSelect(eventKey, e)} } className={cn({active: activeKey === eventKey})}>
10+
<a>{title}</a>
1111
</li>
1212
)
1313
const activeChild = ({props: {eventKey}}) => eventKey === activeKey

0 commit comments

Comments
 (0)