-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* perf(pencil): Over 90% reduction in file size and over 80% reduction in Gzipped file after refactoring and reducing dependency footprint. Before: Stat: 611.06KB Parsed: 105.41KB Gzipped: 32.8KB After: Stat: 56.67KB Parsed: 22.38KB Gzipped: 6.02KB
- Loading branch information
Showing
20 changed files
with
2,341 additions
and
2,760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
docs/bundle.js | ||
docs/**/bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ dist | |
*.tgz | ||
|
||
# Webstorm cache | ||
.idea | ||
.idea | ||
/webpack-stats.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Simplified implmentation of isEmpty. | ||
* Note: This is not complete and will return false positives for empty objects and likes. | ||
* However, it suffices for the limited use-case of this project. | ||
*/ | ||
const isEmpty = o => !o || (Array.isArray(o) && !o.length) | ||
|
||
export default isEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,31 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import cn from 'classnames/bind' | ||
import styles from './index.css' | ||
|
||
const cx = cn.bind(styles) | ||
|
||
class Button extends Component { | ||
static propTypes = { | ||
id: PropTypes.string.isRequired, | ||
onDelete: PropTypes.func | ||
} | ||
|
||
render () { | ||
return ( | ||
<button onClick={this.onClick} className={cx('tag-remove')} type='button'>x</button> | ||
) | ||
} | ||
const Tag = (props) => { | ||
const { id, label, onDelete } = props | ||
|
||
onClick = (e) => { | ||
const onClick = (e) => { | ||
// this is needed to stop the drawer from closing | ||
e.stopPropagation() | ||
this.props.onDelete(this.props.id) | ||
onDelete(id) | ||
} | ||
} | ||
|
||
class Tag extends Component { | ||
static propTypes = { | ||
id: PropTypes.string.isRequired, | ||
label: PropTypes.string.isRequired, | ||
onDelete: PropTypes.func | ||
} | ||
return ( | ||
<span className={cx('tag')}> | ||
{label} | ||
<button onClick={onClick} className={cx('tag-remove')} type='button'>x</button> | ||
</span> | ||
) | ||
} | ||
|
||
render () { | ||
const { id, label, onDelete } = this.props | ||
return ( | ||
<span className={cx('tag')}> | ||
{label} | ||
<Button id={id} onDelete={onDelete} /> | ||
</span> | ||
) | ||
} | ||
Tag.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
label: PropTypes.string.isRequired, | ||
onDelete: PropTypes.func | ||
} | ||
|
||
export default Tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
import React, { Component } from 'react' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
class Action extends Component { | ||
static propTypes = { | ||
title: PropTypes.string, | ||
text: PropTypes.string, | ||
className: PropTypes.string, | ||
actionData: PropTypes.object, | ||
onAction: PropTypes.func | ||
} | ||
const Action = (props) => { | ||
const { title, className, text, onAction, actionData } = props | ||
|
||
onClick = (e) => { | ||
if (typeof this.props.onAction === 'function') { | ||
this.props.onAction(this.props.actionData) | ||
const onClick = (e) => { | ||
if (typeof onAction === 'function') { | ||
onAction(actionData) | ||
} | ||
} | ||
|
||
render () { | ||
const { title, className, text } = this.props | ||
return <i title={title} className={className} onClick={this.onClick}>{text}</i> | ||
} | ||
return <i title={title} className={className} onClick={onClick}>{text}</i> | ||
} | ||
|
||
Action.propTypes = { | ||
title: PropTypes.string, | ||
text: PropTypes.string, | ||
className: PropTypes.string, | ||
actionData: PropTypes.object, | ||
onAction: PropTypes.func | ||
} | ||
|
||
export default Action |
Oops, something went wrong.