UNPKG

3.5 kBMarkdownView Raw
1# grasia-dash-components
2
3[Dash](https://github.com/plotly/dash) UI component suite for [GRASIA](https://github.com/Grasia/) projects.
4
5## Use it
6
7If you just want to use any of the components offered by this suite, add it to your system with `pip install grasia-dash-components` and import it with `import grasia_dash_components`.
8
9You can see a very basic example of its usage in `usage.py` or in https://github.com/Akronix/test_grasia_dash_components.
10
11## Hack it
12If you want to hack with the code, keep reading.
13
14```sh
15# Install dependencies
16$ npm install
17
18# Watch source for changes and build to `lib/`
19$ npm start
20```
21
22Go to this link to learn more about [Dash plugins](https://plot.ly/dash/plugins).
23
24### Play with the components
25
26If you just want to play around with the available components that grasia-dash-components offers you, just follow the instructions below:
27
28```sh
29# clone git repo and enter there
30$ git clone https://github.com/Grasia/grasia-dash-components && cd grasia-dash-components
31# create a Python3 new virtual environment
32$ virtualenv -p python3 venv/
33# activate it
34$ source venv/bin/activate
35# and install dependencies
36$ pip install -r requirements.txt
37# generate metadata.json of the Components
38$ npm run prepublish
39# launch the playground
40$ python usage.py
41```
42
43Feel free to modify usage.py source file and play with the different options of the components.
44
45### React demo server
46
47For easy developing and testing of the react components, you can start up a demo development server:
48
49```sh
50$ npm run demo
51$ open http://localhost:9000
52```
53
54You have to maintain the list of components in `demo/Demo.react.js`.
55
56### Code quality and tests
57
58#### To run lint and unit tests:
59
60```sh
61$ npm test
62```
63
64#### To run unit tests and watch for changes:
65
66```sh
67$ npm run test-watch
68```
69
70#### To debug unit tests in a browser (Chrome):
71
72```sh
73$ npm run test-debug
74```
75
761. Wait until Chrome launches.
772. Click the "DEBUG" button in the top right corner.
783. Open up Chrome Devtools (`Cmd+opt+i`).
794. Click the "Sources" tab.
805. Find source files
81 - Navigate to `webpack:// -> . -> spec/components` to find your test source files.
82 - Navigate to `webpack:// -> [your/repo/path]] -> grasia-dash-components -> src` to find your component source files.
836. Now you can set breakpoints and reload the page to hit them.
847. The test output is available in the "Console" tab, or in any tab by pressing "Esc".
85
86#### To run a specific test
87
88In your test, append `.only` to a `describe` or `it` statement:
89
90```javascript
91describe.only('Foo component', () => {
92 // ...
93})l
94```
95
96### Testing your components in Dash
97
981. Build development bundle to `lib/` and watch for changes
99
100 # Once this is started, you can just leave it running.
101 $ npm start
102
1032. Install module locally (after every change)
104
105 # Generate metadata, and build the JavaScript bundle
106 $ npm run install-local
107
108 # Now you're done. For subsequent changes, if you've got `npm start`
109 # running in a separate process, it's enough to just do:
110 $ python setup.py install
111
1123. Run the dash layout you want to test
113
114 # Import grasia-dash-components to your layout, then run it:
115 $ python my_dash_layout.py
116
117
118### Installing python package locally
119
120Before publishing to PyPi, you can test installing the module locally:
121
122```sh
123# Install in `site-packages` on your machine
124$ npm run install-local
125```
126
127### Uninstalling python package locally
128
129```sh
130$ npm run uninstall-local
131```