Skip to content

Commit 23fd07f

Browse files
author
Youen Péron
authored
Merge pull request #169 from CGI-FR/test-elm
refactor(play): use elm framework
2 parents c7961b3 + 37b993e commit 23fd07f

25 files changed

+2677
-447
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"spikespaz.vscode-smoothtype",
3131
"EditorConfig.EditorConfig",
3232
"redhat.vscode-yaml",
33-
"bradlc.vscode-tailwindcss"
33+
"bradlc.vscode-tailwindcss",
34+
"elmTooling.elm-ls-vscode",
3435
],
3536
"settings": {
3637
// General settings
@@ -82,4 +83,4 @@
8283
"https://raw.githubusercontent.com/CGI-FR/PIMO/main/schema/v1/pimo.schema.json": "/**/*masking*.yml"
8384
}
8485
}
85-
}
86+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ bin
33
.env
44
test/workspace
55
dist/
6+

build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ targets:
218218
doc: "Build website and copy it to play.go path"
219219
depends: "info"
220220
steps:
221-
- $: cd web/play && yarn install && yarn build
221+
- $: cd web/play && yarn install && yarn tailwind-elm && yarn build
222222
- $: touch web/play/node_modules/go.mod
223223
- $: rm -rf internal/app/pimo/client/*
224224
- $: cp -r web/play/dist/* internal/app/pimo/client

web/play/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222
npm-debug.log*
2323
yarn-debug.log*
2424
yarn-error.log*
25+
26+
# Elm
27+
elm-stuff/
28+
gen/

web/play/elm.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"type": "application",
3+
"source-directories": [
4+
"src",
5+
"gen"
6+
],
7+
"elm-version": "0.19.1",
8+
"dependencies": {
9+
"direct": {
10+
"elm/browser": "1.0.2",
11+
"elm/core": "1.0.5",
12+
"elm/html": "1.0.0",
13+
"elm/http": "2.0.0",
14+
"elm/json": "1.1.3",
15+
"elm/svg": "1.0.1",
16+
"jzxhuang/http-extras": "2.1.0",
17+
"rtfeldman/elm-css": "18.0.0"
18+
},
19+
"indirect": {
20+
"elm/bytes": "1.0.8",
21+
"elm/file": "1.0.5",
22+
"elm/time": "1.0.0",
23+
"elm/url": "1.0.0",
24+
"elm/virtual-dom": "1.0.3",
25+
"robinheghan/murmur3": "1.0.0",
26+
"rtfeldman/elm-hex": "1.0.0"
27+
}
28+
},
29+
"test-dependencies": {
30+
"direct": {},
31+
"indirect": {}
32+
}
33+
}

web/play/package.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"start": "webpack serve --open --mode development",
8-
"build": "webpack --mode production"
7+
"test": "elm-test",
8+
"tailwind-elm": "elm-tailwind-modules --tailwind-config ./tailwind.config.cjs --dir gen/",
9+
"start": "webpack serve --open --config webpack.config.dev.js",
10+
"build": "webpack --config webpack.config.prod.js",
11+
"analyse": "elm-analyse -s -p 3001 -o"
912
},
1013
"dependencies": {
1114
"d3": "^7.6.1",
@@ -16,14 +19,25 @@
1619
"monaco-yaml": "^4.0.0-alpha.3"
1720
},
1821
"devDependencies": {
22+
"@tailwindcss/aspect-ratio": "^0.4.0",
23+
"@tailwindcss/forms": "^0.5.2",
24+
"@tailwindcss/typography": "^0.5.4",
1925
"css-loader": "^6.0.0",
2026
"cssnano": "^5.1.12",
27+
"elm": "^0.19.1-5",
28+
"elm-analyse": "^0.16.5",
29+
"elm-format": "^0.8.5",
30+
"elm-hot-webpack-loader": "^1.1.8",
31+
"elm-tailwind-modules": "^0.4.0",
32+
"elm-test": "^0.19.1-revision7",
33+
"elm-webpack-loader": "^7.0.1",
2134
"html-webpack-plugin": "^5.0.0",
2235
"postcss": "^8.4.14",
2336
"postcss-loader": "^7.0.0",
2437
"postcss-preset-env": "^7.7.1",
38+
"string-replace-loader": "^3.1.0",
2539
"style-loader": "^3.0.0",
26-
"tailwindcss": "^3.1.3",
40+
"tailwindcss": "^3.1.6",
2741
"webpack": "^5.0.0",
2842
"webpack-cli": "^4.0.0",
2943
"webpack-dev-server": "^4.0.0"

web/play/postcss.config.cjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
2-
plugins: [
3-
require('tailwindcss'),
4-
require('./tailwind.config.cjs'),
5-
require('autoprefixer'),
6-
require('cssnano')
7-
]
8-
}
2+
plugins: [
3+
require('autoprefixer'),
4+
require('cssnano')
5+
]
6+
}

web/play/src/Error.elm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Error exposing (..)
2+
3+
import Html.Styled exposing (Html, div, text)
4+
import Html.Styled.Attributes as Attr exposing (..)
5+
import Play exposing (Msg)
6+
import Tailwind.Utilities exposing (..)
7+
8+
9+
view : String -> Html Msg
10+
view error =
11+
div
12+
[ Attr.css [ flex_none, font_sans, text_lg, text_red_500 ]
13+
, Attr.id "result-error"
14+
]
15+
[ text error ]

web/play/src/Examples.elm

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module Examples exposing (..)
2+
3+
import Css exposing (visited)
4+
import Html.Styled exposing (..)
5+
import Html.Styled.Attributes as Attr exposing (..)
6+
import Tailwind.Breakpoints exposing (md)
7+
import Tailwind.Utilities exposing (..)
8+
9+
10+
view : Html msg
11+
view =
12+
div
13+
[ Attr.css [ flex, flex_col, md [ flex_row ], mt_5, gap_2, justify_evenly ]
14+
]
15+
[ div []
16+
[ h3
17+
[ Attr.css [ text_lg ]
18+
]
19+
[ text "Data Generation" ]
20+
, a
21+
[ Attr.id "example-generation"
22+
, Attr.css [ text_blue_400, visited [ text_purple_400 ], text_sm, underline, block, cursor_pointer ]
23+
]
24+
[]
25+
]
26+
, div []
27+
[ h3
28+
[ Attr.css [ text_lg ]
29+
]
30+
[ text "Data Anonymization" ]
31+
, a
32+
[ Attr.id "example-anonymization"
33+
, Attr.css [ text_blue_400, visited [ text_purple_400 ], text_sm, underline, block, cursor_pointer ]
34+
]
35+
[]
36+
]
37+
, div []
38+
[ h3
39+
[ Attr.css [ text_lg ]
40+
]
41+
[ text "Data Pseudonymization" ]
42+
, a
43+
[ Attr.id "example-pseudonymization"
44+
, Attr.css [ text_blue_400, visited [ text_purple_400 ], text_sm, underline, block, cursor_pointer ]
45+
]
46+
[]
47+
]
48+
, div []
49+
[ h3
50+
[ Attr.css [ text_lg ]
51+
]
52+
[ text "Other" ]
53+
, a
54+
[ Attr.id "example-other"
55+
, Attr.css [ text_blue_400, visited [ text_purple_400 ], text_sm, underline, block, cursor_pointer ]
56+
]
57+
[]
58+
]
59+
]

web/play/src/Header.elm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module Header exposing (..)
2+
3+
import Html.Styled exposing (..)
4+
import Html.Styled.Attributes as Attr exposing (..)
5+
import Play exposing (Msg(..), init_sandbox)
6+
import Style exposing (onCustomClick)
7+
import Tailwind.Utilities as Tw exposing (..)
8+
9+
10+
view : String -> Html Msg
11+
view version =
12+
div
13+
[ Attr.css [ mb_5, flex, space_x_4, items_baseline, bg_black, text_white ] ]
14+
[ div
15+
[ Attr.css [ m_5, font_sans, text_4xl, font_bold ]
16+
]
17+
[ a
18+
[ Attr.id "reset-link"
19+
, Attr.css [ cursor_pointer ]
20+
, onCustomClick <| UpdateMaskingAndInput init_sandbox
21+
]
22+
[ text "PIMO Play" ]
23+
]
24+
, div
25+
[ Attr.css [ text_slate_200, text_sm ]
26+
]
27+
[ text "A playground for "
28+
, a
29+
[ Attr.href ("https://github.com/CGI-FR/PIMO/tree/" ++ version)
30+
, Attr.target "_blank"
31+
, Attr.rel "noopener noreferrer"
32+
, Attr.css [ Tw.no_underline ]
33+
]
34+
[ text ("pimo " ++ version) ]
35+
]
36+
, div
37+
[ Attr.css [ grow ]
38+
]
39+
[]
40+
]

0 commit comments

Comments
 (0)