diff --git a/R4.01_R4.A.10/td_tp/tp5/README.md b/R4.01_R4.A.10/td_tp/tp5/README.md index 46aadb2..851ed9e 100644 --- a/R4.01_R4.A.10/td_tp/tp5/README.md +++ b/R4.01_R4.A.10/td_tp/tp5/README.md @@ -21,3 +21,19 @@ Le but est de comprendre le code pour prendre en main Riot.js - Ajoutez le nombre de tâches restantes. - Modifiez le code pour que les tâches soient stockées localement (utilisez l'objet `localStorage`). +#### Ex2 +Voici un [exemple](./src/ex2) d'application (radar chart) écrite avec riot.js. +
+ +
+ +- Complétez les méthodes `add` et `remove`. +- Créez un nouveau composant `slider.riot`, qui vous utiliserez dans app.riot + +#### Ex3 +L'api DummyJSON permet de manipuler des données fictives. Ecrire, avec riotjs, une application qui permet : + +- de récuperer depuis l'url `https://dummyjson.com/products` une liste de produits +- pour chaque produit, afficher le titre, prix et image. +- ajouter un filtre `prix < 100`, et un bouton `voir détails`. + diff --git a/R4.01_R4.A.10/td_tp/tp5/img/radar.png b/R4.01_R4.A.10/td_tp/tp5/img/radar.png new file mode 100644 index 0000000..89d94a5 Binary files /dev/null and b/R4.01_R4.A.10/td_tp/tp5/img/radar.png differ diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/README.md b/R4.01_R4.A.10/td_tp/tp5/src/ex2/README.md new file mode 100644 index 0000000..af4a644 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/README.md @@ -0,0 +1,18 @@ +# Riot4 Radar Chart + +## Usage + +First of all, plz execute this commands. + +```cmd +$ cd ../ +$ yarn install +$ yarn radar +``` + +Perhaps the browser will open automatically and the application should start. + +URL: [http://127.0.0.1:8080/](http://127.0.0.1:8080/) + +## Demo +demo: [CodeSandbox](https://codesandbox.io/embed/riot4-template-0f6i0) diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/app.riot b/R4.01_R4.A.10/td_tp/tp5/src/ex2/app.riot new file mode 100644 index 0000000..06b788d --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/app.riot @@ -0,0 +1,62 @@ + +

{ props.title }

+
+ + + + + + + + +
+
+ + + { stat.value } + +
+ + +
+ + +
+
+
+ + +
diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/polygraph.riot b/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/polygraph.riot new file mode 100644 index 0000000..bba4315 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/polygraph.riot @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/text.riot b/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/text.riot new file mode 100644 index 0000000..3a5ddcf --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/components/text.riot @@ -0,0 +1,25 @@ + +{ props.stat.label } + + + diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/helper.js b/R4.01_R4.A.10/td_tp/tp5/src/ex2/helper.js new file mode 100644 index 0000000..6c6667f --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/helper.js @@ -0,0 +1,13 @@ +const valueToPoint = (value, index, total) => { + const x = 0 + const y = -value * 1.6 + const angle = Math.PI * 2 / total * index + const cos = Math.cos(angle) + const sin = Math.sin(angle) + const tx = x * cos - y * sin + 200 + const ty = x * sin + y * cos + 200 + return { + x: tx, + y: ty + } +} diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/index.html b/R4.01_R4.A.10/td_tp/tp5/src/ex2/index.html new file mode 100644 index 0000000..e8ae784 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/index.html @@ -0,0 +1,42 @@ + + + + + + Riot.js Radar Chart + + + + + + + + + + + + + + + + + diff --git a/R4.01_R4.A.10/td_tp/tp5/src/ex2/style.css b/R4.01_R4.A.10/td_tp/tp5/src/ex2/style.css new file mode 100644 index 0000000..c5aeb37 --- /dev/null +++ b/R4.01_R4.A.10/td_tp/tp5/src/ex2/style.css @@ -0,0 +1,46 @@ +body { + font-family: Helvetica Neue, Arial, sans-serif; +} +#radar{ + display : flex; +} + +svg { + width:400px; + height:400px; +} +polygon { + fill: #ED1646; + opacity: .75; +} + +circle { + fill: transparent; + stroke: #999; +} + +text { + font-family: Futura, Helvetica Neue, Arial, sans-serif; + font-size: 10px; + fill: #666; +} + +label { + display: inline-block; + margin-left: 10px; + width: 20px; +} + +#raw { +/* position: absolute; + top: 0; + left: 300px;*/ +} + +#add { + margin-top: 1em; +} + +.remove { + margin: 0 4px; +}