Skip to content

Commit bbd5c2c

Browse files
committed
feat(ui): Remove dependency on react-simple-dropdown package (#45) ✨
refactor(ui): Removed dependency on react-simple-dropdown package - Slims down bundle size - Removes warnings associated with react-simple-dropdown package * perf: V8 Perf tweak 🐎 * docs(README): Updated CSS skeleton to reflect react-simple-dropdown package removal related changes 📚 Fixes #40
1 parent 2c10486 commit bbd5c2c

26 files changed

+1350
-326
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"presets": [["es2015", { "modules": false }], "stage-0", "react"],
33
"plugins": [
4-
"transform-class-properties",
5-
"transform-react-remove-prop-types"
4+
"transform-class-properties"
65
],
76
"env": {
87
"test": {

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
engines:
22
eslint:
33
enabled: true
4-
csslint:
4+
stylelint:
55
enabled: true
66
duplication:
77
enabled: true

.eslintrc.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{
22
"parser": "babel-eslint",
3+
"parserOptions": {
4+
"ecmaFeatures": {
5+
"jsx": true,
6+
"modules": true
7+
}
8+
},
39
"extends": ["standard", "plugin:react/recommended"],
4-
"plugins": [
5-
"react"
6-
]
7-
}
10+
"plugins": ["react"],
11+
"rules": {
12+
"max-len": ["error", { "code": 120 }]
13+
}
14+
}

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A lightweight and fast control to render a select component that can display hie
2626
- [Screenshot](#screenshot)
2727
- [Demo](#example)
2828
- [Vanilla (no framework)](#vanilla-no-framework)
29-
- [With Bootstrap](#with-bootstrap)
29+
- [With Bootstrap](#with-bootstrap)
3030
- [With Material Design](#with-material-design )
3131
- [Install](#install)
3232
- [Peer Dependencies](#peer-dependencies)
@@ -58,10 +58,10 @@ A lightweight and fast control to render a select component that can display hie
5858
##### Vanilla, no framework
5959
Online demo: http://dowjones.github.io/react-dropdown-tree-select/
6060

61-
##### With Bootstrap
61+
##### With Bootstrap
6262
Online demo: http://dowjones.github.io/react-dropdown-tree-select/examples/bootstrap
6363

64-
##### With Material Design
64+
##### With Material Design
6565
Online demo: http://dowjones.github.io/react-dropdown-tree-select/examples/material
6666

6767
## Install
@@ -198,7 +198,7 @@ The text to display as placeholder on the search box. Defaults to `Choose...`
198198

199199
### Default styles
200200

201-
The component brings minimal styles for bare-bones functional rendering. It is kept purposefully minimal so that user can style/customize it completely to suit their needs.
201+
The component brings minimal styles for bare-bones functional rendering. It is kept purposefully minimal so that user can style/customize it completely to suit their needs.
202202

203203
#### Using WebPack
204204

@@ -239,7 +239,7 @@ Once you import default styles, it is easy to add/override the provided styles t
239239

240240
- [With Bootstrap](/docs/examples/bootstrap)
241241
- [With Material Design ](/docs/examples/material)
242-
242+
243243
## Performance
244244

245245
### Search optimizations
@@ -295,14 +295,14 @@ Absolutely not! Simply do not import the styles (webpack) or include it in your
295295

296296
```pug
297297
div.react-dropdown-tree-select
298-
div.dropdown
299-
a.dropdown__trigger.dropdown-trigger
298+
div.dropdown
299+
a.dropdown-trigger
300300
span
301301
ul.tag-list
302302
li.tag-item
303303
input
304-
div.dropdown__content.dropdown-content
305-
ul.root
304+
div.dropdown-content
305+
ul.root
306306
li.node.tree
307307
i.toggle.collapsed
308308
label
@@ -311,9 +311,9 @@ div.react-dropdown-tree-select
311311
```
312312

313313
Write your own styles from scratch or copy [existing styles](https://github.com/search?utf8=%E2%9C%93&q=repo%3Adowjones%2Freact-dropdown-tree-select+language%3ACSS+path%3A%2Fsrc&type=Code&ref=advsearch&l=CSS&l=) and tweak them.
314-
Then include your own custom styles in your project.
314+
Then include your own custom styles in your project.
315315

316-
:bulb: Pro tip: Leverage [node's](#data) `className`, `tagClassName` or [action's](#data) `className` prop to emit your own class name. Then override/add css propeties in your class. Remember that last person wins in CSS (unless specificity or `!important` is involved). Often times, this may suffice and may be easier then writin all the styles from the ground up.
316+
:bulb: Pro tip: Leverage [node's](#data) `className`, `tagClassName` or [action's](#data) `className` prop to emit your own class name. Then override/add css propeties in your class. Remember that last person wins in CSS (unless specificity or `!important` is involved). Often times, this may suffice and may be easier then writing all the styles from the ground up.
317317

318318
If you believe this aspect can be improved further, feel free to raise an issue.
319319

docs/examples/bootstrap/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ h2 {
4949

5050
.bootstrap-demo .toggle.expanded::after {
5151
content: "\f068";
52-
}
52+
}

docs/examples/material/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ h2, h6 {
6161
position: relative;
6262
width: 1rem;
6363
height: 1rem;
64-
margin-right: .75rem;
64+
margin-right: 0.75rem;
6565
cursor: pointer;
6666
-webkit-appearance: none;
6767
-moz-appearance: none;
@@ -89,4 +89,4 @@ h2, h6 {
8989
border-top-style: none;
9090
border-right-style: none;
9191
border-color: #2196f3;
92-
}
92+
}

docs/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ h2 {
3131

3232
.dropdown-content {
3333
max-height: 400px;
34-
34+
overflow-y: auto;
3535
}
3636

3737
.node .fa {
@@ -42,4 +42,4 @@ h2 {
4242

4343
.node .fa-ban {
4444
color: darkorange;
45-
}
45+
}

docs/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ import ReactDOM from 'react-dom'
33
import DropdownTreeSelect from '../src'
44
import data from './demo-data.json'
55

6-
const onChange = (curNode, selectedNodes) => { console.log('onChange::', curNode, selectedNodes) }
7-
const onAction = ({action, node}) => { console.log(`onAction:: [${action}]`, node) }
8-
const onNodeToggle = (curNode) => { console.log('onNodeToggle::', curNode) }
6+
const onChange = (curNode, selectedNodes) => {
7+
console.log('onChange::', curNode, selectedNodes)
8+
}
9+
const onAction = ({ action, node }) => {
10+
console.log(`onAction:: [${action}]`, node)
11+
}
12+
const onNodeToggle = curNode => {
13+
console.log('onNodeToggle::', curNode)
14+
}
915

10-
ReactDOM.render(<DropdownTreeSelect data={data} onChange={onChange} onAction={onAction} onNodeToggle={onNodeToggle} />, document.getElementById('app'))
16+
ReactDOM.render(
17+
<DropdownTreeSelect data={data} onChange={onChange} onAction={onAction} onNodeToggle={onNodeToggle} />,
18+
document.getElementById('app')
19+
)

docs/webpack.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ const baseConfig = {
1515
{
1616
test: /\.css$/,
1717
use: [
18-
'style-loader',
1918
{
20-
loader: 'css-loader'
19+
loader: 'style-loader'
20+
},
21+
{
22+
loader: 'css-loader',
23+
options: {
24+
localIdentName: 'react-dropdown-tree-select__[local]--[hash:base64:5]',
25+
importLoaders: 1
26+
}
27+
},
28+
{
29+
loader: 'postcss-loader'
2130
}
2231
],
2332
include: /src/

package.json

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,17 @@
2727
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
2828
"demo": "webpack-dev-server --config docs/webpack.config.js",
2929
"prepublishOnly": "npm run build",
30-
"lint": "eslint --fix src docs webpack.config.js",
30+
"lint": "eslint --fix src docs webpack.config.js && stylelint \"src/**/*.css\" --fix",
3131
"semantic-release": "semantic-release",
3232
"travis-deploy-once": "travis-deploy-once",
3333
"test": "cross-env NODE_ENV=test ava",
3434
"test:cov": "rimraf .nyc_output && nyc npm test"
3535
},
36-
"files": [
37-
"dist"
38-
],
36+
"files": ["dist"],
3937
"dependencies": {
4038
"classnames": "^2.2.5",
4139
"lodash.debounce": "^4.0.8",
42-
"prop-types": "^15.5.8",
43-
"react-simple-dropdown": "^3.2.0"
40+
"prop-types": "^15.6.0"
4441
},
4542
"devDependencies": {
4643
"ava": "^0.25.0",
@@ -49,8 +46,6 @@
4946
"babel-loader": "^7.1.2",
5047
"babel-plugin-istanbul": "^4.1.3",
5148
"babel-plugin-transform-class-properties": "^6.24.1",
52-
"babel-plugin-transform-imports": "^1.4.1",
53-
"babel-plugin-transform-react-remove-prop-types": "^0.4.12",
5449
"babel-preset-es2015": "^6.24.1",
5550
"babel-preset-react": "^6.24.1",
5651
"babel-preset-stage-0": "^6.24.1",
@@ -72,51 +67,43 @@
7267
"jsdom-global": "^3.0.2",
7368
"nyc": "^11.2.1",
7469
"open": "^0.0.5",
70+
"postcss": "^6.0.16",
71+
"postcss-cssnext": "^3.1.0",
72+
"postcss-import": "^11.0.0",
73+
"postcss-loader": "^2.0.10",
74+
"postcss-nested": "^3.0.0",
7575
"react": "^16.0.0",
7676
"react-dom": "^16.0.0",
7777
"react-test-renderer": "^16.0.0",
7878
"rimraf": "^2.6.1",
7979
"semantic-release": "^12.2.2",
8080
"sinon": "^4.0.0",
81-
"style-loader": "^0.19.0",
81+
"style-loader": "^0.20.1",
82+
"stylelint": "^8.4.0",
83+
"stylelint-config-standard": "^18.0.0",
8284
"travis-deploy-once": "^4.3.2",
8385
"webpack": "^3.5.6",
8486
"webpack-bundle-analyzer": "^2.9.2",
8587
"webpack-dev-server": "^2.9.4"
8688
},
8789
"peerDependencies": {
88-
"react": "^15.0.0 || ^16.0.0",
89-
"react-dom": "^15.0.0 || ^16.0.0"
90+
"react": "^15.0.0 || ^16.0.0"
9091
},
9192
"ava": {
92-
"files": [
93-
"src/**/*.test.js"
94-
],
95-
"require": [
96-
"babel-register",
97-
"ignore-styles",
98-
"jsdom-global/register",
99-
"./setupEnzyme"
100-
],
93+
"files": ["src/**/*.test.js"],
94+
"require": ["babel-register", "ignore-styles", "jsdom-global/register", "./setupEnzyme"],
10195
"babel": "inherit"
10296
},
10397
"nyc": {
10498
"sourceMap": false,
10599
"instrument": false,
106100
"cache": true,
107-
"reporter": [
108-
"html",
109-
"text-summary"
110-
],
101+
"reporter": ["html", "text-summary"],
111102
"all": true,
112-
"include": [
113-
"src/**/*.js"
114-
],
115-
"exclude": [
116-
"**/*.test.js",
117-
"**/node_modules/**",
118-
"dist",
119-
"demo"
120-
]
103+
"include": ["src/**/*.js"],
104+
"exclude": ["**/*.test.js", "**/node_modules/**", "dist", "demo"]
105+
},
106+
"stylelint": {
107+
"extends": "stylelint-config-standard"
121108
}
122109
}

0 commit comments

Comments
 (0)