1- # ♻️ Usage
1+ # Environment with vanilla Javascript and Webpack
2+
3+ ## ♻️ Usage
4+
5+ The production bundle is available in [ ./dist/main.bundle.js] ( ./dist/main.bundle.js ) .
6+
7+ ### Initialize the library
8+ ``` javascript
9+ import { Bingo } from ' main.bundle.js' ;
10+
11+ // Initialize bingo-generator
12+ // 'bingo-container' is the id of the HTMLElement that renders the Bingo
13+ const bingo = new Bingo (' bingo-container' );
14+ ```
15+
16+ ### Generate a new grid with random numbers on each square
17+ ``` javascript
18+ bingo .resetGrid ();
19+ ```
20+ The result should be something like this:
21+ <p align =" center " >
22+ <img title="Grid" src="../../images/grid.png">
23+ </p >
24+
25+ ### Update the background color of a square, without redrawing all the grid
26+ ``` javascript
27+ bingo .updateBackgroundColor (' 36' , ' Pink' );
28+ ```
29+ The result should be something like this:
30+ <p align =" center " >
31+ <img title="Grid" src="../../images/background-color.png">
32+ </p >
33+
34+ ### Register a handler on the grid
35+ ``` javascript
36+ bingo .registerHandler (cell => {
37+ alert (` You click on square ${ cell .value } ` );
38+ });
39+ ```
40+
41+ This API could be useful for the implementation of the demonstrators. \
42+ The current handler parameter may not be enough or the wrong one. You are free to adapt it.
43+
44+ ## Technical part
245
346The project is configured with Jest for the tests, Playwright & Jest-image-snapshot for the visual tests, ESLint for the code formatting.
447
5- ## IDE Configuration Tips
48+ ### IDE Configuration Tips
649
7- ### IntelliJ/WebStorm
50+ #### IntelliJ/WebStorm
851If you have a problem with IntelliJ, try to change the configuration of ESLint in the IntelliJ preferences, like:
952![ eslint-config.png] ( ../../images/es-webpack-eslint-config.png )
1053
11- ## Commands
54+ ### Commands
1255
13- ### Build and start a development server
56+ #### Build and start a development server
1457` npm run start `
1558
1659A server is launched with an HTML page to test the library manually. \
@@ -19,33 +62,32 @@ A new tab is automatically open in the browser with the url http://localhost:808
1962
2063![ Grid] ( ../../images/start_library_rendering.png )
2164
22-
23- ### Format the code
65+ #### Format the code
2466` npm run lint `
2567
26- ### Clean the built directories
68+ #### Clean the built directories
2769` npm run clean `
2870
29- ### Launch tests
30- #### All tests
71+ #### Launch tests
72+ ##### All tests
3173` npm run test `
3274
33- #### Unit tests
75+ ##### Unit tests
3476` npm run test:unit `
3577
36- #### Unit tests + Coverage
78+ ##### Unit tests + Coverage
3779` npm run test:unit:coverage `
3880
39- #### E2E tests
81+ ##### E2E tests
4082` npm run test:e2e `
4183
42- #### E2E tests + Coverage
84+ ##### E2E tests + Coverage
4385` npm run test:e2e:coverage `
4486
45- ### Build the _ production_ bundle
87+ #### Build the _ production_ bundle
4688` npm run build `
4789
48- ### All commands
90+ #### All commands
4991Run a clean production build with lint and test
5092
5193` npm run all `
0 commit comments