Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 37eed47
Showing
75 changed files
with
5,393 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"presets": ["react", "es2015"], | ||
"env": { | ||
|
||
"test": { | ||
"presets": [] | ||
} | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"ecmaFeatures": { | ||
"jsx": true, | ||
"modules": true | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"parser": "babel-eslint", | ||
"rules": { | ||
"quotes": [2, "single"], | ||
"strict": [2, "never"], | ||
"babel/generator-star-spacing": 1, | ||
"babel/new-cap": 1, | ||
"babel/object-shorthand": 1, | ||
"babel/arrow-parens": 1, | ||
"babel/no-await-in-loop": 1, | ||
"react/jsx-uses-react": 2, | ||
"react/jsx-uses-vars": 2, | ||
"react/react-in-jsx-scope": 2 | ||
}, | ||
"plugins": [ | ||
"babel", | ||
"react" | ||
] | ||
} |
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,5 @@ | ||
.DS_Store | ||
node_modules | ||
npm-debug.log | ||
.idea | ||
dist |
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,2 @@ | ||
dist | ||
demo |
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,19 @@ | ||
Copyright (c) 2016 Danko Kozar | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,162 @@ | ||
[![NPM](https://nodei.co/npm/react-data-menu.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/react-data-menu) | ||
|
||
[![NPM](https://badge.fury.io/js/react-data-menu.png)](https://www.npmjs.com/package/react-data-menu) | ||
|
||
# React Data Menu | ||
|
||
Smart data-driven menu rendered in an overlay. | ||
|
||
Hints-based aligning with custom renderers and factories. | ||
|
||
Never again clipped by other components or screen edges. | ||
|
||
[![Data Menu!](http://dankokozar.com/images/react-data-menu.png)](http://dkozar.github.io/react-data-menu/) | ||
|
||
## :tv: Demo | ||
|
||
http://dkozar.github.io/react-data-menu/ | ||
|
||
## :zap: Usage | ||
|
||
```js | ||
// ES6 | ||
import React, { Component } from 'react'; | ||
import { Menu } from 'react-data-menu'; | ||
|
||
export class App extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
position: { | ||
x: 100, | ||
y: 100 | ||
}, | ||
items: { | ||
type: 'label', | ||
title: 'Menu Popup 1' | ||
}, '-', { | ||
title: 'Menu item 1-1', | ||
callback: callback, | ||
items: [{ // sub-menu | ||
title: 'Menu Popup 2' | ||
}, '-', { | ||
title: 'Menu item 2-1', | ||
callback: callback, | ||
items: [{ // sub-sub-menu | ||
title: 'Menu Popup 3' | ||
}, '-', { | ||
title: 'Menu item 3-1' | ||
}] | ||
}] | ||
}, { | ||
title: 'Menu item 1-2' | ||
}, '-', { | ||
type: 'link', | ||
title: 'Give me stars!', | ||
url: 'https://github.com/dkozar/react-data-menu/stargazers', | ||
target: '_blank' | ||
}]; | ||
}; | ||
} | ||
|
||
render() { | ||
var renderers = { | ||
'link': LinkRenderer | ||
}; | ||
|
||
return ( | ||
<Menu items={this.state.items} position={this.state.position} renderers={renderers} /> | ||
); | ||
} | ||
} | ||
|
||
render(<App />, document.body); | ||
``` | ||
|
||
## :truck: Installation | ||
|
||
### Option A - use it as NPM plugin: | ||
|
||
```bash | ||
npm install react-data-menu --save | ||
``` | ||
|
||
This will install the package into the *node_modules* folder of your project. | ||
|
||
### Option B - download the project source: | ||
|
||
```bash | ||
git clone https://github.com/dkozar/react-data-menu.git | ||
cd react-data-menu | ||
npm install | ||
``` | ||
|
||
*npm install* will install all the dependencies (and their dependencies) into the *node_modules* folder. | ||
|
||
Then, you should run one of the builds. | ||
|
||
## :factory: Builds | ||
|
||
### :rocket: Hot-loader development build | ||
|
||
```bash | ||
npm start | ||
open http://localhost:3000 | ||
``` | ||
|
||
This will give you the build that will partially update the browser via *webpack* whenever you save the edited source file. | ||
|
||
Additionally, it will keep the React component state *intact*. | ||
|
||
For more info on React hot-loader, take a look into [this fantastic video](https://www.youtube.com/watch?v=xsSnOQynTHs). | ||
|
||
### :helicopter: Demo build | ||
|
||
```bash | ||
npm run demo | ||
``` | ||
This should build the minified *demo* folder (it's how the [demo](http://dkozar.github.io/react-data-menu/) is built). | ||
|
||
```bash | ||
npm run debug | ||
``` | ||
This should build the non-minified *demo* folder (for easier debugging). | ||
|
||
You could install the http-server for running demo builds in the browser: | ||
|
||
```bash | ||
npm install http-server | ||
http-server | ||
``` | ||
|
||
### :steam_locomotive: Additional builds | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
Runs Babel on source files (converting ES6 and React to JS) and puts them into the *build* folder. | ||
|
||
```bash | ||
npm run dist | ||
``` | ||
|
||
Builds the webpackUniversalModuleDefinition and puts it into the *dist* folder. | ||
|
||
```bash | ||
npm run all | ||
``` | ||
|
||
Runs all the builds: *build* + *dist* + *demo*. | ||
|
||
```bash | ||
npm run test | ||
``` | ||
|
||
Runs the tests. | ||
|
||
## :thumbsup: Thanks to: | ||
|
||
:rocket: [React Transform Boilerplate](https://github.com/gaearon/react-transform-boilerplate) for the workflow. |
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,4 @@ | ||
#!/bin/bash | ||
rm -rf ./build | ||
./node_modules/.bin/babel --stage 0 --out-dir ./build ./src | ||
find ./build -type f -name '*.jsx' -exec sh -c 'mv -f $0 ${0%.jsx}.js' {} \; |
Oops, something went wrong.