Compare commits

...

19 Commits
master ... vue3

@ -1,5 +0,0 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

@ -1,5 +0,0 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

@ -1,19 +0,0 @@
# Feature parity with RPG-Cards by Crobi
RPG-Cards by Crobi was the original inspiration to create this program.
see https://crobi.github.io/rpg-cards
## Card generation
[x] subtitle
[x] rule
[x] property
[x] description
[x] text
[x] subsection
[x] boxes
[x] dndstats
[x] fill
[x] bullet
[ ] picture: not supported and for now not planned

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

@ -0,0 +1,21 @@
{
"title": "vue3-app-starter",
"meta": {
"viewport": "width=device-width,initial-scale=1.0",
"description": "vue3 app starter with typescript support"
},
"logo": "./src/assets/logo.svg",
"favicons": {
"icons": {
"favicons": true,
"android": true,
"appleIcon": true,
"appleStartup": false,
"coast": false,
"firefox": false,
"yandex": false,
"windows": false
}
},
"template": "./public/index.html"
}

@ -1,67 +1,39 @@
{ {
"name": "rpg-cards-ng", "name": "rpg-cards-ng",
"version": "0.1.0", "version": "0.1.0",
"description": "next gen rpg card app",
"main": "src/main.ts",
"author": "koehr <n@koehr.in>",
"license": "MIT",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "dev": "webpack-dev-server",
"build": "vue-cli-service build", "build": "webpack --env.prod --progress"
"lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.6.4", "vue": "3.0.0-beta.15",
"register-service-worker": "^1.6.2", "vue-router": "4.0.0-alpha.12"
"vue": "^2.6.11",
"vue-router": "^3.1.5"
}, },
"devDependencies": { "devDependencies": {
"@editorjs/editorjs": "^2.17.0", "@editorjs/editorjs": "^2.18.0",
"@editorjs/list": "^1.4.0", "@editorjs/list": "^1.5.0",
"@typescript-eslint/eslint-plugin": "^2.18.0", "@vue/compiler-sfc": "3.0.0-beta.15",
"@typescript-eslint/parser": "^2.18.0", "copy-webpack-plugin": "^6.0.2",
"@vue/cli-plugin-babel": "^4.2.0", "css-loader": "^3.6.0",
"@vue/cli-plugin-eslint": "^4.2.0", "dexie": "^3.0.1",
"@vue/cli-plugin-pwa": "^4.2.0", "favicons-webpack-plugin": "^3.0.1",
"@vue/cli-plugin-typescript": "^4.2.0", "file-loader": "^6.0.0",
"@vue/cli-service": "^4.2.0", "html-webpack-plugin": "^4.3.0",
"@vue/eslint-config-standard": "^5.1.0", "raw-loader": "^4.0.1",
"@vue/eslint-config-typescript": "^5.0.1", "style-loader": "^1.2.0",
"eslint": "^6.7.2", "ts-loader": "^7.0.5",
"eslint-plugin-import": "^2.20.1", "typescript": "^3.9.5",
"eslint-plugin-node": "^11.0.0", "url-loader": "^4.1.0",
"eslint-plugin-promise": "^4.2.1", "vue-loader": "16.0.0-beta.3",
"eslint-plugin-standard": "^4.0.0", "webpack": "^4.43.0",
"eslint-plugin-vue": "^6.1.2", "webpack-cli": "^3.3.11",
"lint-staged": "^9.5.0", "webpack-dev-server": "^3.11.0",
"raw-loader": "^4.0.0", "webpack-subresource-integrity": "^1.4.1",
"typescript": "~3.7.5", "yarn": "^1.22.4"
"vue-property-decorator": "^8.4.0",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"@vue/standard",
"@vue/typescript/recommended"
],
"parserOptions": {
"ecmaVersion": 2020
}
},
"browserslist": [
"> 1%",
"IE > 11"
],
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,vue,ts,tsx}": [
"vue-cli-service lint",
"git add"
]
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

@ -1,149 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="16.000000pt" height="16.000000pt" viewBox="0 0 16.000000 16.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,16.000000) scale(0.000320,-0.000320)"
fill="#000000" stroke="none">
<path d="M18 46618 c45 -75 122 -207 122 -211 0 -2 25 -45 55 -95 30 -50 55
-96 55 -102 0 -5 5 -10 10 -10 6 0 10 -4 10 -9 0 -5 73 -135 161 -288 89 -153
173 -298 187 -323 14 -25 32 -57 41 -72 88 -149 187 -324 189 -335 2 -7 8 -13
13 -13 5 0 9 -4 9 -10 0 -5 46 -89 103 -187 175 -302 490 -846 507 -876 8 -16
20 -36 25 -45 28 -46 290 -498 339 -585 13 -23 74 -129 136 -236 61 -107 123
-215 137 -240 14 -25 29 -50 33 -56 5 -5 23 -37 40 -70 18 -33 38 -67 44 -75
11 -16 21 -33 63 -109 14 -25 29 -50 33 -56 4 -5 21 -35 38 -65 55 -100 261
-455 269 -465 4 -5 14 -21 20 -35 15 -29 41 -75 103 -180 24 -41 52 -88 60
-105 9 -16 57 -100 107 -185 112 -193 362 -626 380 -660 8 -14 23 -38 33 -55
11 -16 23 -37 27 -45 4 -8 26 -46 48 -85 23 -38 53 -90 67 -115 46 -81 64
-113 178 -310 62 -107 121 -210 132 -227 37 -67 56 -99 85 -148 16 -27 32 -57
36 -65 4 -8 15 -27 25 -42 9 -15 53 -89 96 -165 44 -76 177 -307 296 -513 120
-206 268 -463 330 -570 131 -227 117 -203 200 -348 36 -62 73 -125 82 -140 10
-15 21 -34 25 -42 4 -8 20 -37 36 -65 17 -27 38 -65 48 -82 49 -85 64 -111 87
-153 13 -25 28 -49 32 -55 4 -5 78 -134 165 -285 87 -151 166 -288 176 -305
10 -16 26 -43 35 -59 9 -17 125 -217 257 -445 132 -229 253 -441 270 -471 17
-30 45 -79 64 -108 18 -29 33 -54 33 -57 0 -2 20 -37 44 -77 24 -40 123 -212
221 -383 97 -170 190 -330 205 -355 16 -25 39 -65 53 -90 13 -25 81 -144 152
-265 70 -121 137 -238 150 -260 12 -22 37 -65 55 -95 18 -30 43 -73 55 -95 12
-22 48 -85 80 -140 77 -132 163 -280 190 -330 13 -22 71 -123 130 -225 59
-102 116 -199 126 -217 10 -17 29 -50 43 -72 15 -22 26 -43 26 -45 0 -2 27
-50 60 -106 33 -56 60 -103 60 -105 0 -2 55 -98 90 -155 8 -14 182 -316 239
-414 13 -22 45 -79 72 -124 27 -46 49 -86 49 -89 0 -2 14 -24 30 -48 16 -24
30 -46 30 -49 0 -5 74 -135 100 -176 5 -8 24 -42 43 -75 50 -88 58 -101 262
-455 104 -179 199 -345 213 -370 14 -25 28 -49 32 -55 4 -5 17 -26 28 -45 10
-19 62 -109 114 -200 114 -197 133 -230 170 -295 16 -27 33 -57 38 -65 17 -28
96 -165 103 -180 4 -8 16 -28 26 -45 10 -16 77 -131 148 -255 72 -124 181
-313 243 -420 62 -107 121 -209 131 -227 35 -62 323 -560 392 -678 38 -66 83
-145 100 -175 16 -30 33 -59 37 -65 4 -5 17 -27 29 -47 34 -61 56 -100 90
-156 17 -29 31 -55 31 -57 0 -2 17 -32 39 -67 21 -35 134 -229 251 -433 117
-203 235 -407 261 -451 27 -45 49 -85 49 -88 0 -4 8 -19 19 -34 15 -21 200
-341 309 -533 10 -19 33 -58 51 -87 17 -29 31 -54 31 -56 0 -2 25 -44 55 -94
30 -50 55 -95 55 -98 0 -4 6 -15 14 -23 7 -9 27 -41 43 -71 17 -30 170 -297
342 -594 171 -296 311 -542 311 -547 0 -5 5 -9 10 -9 6 0 10 -4 10 -10 0 -5
22 -47 49 -92 27 -46 58 -99 68 -118 24 -43 81 -140 93 -160 5 -8 66 -114 135
-235 69 -121 130 -227 135 -235 12 -21 259 -447 283 -490 10 -19 28 -47 38
-62 11 -14 19 -29 19 -32 0 -3 37 -69 83 -148 99 -170 305 -526 337 -583 13
-22 31 -53 41 -70 11 -16 22 -37 26 -45 7 -14 82 -146 103 -180 14 -24 181
-311 205 -355 13 -22 46 -80 75 -130 29 -49 64 -110 78 -135 14 -25 51 -88 82
-140 31 -52 59 -102 63 -110 4 -8 18 -33 31 -55 205 -353 284 -489 309 -535
17 -30 45 -78 62 -106 18 -28 36 -60 39 -72 4 -12 12 -22 17 -22 5 0 9 -4 9
-10 0 -5 109 -197 241 -427 133 -230 250 -431 259 -448 51 -90 222 -385 280
-485 37 -63 78 -135 92 -160 14 -25 67 -117 118 -205 51 -88 101 -175 111
-193 34 -58 55 -95 149 -257 51 -88 101 -173 110 -190 9 -16 76 -131 147 -255
72 -124 140 -241 151 -260 61 -108 281 -489 355 -615 38 -66 77 -133 87 -150
35 -63 91 -161 100 -175 14 -23 99 -169 128 -220 54 -97 135 -235 142 -245 4
-5 20 -32 35 -60 26 -48 238 -416 276 -480 10 -16 26 -46 37 -65 30 -53 382
-661 403 -695 10 -16 22 -37 26 -45 4 -8 26 -48 50 -88 24 -41 43 -75 43 -77
0 -2 22 -40 50 -85 27 -45 50 -84 50 -86 0 -3 38 -69 83 -147 84 -142 302
-520 340 -587 10 -19 34 -60 52 -90 18 -30 44 -75 57 -100 14 -25 45 -79 70
-120 25 -41 56 -96 70 -121 14 -25 77 -133 138 -240 62 -107 122 -210 132
-229 25 -43 310 -535 337 -581 11 -19 26 -45 34 -59 17 -32 238 -414 266 -460
11 -19 24 -41 28 -49 3 -7 75 -133 160 -278 84 -146 153 -269 153 -274 0 -5 5
-9 10 -9 6 0 10 -4 10 -10 0 -5 82 -150 181 -322 182 -314 201 -346 240 -415
12 -21 80 -139 152 -263 71 -124 141 -245 155 -270 14 -25 28 -49 32 -55 6 -8
145 -248 220 -380 37 -66 209 -362 229 -395 11 -19 24 -42 28 -49 4 -8 67
-118 140 -243 73 -125 133 -230 133 -233 0 -2 15 -28 33 -57 19 -29 47 -78 64
-108 17 -30 53 -93 79 -139 53 -90 82 -141 157 -272 82 -142 115 -199 381
-659 142 -245 268 -463 281 -485 12 -22 71 -125 132 -230 60 -104 172 -298
248 -430 76 -132 146 -253 156 -270 11 -16 22 -36 26 -44 3 -8 30 -54 60 -103
29 -49 53 -91 53 -93 0 -3 18 -34 40 -70 22 -36 40 -67 40 -69 0 -2 37 -66 81
-142 45 -77 98 -168 119 -204 20 -36 47 -81 58 -100 12 -19 27 -47 33 -62 6
-16 15 -28 20 -28 5 0 9 -4 9 -9 0 -6 63 -118 140 -251 77 -133 140 -243 140
-245 0 -2 18 -33 41 -70 22 -37 49 -83 60 -101 10 -19 29 -51 40 -71 25 -45
109 -189 126 -218 7 -11 17 -29 22 -40 6 -11 22 -38 35 -60 14 -22 37 -62 52
-90 14 -27 35 -62 45 -77 11 -14 19 -29 19 -32 0 -3 18 -35 40 -71 22 -36 40
-67 40 -69 0 -2 19 -35 42 -72 23 -38 55 -94 72 -124 26 -47 139 -244 171
-298 6 -9 21 -36 34 -60 28 -48 37 -51 51 -19 6 12 19 36 29 52 10 17 27 46
38 65 11 19 104 181 208 360 103 179 199 345 213 370 14 25 42 74 64 109 21
34 38 65 38 67 0 2 18 33 40 69 22 36 40 67 40 69 0 3 177 310 199 346 16 26
136 234 140 244 2 5 25 44 52 88 27 44 49 81 49 84 0 2 18 34 40 70 22 36 40
67 40 69 0 2 20 36 43 77 35 58 169 289 297 513 9 17 50 86 90 155 40 69 86
150 103 180 16 30 35 62 41 70 6 8 16 24 22 35 35 64 72 129 167 293 59 100
116 199 127 220 11 20 30 53 41 72 43 72 1070 1850 1121 1940 14 25 65 113
113 195 48 83 96 166 107 185 10 19 28 50 38 68 11 18 73 124 137 235 64 111
175 303 246 427 71 124 173 299 225 390 52 91 116 202 143 248 27 45 49 85 49
89 0 4 6 14 14 22 7 9 28 43 46 76 26 47 251 436 378 655 11 19 29 51 40 70
11 19 101 176 201 348 99 172 181 317 181 323 0 5 5 9 10 9 6 0 10 5 10 11 0
6 8 23 18 37 11 15 32 52 49 82 16 30 130 228 253 440 122 212 234 405 248
430 13 25 39 70 57 100 39 65 69 117 130 225 25 44 50 87 55 95 12 19 78 134
220 380 61 107 129 224 150 260 161 277 222 382 246 425 15 28 47 83 71 123
24 41 43 78 43 83 0 5 4 9 8 9 4 0 13 12 19 28 7 15 23 45 36 67 66 110 277
478 277 483 0 3 6 13 14 21 7 9 27 41 43 71 17 30 45 80 63 110 34 57 375 649
394 685 6 11 16 27 22 35 6 8 26 42 44 75 18 33 41 74 51 90 10 17 24 41 32
55 54 97 72 128 88 152 11 14 19 28 19 30 0 3 79 141 175 308 96 167 175 305
175 308 0 3 6 13 14 21 7 9 26 39 41 66 33 60 276 483 338 587 24 40 46 80 50
88 4 8 13 24 20 35 14 23 95 163 125 215 11 19 52 91 92 160 40 69 80 139 90
155 9 17 103 179 207 360 105 182 200 346 211 365 103 181 463 802 489 845 7
11 15 27 19 35 4 8 29 51 55 95 64 110 828 1433 848 1470 9 17 24 41 33 55 9
14 29 48 45 77 15 28 52 93 82 145 30 51 62 107 71 123 17 30 231 398 400 690
51 88 103 179 115 202 12 23 26 48 32 55 6 7 24 38 40 68 17 30 61 107 98 170
37 63 84 144 103 180 19 36 41 72 48 81 8 8 14 18 14 21 0 4 27 51 59 106 32
55 72 124 89 154 16 29 71 125 122 213 51 88 104 180 118 205 13 25 28 50 32
55 4 6 17 26 28 45 11 19 45 80 77 135 31 55 66 116 77 135 11 19 88 152 171
295 401 694 620 1072 650 1125 11 19 87 152 170 295 83 143 158 273 166 288 9
16 21 36 26 45 6 9 31 52 55 96 25 43 54 94 66 115 11 20 95 164 186 321 91
157 173 299 182 315 9 17 26 46 37 65 12 19 66 114 121 210 56 96 108 186 117
200 8 14 24 40 34 59 24 45 383 664 412 713 5 9 17 29 26 45 15 28 120 210
241 419 36 61 68 117 72 125 4 8 12 23 19 34 35 57 245 420 262 453 11 20 35
61 53 90 17 29 32 54 32 56 0 3 28 51 62 108 33 57 70 119 80 138 10 19 23 42
28 50 5 8 32 53 59 100 27 47 149 258 271 470 122 212 234 405 248 430 30 53
62 108 80 135 6 11 15 27 19 35 4 8 85 150 181 315 96 165 187 323 202 350 31
56 116 202 130 225 5 8 25 42 43 75 19 33 92 159 162 280 149 257 157 271 202
350 19 33 38 67 43 75 9 14 228 392 275 475 12 22 55 96 95 165 40 69 80 139
90 155 24 42 202 350 221 383 9 15 27 47 41 72 14 25 75 131 136 236 61 106
121 210 134 232 99 172 271 470 279 482 5 8 23 40 40 70 18 30 81 141 142 245
60 105 121 210 135 235 14 25 71 124 127 220 56 96 143 247 194 335 51 88 96
167 102 175 14 24 180 311 204 355 23 43 340 590 356 615 5 8 50 87 101 175
171 301 517 898 582 1008 25 43 46 81 46 83 0 2 12 23 27 47 14 23 40 67 56
97 16 30 35 62 42 70 7 8 15 22 18 30 4 8 20 38 37 65 16 28 33 57 37 65 6 12
111 196 143 250 5 8 55 95 112 193 57 98 113 195 126 215 12 20 27 46 32 57 6
11 14 27 20 35 5 8 76 130 156 270 80 140 165 287 187 325 23 39 52 90 66 115
13 25 30 52 37 61 8 8 14 18 14 21 0 4 41 77 92 165 50 87 175 302 276 478
101 176 208 360 236 408 28 49 67 117 86 152 19 35 41 70 48 77 6 6 12 15 12
19 0 7 124 224 167 291 12 21 23 40 23 42 0 2 21 40 46 83 26 43 55 92 64 109
54 95 327 568 354 614 19 30 45 75 59 100 71 128 82 145 89 148 4 2 8 8 8 13
0 5 42 82 94 172 311 538 496 858 518 897 14 25 40 70 58 100 18 30 42 71 53
90 10 19 79 139 152 265 73 127 142 246 153 265 10 19 43 76 72 125 29 50 63
108 75 130 65 116 80 140 87 143 4 2 8 8 8 12 0 8 114 212 140 250 6 8 14 24
20 35 5 11 54 97 108 190 l100 170 -9611 3 c-5286 1 -9614 -1 -9618 -5 -5 -6
-419 -719 -619 -1068 -89 -155 -267 -463 -323 -560 -38 -66 -81 -140 -95 -165
-31 -56 -263 -457 -526 -910 -110 -190 -224 -388 -254 -440 -29 -52 -61 -109
-71 -125 -23 -39 -243 -420 -268 -465 -11 -19 -204 -352 -428 -740 -224 -388
-477 -826 -563 -975 -85 -148 -185 -322 -222 -385 -37 -63 -120 -207 -185
-320 -65 -113 -177 -306 -248 -430 -72 -124 -172 -297 -222 -385 -51 -88 -142
-245 -202 -350 -131 -226 -247 -427 -408 -705 -65 -113 -249 -432 -410 -710
-160 -278 -388 -673 -506 -877 -118 -205 -216 -373 -219 -373 -3 0 -52 82
-109 183 -58 100 -144 250 -192 332 -95 164 -402 696 -647 1120 -85 149 -228
396 -317 550 -212 365 -982 1700 -1008 1745 -10 19 -43 76 -72 125 -29 50 -64
110 -77 135 -14 25 -63 110 -110 190 -47 80 -96 165 -110 190 -14 25 -99 171
-188 325 -89 154 -174 300 -188 325 -13 25 -64 113 -112 195 -48 83 -140 242
-205 355 -65 113 -183 317 -263 454 -79 137 -152 264 -163 282 -50 89 -335
583 -354 614 -12 19 -34 58 -50 85 -15 28 -129 226 -253 440 -124 215 -235
408 -247 430 -12 22 -69 121 -127 220 -58 99 -226 389 -373 645 -148 256 -324
561 -392 678 -67 117 -134 232 -147 255 -13 23 -33 59 -46 80 l-22 37 -9615 0
-9615 0 20 -32z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 10 KiB

@ -3,15 +3,6 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="icon" href="<%= BASE_URL %>favicon-32.png" sizes="32x32">
<link rel="icon" href="<%= BASE_URL %>favicon-128.png" sizes="128x128">
<link rel="icon" href="<%= BASE_URL %>favicon-192.png" sizes="192x192">
<link rel="shortcut icon" href="<%= BASE_URL %>favicon-196.png" sizes="196x196">
<link rel="apple-touch-icon" href="<%= BASE_URL %>favicon-152.png" sizes="152x152">
<link rel="apple-touch-icon" href="<%= BASE_URL %>favicon-180.png" sizes="180x180">
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>

@ -1,20 +1,82 @@
<template> <template>
<div id="app"> <router-link class="home-link" to="/">
<router-link class="home-link" to="/"> <Logo />
<Logo /> </router-link>
</router-link>
<Notifications :notifications="notifications" @dismiss="dismissNotification" />
<main :name="routeName">
<router-view /> <router-view />
</main>
<div id="popup" v-show="popupShown">
<div class="popup-content"></div>
</div>
<div id="loading-popup" v-show="loading">
<div class="popup-content spinner">
</div>
</div> </div>
</template> </template>
<script lang="ts"> <script lang='ts'>
import { Component, Vue } from 'vue-property-decorator' import { defineComponent } from 'vue'
import Logo from '@/components/logo.vue' import { useState } from '@/state'
@Component({ import Logo from '@/components/Logo.vue'
components: { Logo } import Notifications from '@/components/Notifications.vue'
export default defineComponent({
setup () {
const { collection: loading } = useState('loading')
const { collection: popupShown } = useState('popup')
const { collection: notifications, actions: notificationActions } = useState('notifications')
return {
loading,
popupShown,
notifications,
addNotification: notificationActions.add,
dismissNotification: notificationActions.dismiss,
}
},
components: { Notifications, Logo },
data () {
return {
routeName: 'home'
}
},
watch: {
// this adds a css class to the body equal to the name of the current root
'$route' (newRoute, oldRoute) {
const bodyEl = document.body
const oldClass = oldRoute.name?.toLowerCase()
const newClass = newRoute.name?.toLowerCase()
this.routeName = newClass || ''
if (oldClass) bodyEl.classList.remove(oldClass)
if (newClass) bodyEl.classList.add(newClass)
},
loading (isLoading) {
const bodyEl = document.body
if (isLoading) bodyEl.classList.add('loading')
else bodyEl.classList.remove('loading')
},
popupShown (isShown) {
const bodyEl = document.body
if (isShown) bodyEl.classList.add('popup')
else bodyEl.classList.remove('popup')
}
},
mounted () {
this.addNotification({
level: 'warning',
title: 'This is a pre-alpha version.',
content: 'Many features are still unstable or completely missing. Check out <a href="https://github.com/nkoehring/rpg-cards-ng/">the code repository</a> for more information.'
})
this.addNotification({
content: 'Click the PLUS to create a new deck of cards.'
})
}
}) })
export default class App extends Vue {
}
</script> </script>
<style src="@/assets/app.css" /> <style src='@/assets/app.css' />

@ -1,46 +1,58 @@
:root { :root {
--card-height: 35rem; --card-height: 35rem;
--background-color: #222;
--foreground-color: #CCC;
} }
html,body { html,body {
display: block; display: block;
min-height: 100vh;
margin: 0; margin: 0;
padding: 0; padding: 0;
background-color: #222;
font-size: 10px; font-size: 10px;
color: #CCC;
font-family: Avenir, Helvetica, Arial, sans-serif; font-family: Avenir, Helvetica, Arial, sans-serif;
background-color: var(--background-color);
color: var(--foreground-color);
}
body.print {
color: black;
background-color: white;
} }
#app { #app {
display: block; max-width: 90rem;
margin: auto; margin: auto;
font-size: 1.6rem; font-size: 1.6rem;
max-width: 90rem;
} }
#app > .home-link { #app > main {
display: block;
}
#app .home-link {
position: absolute; position: absolute;
top: 1vh; top: 1rem;
left: 1vw; left: 1rem;
width: 4rem; width: 4rem;
height: 4rem; height: 4rem;
border: none;
} }
#logo { .popup > #app > :not(#popup) {
filter: blur(10px);
}
.logo {
transition: transform .3s ease-out; transition: transform .3s ease-out;
} }
#logo path.house { .logo path.house {
fill: #222; fill: #222;
fill-opacity: 0.0; fill-opacity: 0.0;
transition: fill-opacity .3s ease-out .2s; transition: fill-opacity .3s ease-out .2s;
} }
#logo:hover { .home-link > .logo:hover {
transform: scale(4) translate(5%, 15%); transform: scale(4) translate(5%, 15%);
} }
#logo:hover path.house { .home-link > .logo:hover path.house {
fill-opacity: 1.0; fill-opacity: 1.0;
} }
@ -54,31 +66,92 @@ header {
header > p { header > p {
opacity: .6; opacity: .6;
} }
section[name=notifications] { footer {
display: block;
margin-top: 1.5em;
}
section.notification-section {
display: block; display: block;
max-width: 70rem; max-width: 70rem;
margin: 0 auto 1em; margin: 0 auto 1em;
padding: 1rem 3rem; }
border: .5em solid red; section.notification-section > .note {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1em 1.5em;
background-color: #0006;
border: .5em solid #000;
transition: opacity .5s ease, transform .3s ease;
}
section.notification-section > .note a {
display: inline-block;
height: 1.15em;
border-bottom: 1px dotted white;
} }
#popup {
section.notification-section > .warning {
border-color: red;
}
#popup, #loading-popup {
display: flex;
justify-content: center;
align-items: center;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
display: block; background: radial-gradient(#101010, transparent);
background-color: #0008; overflow-y: auto;
} }
#popup > .popup-content { .popup-content {
max-width: calc(80rem); width: 75rem;
height: calc(100vh - 20rem); max-width: 100vw;
margin: 10rem auto;
} }
main.popup > :not(#popup) { .spinner {
filter: blur(10px); font-size: 10px;
margin: 50px auto;
text-indent: -9999em;
width: 11em;
height: 11em;
border-radius: 50%;
background: #8193a2;
background: linear-gradient(to right, #8193a2 10%, rgba(129,147,162, 0) 42%);
position: relative;
animation: spin 1.4s infinite linear;
transform: translateZ(0);
}
.spinner::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 50%;
background: #8193a2;
border-radius: 100% 0 0 0;
}
.spinner::after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 95%;
height: 95%;
background: #101010;
border-radius: 50%;
margin: auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
} }
input, button, select { input, button, select {
@ -102,7 +175,6 @@ select {
section.cards { section.cards {
display: flex; display: flex;
flex-flow: row wrap; flex-flow: row wrap;
justify-content: space-evenly;
justify-content: flex-start; justify-content: flex-start;
} }
section.cards.centered { section.cards.centered {
@ -133,6 +205,53 @@ button.action-close {
cursor: pointer; cursor: pointer;
} }
.options-form {
display: flex;
flex-flow: row nowrap;
justify-content: space-evenly;
}
.deck-form-fields {
display: flex;
flex-flow: column nowrap;
justify-content: center;
max-width: 25rem;
width: 50%;
margin-right: -15%;
text-shadow: 0 0 3px black;
z-index: 1;
}
.deck-form-fields label {
display: flex;
justify-content: space-between;
align-items: center;
}
.deck-form-fields label,
.deck-form-fields select,
.deck-form-fields input,
.deck-form-fields button {
margin: .5em 0;
}
.deck-form-fields input[type=color] {
margin-left: .5em;
padding: 0;
vertical-align: middle;
}
.codex-editor--narrow .codex-editor__redactor { .codex-editor--narrow .codex-editor__redactor {
margin-right: 0; margin-right: 0;
} }
.centered {
margin: auto inherit;
text-align: center;
}
.notifications-enter-from, .notifications-leave-to {
opacity: 0;
transform: translate(0, -100px);
}
.notifications-leave-from, .notifications-enter-to {
opacity: 1;
transform: translate(0, 0);
}

@ -1,54 +1,44 @@
<template> .card-front {
<main ref="cardEl" class="card-content"></main> display: flex;
</template> flex-flow: column nowrap;
justify-content: flex-start;
<script lang="ts"> }
import { Component, Prop, Vue } from 'vue-property-decorator' .card-front > header {
display: flex;
import Editor from '@editorjs/editorjs' flex-flow: row nowrap;
import List from '@editorjs/list' justify-content: space-between;
import { Heading, Delimiter, Charges, DnDStats } from '@/editor' align-items: center;
height: 3.6rem;
@Component color: white;
export default class DeckCardEditor extends Vue { font-size: 1.2rem;
@Prop() public readonly cardId!: string font-weight: normal;
@Prop() public readonly active!: boolean font-variant: small-caps;
@Prop() public readonly content!: Card['content'] padding: 0 1em;
text-align: left;
private editor!: Editor }
.card-front > header > h1 {
private get id () { margin: 0;
return `${this.cardId}-editor` line-height: .9em;
} font-size: 2rem;
}
private mounted () { .card-front > header > img {
this.editor = new Editor({ height: 3rem;
holder: this.$refs.cardEl as HTMLElement, }
autofocus: false, .card-front > main {
tools: { position: relative;
// header: Heading, display: flex;
list: { class: List, inlineToolbar: true }, flex-flow: column nowrap;
heading: { class: Heading, inlineToolbar: true }, flex: 1;
delimiter: { class: Delimiter, inlineToolbar: false }, height: 100%;
charges: { class: Charges, inlineToolbar: false }, margin: .1rem .4rem .5rem;
dndstats: { class: DnDStats, inlineToolbar: false } padding: .2rem 1rem;
}, background: white;
data: this.content, border-radius: 1rem;
placeholder: 'Click here to write your card.', font-size: 1.2rem;
onChange: () => { color: black;
console.log('editor change, saving') overflow: hidden;
this.editor.save().then(value => { }
this.$emit('change', { field: 'content', value })
}).catch(error => {
console.error('error saving data', error)
})
}
})
}
}
</script>
<style>
.card-content .cdx-block { .card-content .cdx-block {
padding: 0; padding: 0;
} }
@ -158,6 +148,4 @@ export default class DeckCardEditor extends Vue {
} }
.card-content .dnd-stat-block { .card-content .dnd-stat-block {
} }
[contenteditable="true"] { outline: none; } [contenteditable="true"] { outline: none; }
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@ -1,8 +0,0 @@
import Component from 'vue-class-component'
// Register the router hooks with their names
Component.registerHooks([
'beforeRouteEnter',
'beforeRouteLeave',
'beforeRouteUpdate'
])

@ -0,0 +1,61 @@
<template>
<section name="card-back" class="card card-back" :style="cssVars">
<div class="icon-wrapper">
<img :src="iconPath" alt="card icon" />
</div>
<footer><slot></slot></footer>
</section>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { KV } from '@/types'
import { cardCSSVars } from '@/lib/card'
import iconPath from '@/lib/iconPath'
export default defineComponent({
name: 'CardBack',
props: {
icon: String,
color: String,
size: String
},
computed: {
iconPath (): string {
const icon = this.icon || 'plus'
return iconPath(icon)
},
cssVars (): KV<string> {
return cardCSSVars(this.size, this.color)
}
}
})
</script>
<style scoped>
.card-back {
display: flex;
flex-flow: column nowrap;
justify-content: center;
text-align: center;
line-height: 4rem;
font-size: 2rem;
}
.card-back > footer {
font-size: 2rem;
margin: 1rem 0;
}
#_add.card-back {
height: var(--card-height);
width: 25rem;
border: none;
box-shadow: none;
}
#_add.card-back > footer {
display: none;
}
.card-back > .icon-wrapper {
width: 70%;
margin: auto;
}
</style>

@ -0,0 +1,68 @@
<template>
<section name="card-front" class="card card-front" :style="cssVars">
<header>
<h1>{{ card.name }}</h1>
<img :src="iconPath" />
</header>
<main ref="cardEl" class="card-content" />
</section>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { KV } from '@/types'
import { cardCSSVars } from '@/lib/card'
import iconPath from '@/lib/iconPath'
import Editor from '@editorjs/editorjs'
import List from '@editorjs/list'
import { Heading, Delimiter, Charges, DnDStats } from '@/editor'
const editorjsConfig = {
autofocus: false,
hideToolbar: true,
tools: {
list: { class: List, inlineToolbar: false },
heading: { class: Heading, inlineToolbar: false },
delimiter: { class: Delimiter, inlineToolbar: false },
charges: { class: Charges, inlineToolbar: false },
dndstats: { class: DnDStats, inlineToolbar: false }
},
onReady: () => {
console.log('editor is ready, what to do?')
}
}
export default defineComponent({
name: 'CardFront',
props: {
card: Object,
icon: String,
color: String,
size: String
},
setup (props) {
const cardEl = ref(document.createElement('main'))
const editor = new Editor({
holder: cardEl.value,
data: props.card?.content || {},
...editorjsConfig
})
console.log('card content', props.card?.content)
return { cardEl }
},
computed: {
iconPath (): string {
const icon = this.card?.icon || this.icon || 'plus'
return iconPath(icon)
},
cssVars (): KV<string> {
return cardCSSVars(this.size, this.color)
}
}
})
</script>
<style scoped src="@/assets/card.css" />

@ -0,0 +1,68 @@
<template>
<form class="options-form" @submit.prevent="saveDeck">
<div class="deck-form-fields">
<select v-model="icon">
<option :key="iconName" :value="iconName" v-for="iconName in icons">{{ iconName }}</option>
</select>
<input v-model="name" title="deck name" placeholder="give it a name" />
<input v-model="description" title="deck description" placeholder="the most awesome deck of cards" />
<p>Pick a colour: <input type="color" v-model="color" /></p>
<select v-model="cardSize">
<option :key="size.value" :value="size.value" v-for="size in sizes">{{ size.title }}</option>
</select>
<button type="submit">Save deck</button>
<button class="cancel" @click.prevent="$emit('cancel')">cancel</button>
</div>
<CardBack :icon="icon" :color="color" :size="cardSize">
{{ name }}
</CardBack>
</form>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { useState } from '@/state'
import { cardSizeOptions, defaultCardSize } from '@/consts'
import CardBack from '@/components/CardBack.vue'
export default defineComponent({
components: { CardBack },
props: {
deck: Object
},
data () {
const icons = useState('icons').collection
return {
icons,
sizes: cardSizeOptions,
icon: icons[0],
name: 'no-name deck',
description: '',
color: '#3C1C00',
cardSize: defaultCardSize
}
},
watch: {
deck (deck) {
if (deck === undefined) return
this.icon = deck.icon
this.name = deck.name
this.description = deck.description
this.color = deck.color
this.cardSize = deck.cardSize
}
},
methods: {
saveDeck () {
const { icon, name, description, color, cardSize } = this
this.$emit('save', { icon, name, description, color, cardSize })
}
}
})
</script>

@ -0,0 +1,110 @@
<template>
<div class="flip-card card">
<CardFront :card="card" :icon="icon" :color="color" :size="size" />
<CardBack :icon="card.icon || icon" :color="card.color || color" :size="size">
<button @click="$emit('click')">edit card</button>
<button @click="$emit('delete')">delete card</button>
</CardBack>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import CardFront from '@/components/CardFront.vue'
import CardBack from '@/components/CardBack.vue'
export default defineComponent({
name: 'FlipCard',
components: { CardFront, CardBack },
props: {
card: Object,
icon: String,
color: String,
size: String
}
})
</script>
<style scoped>
.flip-card {
position: relative;
perspective: 600px;
transition: transform .2s ease-out .4s;
}
.flip-card.card {
border: none;
box-shadow: none;
}
.flip-card.card > .card {
margin: 0;
}
.flip-card > .active-background {
display: none;
position: fixed;
top: -100vh;
left: -100vw;
width: 200vw;
height: 200vh;
background-color: #0008;
}
.flip-card.active {
z-index: 1;
}
.flip-card.active > .active-background {
display: block;
}
.card-front, .card-back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: var(--highlight-color);
transform: rotateX(0) rotateY(0);
transform-style: preserve-3d;
backface-visibility: hidden;
transition: transform .4s ease-out;
overflow: hidden;
}
.flip-card:not(.active):hover > .card-front {
transform: rotateX(0) rotateY(179deg);
}
.flip-card:not(.active):hover > .card-back {
z-index: 2;
transform: rotateX(0) rotateY(0);
}
.card-front {
z-index: 1;
}
.card-front h1[contenteditable="true"] { text-decoration: underline dotted; }
.card-front h1[contenteditable="true"]:focus { text-decoration: none; }
.card-back {
cursor: pointer;
z-index: 2;
transform: rotateX(0) rotateY(-179deg);
}
.card-back button {
width: 80%;
margin: .1rem auto;
}
.action-close {
position: absolute;
top: 0;
right: 0;
width: 3rem;
height: 3rem;
margin-top: -3rem;
}
@media screen and (orientation:landscape) {
.action-close {
top: 3rem;
right: -3rem;
}
}
</style>

@ -1,5 +1,5 @@
<template> <template>
<svg id="logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <svg class="logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<defs> <defs>
<filter id="outer-shadow" height="300%" width="300%" x="-100%" y="-100%"> <filter id="outer-shadow" height="300%" width="300%" x="-100%" y="-100%">
<feFlood flood-color="rgba(201, 201, 201, 1)" result="flood"></feFlood> <feFlood flood-color="rgba(201, 201, 201, 1)" result="flood"></feFlood>
@ -37,11 +37,3 @@
</g> </g>
</svg> </svg>
</template> </template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
@Component
export default class DeckCard extends Vue {
}
</script>

@ -0,0 +1,21 @@
<template>
<transition-group name="notifications" tag="section" class="notification-section">
<p :key="i" class="note" :class="note.level" v-for="(note, i) in notifications">
<strong>{{ note.title }}</strong>
<div v-html="note.content" />
<button @click="$emit('dismiss', note)">dismiss</button>
</p>
</transition-group>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { Notification } from '@/types'
export default defineComponent({
name: 'Notifications',
props: {
notifications: Array
}
})
</script>

@ -0,0 +1,5 @@
<template>
<Teleport to="#popup > .popup-content">
<slot></slot>
</Teleport>
</template>

@ -1,235 +0,0 @@
<template>
<div
:id="card.id"
class="flip-card card"
:class="{ active: isSelection }"
:style="containerStyle"
@click="clickUnlessSelected">
<div class="active-background" @click.self.stop="$emit('close')" />
<button class="action-close" @click.self.stop="$emit('close')" v-if="isSelection" />
<section name="card-front" class="card-front">
<header>
<h1 :contenteditable="isSelection"
@blur="editField('name', $event)"
@keypress.enter.prevent="editField('name', $event)">
{{ card.name }}
</h1>
<img :src="icon" />
</header>
<deck-card-editor
:card-id="card.id"
:active="isSelection"
:content="card.content"
@change="$emit('edit', $event)"
/>
</section>
<section name="card-back" class="card-back">
<div class="icon-wrapper">
<img :src="backIcon" />
</div>
<button @click="$emit('click')">edit card</button>
<button @click="$emit('delete')">delete card</button>
</section>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { cardWHtoStyle, iconPath } from '@/lib'
import DeckCardEditor from '@/components/deck-card-editor.vue'
@Component({
components: { DeckCardEditor }
})
export default class DeckCard extends Vue {
@Prop() public readonly card!: Card
@Prop() public readonly deck!: Deck
@Prop() public readonly isSelection!: boolean
/// TODO: onEdit
// this.$emit('edit', { field: 'content', value: doc.content })
private editHeadline = false;
private editFieldIndex: number | null = null;
private clickUnlessSelected () {
if (this.isSelection) return
this.$emit('click')
}
private editField (field: string, event: Event) {
if (event.target === null) return
const target = event.target as HTMLElement
const payload = { field, value: target.innerText }
this.$emit('edit', payload)
}
private get icon () {
const icon = this.card.icon || this.deck.icon
return iconPath(icon)
}
private get backIcon () {
const icon = this.card.backIcon || this.deck.icon
return iconPath(icon)
}
private get containerStyle () {
const style = {
'--highlight-color': this.card.color || this.deck.color,
...cardWHtoStyle(this.deck.cardWidth, this.deck.cardHeight),
transform: ''
}
const selected = this.isSelection
const hasElement = this.$el
if (selected && hasElement) {
const el = this.$el.getBoundingClientRect()
const wWidth = window.innerWidth
const wHeight = window.innerHeight
let scale = Math.min(2, wWidth / el.width)
const dH = wHeight / el.height
if (dH < scale) {
// leave some space if scaled card would otherwise fill top to bottom
// so that we can fit controls
scale = dH - dH * 0.1
}
console.log('scale', scale)
const dx = Math.round(wWidth / 2.0 - el.x - el.width / 2.0)
const dy = Math.round(wHeight / 2.0 - el.y - el.height / 2.0)
style.transform = `translate(${dx}px, ${dy}px) scale(${scale})`
}
return style
}
}
</script>
<style scoped>
.flip-card {
position: relative;
perspective: 600px;
transition: transform .2s ease-out .4s;
}
.flip-card > .active-background {
display: none;
position: fixed;
top: -100vh;
left: -100vw;
width: 200vw;
height: 200vh;
background-color: #0008;
}
.flip-card.active {
z-index: 1;
}
.flip-card.active > .active-background {
display: block;
}
.card-front, .card-back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: var(--highlight-color);
transform: rotateX(0) rotateY(0);
transform-style: preserve-3d;
backface-visibility: hidden;
transition: transform .4s ease-out;
overflow: hidden;
}
.flip-card:not(.active):hover > .card-front {
transform: rotateX(0) rotateY(179deg);
}
.card-back {
z-index: 2;
transform: rotateX(0) rotateY(-179deg);
}
.flip-card:not(.active):hover > .card-back {
z-index: 2;
transform: rotateX(0) rotateY(0);
}
.card-front {
display: flex;
flex-flow: column nowrap;
justify-content: flex-start;
z-index: 1;
}
.card-front > header {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
height: 3.6rem;
color: white;
font-size: 1.2rem;
font-weight: normal;
font-variant: small-caps;
padding: 0 1em;
text-align: left;
}
.card-front > header > h1 {
margin: .5em 0 0 0;
align-self: center;
line-height: .9em;
font-size: 2rem;
}
.card-front > header > img {
height: 3rem;
align-self: end;
}
.card-front > header > h1[contenteditable="true"] { text-decoration: underline dotted; }
.card-front > header > h1[contenteditable="true"]:focus { text-decoration: none; }
.card-front > main {
position: relative;
display: flex;
flex-flow: column nowrap;
flex: 1;
height: 100%;
margin: .7rem .4rem .5rem;
padding: .2rem 1rem;
background: white;
border-radius: 1rem;
font-size: 1.2rem;
color: black;
overflow: hidden;
}
.card-back {
display: flex;
flex-flow: column nowrap;
justify-content: center;
cursor: pointer;
}
.card-back > .icon-wrapper {
margin: 3em;
}
.card-back > button {
width: 80%;
margin: .1rem auto;
}
.action-close {
position: absolute;
top: 0;
right: 0;
width: 3rem;
height: 3rem;
margin-top: -3rem;
}
@media screen and (orientation:landscape) {
.action-close {
top: 3rem;
right: -3rem;
}
}
</style>

@ -1,69 +0,0 @@
<template>
<div
:id="deck.id" class="card deck-cover" :style="style"
@click="$emit('click')"
>
<div class="icon-wrapper">
<img :src="icon" />
</div>
<footer>{{ deck.name }} ({{ deck.cards.length }})</footer>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { cardWHtoStyle, iconPath, defaultDeck } from '@/lib'
const emptyDeck: Deck = {
...defaultDeck(),
id: '_add_deck',
name: 'create new deck',
color: 'transparent',
icon: 'plus'
}
@Component
export default class DeckCover extends Vue {
@Prop({ default () { return emptyDeck } }) public readonly deck!: Deck
private get icon () {
const icon = this.deck.icon || 'default'
return iconPath(icon)
}
private get style () {
return {
backgroundColor: this.deck.color,
...cardWHtoStyle(this.deck.cardWidth, this.deck.cardHeight)
}
}
}
</script>
<style scoped>
.deck-cover {
display: flex;
flex-flow: column nowrap;
justify-content: space-evenly;
text-align: center;
line-height: 4rem;
font-size: 2rem;
}
.deck-cover > footer {
font-size: 2rem;
margin: 1rem 0;
}
#_add_deck.deck-cover {
height: var(--card-height);
width: 25rem;
border: none;
box-shadow: none;
}
#_add_deck.deck-cover > footer {
display: none;
}
.deck-cover > .icon-wrapper {
width: 90%;
margin: auto;
}
</style>

@ -1,109 +0,0 @@
<template>
<form @submit.prevent="saveDeck">
<div class="deck-form-fields">
<select v-model="icon">
<option :key="iconName" :value="iconName" v-for="iconName in icons">{{ iconName }}</option>
</select>
<input v-model="name" title="deck name" placeholder="give it a name" />
<input v-model="description" title="deck description" placeholder="the most awesome deck of cards" />
<p>Pick a colour: <input type="color" v-model="color" /></p>
<select v-model="cardSize">
<option :key="size.value" :value="size.value" v-for="size in sizes">{{ size.title }}</option>
</select>
<button type="submit">Save deck</button>
<button class="cancel" @click.prevent="$emit('close')">cancel</button>
</div>
<DeckCover :deck="newDeck" />
</form>
</template>
<script lang="ts">
import { Component, Prop, Emit, Vue } from 'vue-property-decorator'
import DeckCover from '@/components/deck-cover.vue'
import { cardWHFromSize, cardSizeFromWH, iconPath } from '../lib'
@Component({
components: { DeckCover }
})
export default class DeckForm extends Vue {
@Prop() public readonly deck!: Deck
private icons = ['mouth-watering', 'robe', 'thorny-triskelion']
private sizes = [
{ title: '88x62 (Poker)', value: '88x62' },
{ title: '88x56 (Bridge)', value: '88x56' }
]
private icon: string
private name: string
private description: string
private color: string
private cardSize: string
constructor () {
super()
this.icon = this.deck.icon
this.name = this.deck.name
this.description = this.deck.description
this.color = this.deck.color
this.cardSize = cardSizeFromWH(this.deck.cardWidth, this.deck.cardHeight)
}
private get iconPath () {
return iconPath(this.icon)
}
private get newDeck () {
const [cardWidth, cardHeight] = cardWHFromSize(this.cardSize)
return {
...this.deck,
name: this.name,
description: this.description,
color: this.color,
icon: this.icon,
cardWidth,
cardHeight
}
}
@Emit('save')
private saveDeck (): Deck {
return this.newDeck
}
}
</script>
<style scoped>
form {
display: flex;
flex-flow: row nowrap;
justify-content: space-evenly;
}
.deck-form-fields {
display: flex;
flex-flow: column nowrap;
justify-content: center;
max-width: 25rem;
width: 50%;
margin-right: -15%;
z-index: 1;
}
.deck-form-fields select,
.deck-form-fields input,
.deck-form-fields button {
margin: .5em 0;
}
.deck-form-fields input[type=color] {
margin-left: .5em;
padding: 0;
vertical-align: middle;
}
</style>

@ -1,23 +0,0 @@
<template>
<div id="edit-deck-form" class="deck">
<header>Deck Config</header>
<DeckForm :deck="deck" @save="saveDeck" @close="$emit('close')" />
</div>
</template>
<script lang="ts">
import { Component, Prop, Emit, Vue } from 'vue-property-decorator'
import DeckForm from './deck-form.vue'
@Component({
components: { DeckForm }
})
export default class EditDeckForm extends Vue {
@Prop() public readonly deck!: Deck
@Emit('save')
private saveDeck (deck: Deck) {
this.$storage.saveDeck(deck)
}
}
</script>

@ -1,25 +0,0 @@
<template>
<div id="new-deck-form" class="deck">
<header>Create a new deck of cards</header>
<DeckForm :deck="newDeck" @save="saveDeck" @close="$emit('close')" />
</div>
</template>
<script lang="ts">
import { Component, Emit, Vue } from 'vue-property-decorator'
import DeckForm from './deck-form.vue'
import { defaultDeck, randomId } from '../lib'
@Component({
components: { DeckForm }
})
export default class NewDeckForm extends Vue {
private newDeck: Deck = defaultDeck()
@Emit('save')
private saveDeck (deck: Deck) {
deck.id = randomId() // just to make sure
this.$storage.saveDeck(deck)
}
}
</script>

@ -0,0 +1,50 @@
// page width x page height
export const enum PageSize {
A4 = '210mm 297mm',
USLetter = '8.5in 11in',
JISB4 = '182mm 257mm',
A3 = '297mm 420mm',
A5 = '148mm 210mm',
USLegal = '8.5in 14in',
USLedger = '11in 17in',
JISB5 = '257mm 364mm'
}
// card width x card height
export const enum CardSize {
Poker = '64x89',
Bridge = '57x89'
}
export const enum Arrangement {
DoubleSided = 'doublesided',
FrontOnly = 'frontonly',
SideBySide = 'sidebyside'
}
export const cardSizeOptions = [
{ title: '88x62 (Poker)', value: CardSize.Poker },
{ title: '88x56 (Bridge)', value: CardSize.Bridge }
]
export const pageSizeOptions = [
{ title: 'A4', value: PageSize.A4 }, // 210mm × 297mm
{ title: 'US Letter', value: PageSize.USLetter }, // 8.5in × 11in
{ title: 'JIS-B4', value: PageSize.JISB4 }, // 182mm × 257mm
{ title: 'A3', value: PageSize.A3 }, // 297mm × 420mm
{ title: 'A5', value: PageSize.A5 }, // 148mm × 210mm
{ title: 'US Legal', value: PageSize.USLegal }, // 8.5in × 14in
{ title: 'US Ledger', value: PageSize.USLedger }, // 11in × 17in
{ title: 'JIS-B5', value: PageSize.JISB5 } // 257mm × 364mm
]
export const arrangementOptions = [
{ title: 'Double Sided', value: Arrangement.DoubleSided },
{ title: 'Only Front Sides', value: Arrangement.FrontOnly },
{ title: 'Side by Side', value: Arrangement.SideBySide }
]
export const defaultPageSize = pageSizeOptions[0].value
export const defaultCardSize = cardSizeOptions[0].value
export const defaultArrangement = arrangementOptions[0].value

@ -1,39 +0,0 @@
import Vue from 'vue'
import { randomId } from './lib'
const eventHandlers: { [key: string]: () => void } = {}
Vue.directive('editable', (el, { value, arg }, vnode) => {
const keypressHandler = (event: KeyboardEvent) => {
// allow line break via Shift + Enter
if (event.keyCode === 13 && !event.shiftKey) {
event.preventDefault()
console.log('edit event on enter', el.innerText)
if (!vnode.context) return
vnode.context.$emit('edit', { param: arg, value: el.innerText })
}
}
const blurHandler = () => {
console.log('edit event on blur', el.innerText)
if (!vnode.context) return
vnode.context.$emit('edit', { param: arg, value: el.innerText })
}
// remove old event listeners
if (el.dataset.__evtid) {
eventHandlers[el.dataset.__evtid]()
}
el.contentEditable = value ? 'true' : 'false'
el.addEventListener('keypress', keypressHandler)
el.addEventListener('blur', blurHandler)
// TODO: is there a better way to avoid multiple event handlers?
const id = randomId()
el.dataset.__evtid = id
eventHandlers[id] = () => {
el.removeEventListener('keypress', keypressHandler)
el.removeEventListener('blur', blurHandler)
}
})

@ -21,7 +21,6 @@ class Charges extends ContentlessBlock {
constructor (args: BlockToolArgs) { constructor (args: BlockToolArgs) {
super(args) super(args)
console.log('new charges', args)
this._settingButtons = [ this._settingButtons = [
{ name: 'box', icon, action: (name: string) => this.setVariant(name) }, { name: 'box', icon, action: (name: string) => this.setVariant(name) },
{ name: 'more', icon: icon, action: () => this.increaseAmount() }, { name: 'more', icon: icon, action: () => this.increaseAmount() },
@ -115,8 +114,6 @@ class Charges extends ContentlessBlock {
el.appendChild(this.createCharge()) el.appendChild(this.createCharge())
} }
console.log('rendered', this._amount, 'charges', el)
return el return el
} }

@ -1,54 +0,0 @@
export function randomId (): string {
const now = Date.now()
const rnd = Math.round(10000000 + Math.random() * 10000000).toString(36)
return `${now}.${rnd}`
}
export function cardSizeFromWH (w: number, h: number): string {
return `${h}x${w}`
}
export function cardWHFromSize (size: string): number[] {
return size.split('x').map(x => parseInt(x, 10)).reverse()
}
export function iconPath (icon: string): string {
return `/img/${icon}.svg`
}
export function cardWHtoStyle (w: number, h: number): object {
const ratio = w / h
return {
width: `calc(var(--card-height) * ${ratio})`
}
}
export function defaultDeck (): Deck {
return {
id: randomId(),
icon: 'robe',
name: 'the nameless',
description: '',
color: '#3C1C00',
cardWidth: 62,
cardHeight: 88,
cards: []
}
}
export function defaultCard (): Card {
return {
id: `c${randomId()}`,
name: 'no title yet',
count: 1,
tags: [],
icon: 'robe',
content: {
time: Date.now(),
blocks: [],
version: '2.17.0'
}
}
}

@ -0,0 +1,49 @@
import { CardSize, defaultCardSize } from '../consts'
import { KV, ICard } from '../types'
import randomId from './randomId'
export function defaultCard (icon = 'robe', name = 'no title yet'): ICard {
return {
id: randomId(),
name,
icon,
tags: [],
content: {
time: Date.now(),
blocks: [{
type: 'heading',
data: {
text: 'Next Level RPG Card',
level: 2
}
}, {
type: 'delimiter',
data: { variant: 'pointing-left' }
}, {
type: 'paragraph',
data: { text: 'This card is a rich text editor so you can basically do whatever you want.' }
}, {
type: 'paragraph',
data: { text: ' ' }
}, {
type: 'paragraph',
data: { text: 'You see that delimiter over there? It seems to be wrong, or maybe you like it that way. In any way you can change it by clicking on it and then on the little tool button on the right.' }
}],
version: '2.17.0'
}
}
}
export function cardWHFromSize (size: CardSize): number[] {
return size.split('x').map(v => parseFloat(v))
}
export function cardCSSVars (size?: CardSize | string, color?: string): KV<string> {
const [w, h] = cardWHFromSize(size as CardSize || defaultCardSize)
const ratio = w / h
return {
backgroundColor: color || 'transparent',
width: `calc(var(--card-height) * ${ratio})`
}
}

@ -0,0 +1,34 @@
import { CardSize, PageSize, Arrangement } from '../consts'
import { IDeck } from '../types'
import randomId from './randomId'
export const defaultDeckValues: IDeck = {
id: '',
icon: 'robe',
name: 'the nameless',
description: '',
color: '#3C1C00',
cards: [],
cardSize: CardSize.Poker,
pageSize: PageSize.A4,
arrangement: Arrangement.DoubleSided,
roundedCorners: true
}
export function defaultDeck (): IDeck {
const newDeck = { ...defaultDeckValues }
newDeck.cards = [] // make sure not to copy a reference
newDeck.id = randomId()
return newDeck
}
export function isValidDeck (deck: any): boolean {
const example = defaultDeckValues as { [key: string]: any }
for (const key in example) {
const type = typeof example[key]
if (typeof deck[key] !== type) return false
}
return true
}

@ -0,0 +1,3 @@
export default function iconPath (icon: string): string {
return `/img/${icon}.svg`
}

@ -0,0 +1,6 @@
export default function randomId (): string {
const now = Date.now()
const rnd = Math.round(10000000 + Math.random() * 10000000).toString(36)
return `${now}.${rnd}`
}

@ -1,22 +1,11 @@
import './class-component-hooks' import { createApp } from 'vue'
import Vue from 'vue'
import App from './App.vue'
import router from './router' import router from './router'
// import './registerServiceWorker' import state from './state'
import './directives'
import StorageHandler from './storage'
declare module 'vue/types/vue' { import App from './App.vue'
interface Vue {
$storage: StorageHandler;
}
}
Vue.config.productionTip = false const app = createApp(App)
Vue.prototype.$storage = new StorageHandler() app.provide('state', state)
app.use(router)
new Vue({ app.mount('#app')
router,
render: h => h(App)
}).$mount('#app')

@ -1,32 +0,0 @@
/* eslint-disable no-console */
import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready () {
console.log(
'App is being served from cache by a service worker.\n' +
'For more details, visit https://goo.gl/AFskqB'
)
},
registered () {
console.log('Service worker has been registered.')
},
cached () {
console.log('Content has been cached for offline use.')
},
updatefound () {
console.log('New content is downloading.')
},
updated () {
console.log('New content is available; please refresh.')
},
offline () {
console.log('No internet connection found. App is running in offline mode.')
},
error (error) {
console.error('Error during service worker registration:', error)
}
})
}

@ -1,34 +1,20 @@
import Vue from 'vue' import { createRouter, createMemoryHistory, createWebHistory } from 'vue-router'
import VueRouter from 'vue-router' import Home from '@/views/Home.vue'
import Home from './views/Home.vue'
Vue.use(VueRouter) // const AsyncDeck = () => import(/* webpackChunkName: "deck", webpackPrefetch: 10 */'./views/Deck.vue')
// const AsyncPrint = () => import(/* webpackChunkName: "print", webpackPrefetch: 1 */'./views/Print.vue')
const AsyncDeck = () => import(/* webpackChunkName: "deck" */'./views/Deck.vue')
const AsyncPrint = () => import(/* webpackChunkName: "print" */'./views/Print.vue')
const routes = [ const isServer = typeof window === 'undefined'
{ const history = isServer ? createMemoryHistory() : createWebHistory()
path: '/',
name: 'Home',
component: Home
},
{
path: '/deck/:id',
name: 'Deck',
component: () => import(/* webpackChunkName "deck" */ './views/Deck.vue')
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
}
]
const router = new VueRouter({ export default createRouter({
mode: 'history', history,
base: process.env.BASE_URL, strict: true,
routes routes: [
{ path: '/', name: 'Home', component: Home },
{ path: '/deck/:id', name: 'Deck', component: AsyncDeck },
{ path: '/print/:id', name: 'Print', component: AsyncPrint },
]
}) })
export default router

13
src/shims-tsx.d.ts vendored

@ -1,13 +0,0 @@
import Vue, { VNode } from 'vue'
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}

@ -1,6 +1,7 @@
declare module '*.vue' { declare module "*.vue" {
import Vue from 'vue' import { defineComponent } from "vue"
export default Vue const Component: ReturnType<typeof defineComponent>
export default Component
} }
declare module '*.txt' { declare module '*.txt' {

@ -0,0 +1,62 @@
import { Ref } from 'vue'
import { Notification, State, IDeck, KV } from '../types'
import { defaultDeck } from '../lib/deck'
type Decks = State['decks']
/// actions are called like action['sub/foo'](state.sub, payload)
export default {
// NOTIFICATION ACTIONS
'notifications/add' (notifications: Ref<Notification[]>, payload: KV<any>) {
notifications.value.push({
level: 'info',
title: '',
content: '',
dismissed: false,
...payload
})
},
'notifications/dismiss' (notifications: Ref<Notification[]>, notification: Notification) {
notification.dismissed = true
notifications.value = notifications.value.filter(note => !note.dismissed)
},
// DECK ACTIONS
// returns index of newly created deck
'decks/new' (decks: Ref<Decks>): string {
const newDeck = defaultDeck()
const id = newDeck.id
decks.value[id] = newDeck
return newDeck.id
},
// updates decks[updatedDeck.id]
'decks/update' (decks: Ref<Decks>, updatedDeck: IDeck): boolean {
const id = updatedDeck.id
if (!id || !decks.value[id]) return false // can't update non-existing deck
decks.value[id] = {
...decks.value[id],
...updatedDeck
}
return true
},
'decks/remove' (decks: Ref<Decks>, deckId: string) {
delete decks.value[deckId]
},
// POPUP ACTIONS
'popup/show' (popup: Ref<boolean>): boolean {
popup.value = true
return popup.value
},
'popup/hide' (popup: Ref<boolean>): boolean {
popup.value = false
return popup.value
},
'popup/toggle' (popup: Ref<boolean>): boolean {
popup.value = !popup.value
return popup.value
},
}

@ -0,0 +1,48 @@
import { ref } from 'vue'
import { State, KV } from '../types'
import { DeckDB } from '../storage'
import { defaultDeck } from '../lib/deck'
import { defaultCard } from '../lib/card'
import stateActions from './actions'
export const state: State = {
settings: ref({}),
decks: ref({}),
notifications: ref([]),
icons: ref(['mouth-watering', 'robe', 'thorny-triskelion']),
popup: ref(false),
loading: ref(false)
}
export function useState (prop: string): { [key: string]: any } {
const collection = state[prop]
const actions = Object.keys(stateActions).reduce((acc, key) => {
if (key.startsWith(`${prop}/`)) {
const newKey = key.slice(prop.length + 1)
acc[newKey] = (payload: KV<any>) => stateActions[key](collection, payload)
}
return acc
}, {})
return { collection, actions }
}
export const deckDB = new DeckDB()
deckDB.getDecks().then(decks => {
state.decks.value = decks
})
const testDeck = defaultDeck()
testDeck.cards.push(defaultCard())
/*
deckDB.putDeck(testDeck).then(() => {
return deckDB.getDecks()
}).then(decks => {
console.log('Created Decks DB', decks)
}).catch(error => {
console.error('Cannot use in-browser database. This happens for example in Firefox when used in private mode. Unfortunately there is no fix. Please use this app outside of private mode. You can read more about the issue here: https://bugzilla.mozilla.org/show_bug.cgi?id=781982 and here: https://bugzilla.mozilla.org/show_bug.cgi?id=1639542', error)
})
*/
export default state

@ -1,47 +1,86 @@
const KEY = 'rpg-cards-ng' import Dexie from 'dexie'
import { CardSize, Arrangement, PageSize } from './consts'
import { IDeck, ICard } from './types'
export default class StorageHandler { interface IDeckTable {
private cache: StoredStuff = { id: string;
decks: [], name: string;
defaults: { description: string;
color: '#3C1C00' color: string;
} icon: string;
} cards: string[]; // array of card IDs
cardSize: CardSize;
arrangement: Arrangement;
pageSize: PageSize;
roundedCorners: boolean;
}
constructor () { export class DeckDB extends Dexie {
if (localStorage.getItem(KEY) === undefined) this.persist() public decks: Dexie.Table<IDeckTable, string>
public cards: Dexie.Table<ICard, string>
public tags: Dexie.Table<string>
const stored = localStorage.getItem(KEY) public constructor () {
if (stored !== null) this.cache = JSON.parse(stored) super('DeckDB')
} console.log('initializing deck db')
get decks (): Deck[] { this.version(1).stores({
return this.cache.decks decks: '&id,name',
} cards: '&id,name,*tags',
tags: '&tag'
})
set decks (decks: Deck[]) { this.decks = this.table('decks')
this.cache.decks = decks this.cards = this.table('cards')
this.persist() this.tags = this.table('tags')
console.log('deck db initialized', this)
} }
saveDeck (newDeck: Deck) { // explicitely ignore ID and add deck to database
const decks = this.cache.decks public async addDeck (deck: IDeck) {
const index = decks.findIndex(deck => deck.id === newDeck.id) const deckWithoutId: IDeckTable = {
...deck,
if (index >= 0) decks[index] = newDeck cards: deck.cards.map(card => card.id)
else decks.push(newDeck) }
delete deckWithoutId.id
await this.decks.add(deckWithoutId)
}
this.persist() // add or update deck
public async putDeck (deck: IDeck) {
const cards = await this.cards.bulkPut(deck.cards, { allKeys: true })
await this.decks.put({ ...deck, cards })
} }
findDeck (id: string): Deck | null { // add or update card
for (const deck of this.cache.decks) { public async putCard (card: ICard, deckId: string) {
if (deck.id === id) return deck const cardId = await this.cards.put(card)
const deck = await this.decks.get(deckId)
if (deck && deck.cards.indexOf(cardId) < 0) {
deck.cards.push(cardId)
await this.decks.put(deck)
} }
return null
} }
persist () { public async getDecks () {
localStorage.setItem(KEY, JSON.stringify(this.cache)) const deckEntries = await this.decks.toArray()
const decks = await Promise.all(deckEntries.map(async deckTable => {
const cardIds = deckTable.cards
const deck: IDeck = {
...deckTable,
cards: await this.cards.bulkGet(cardIds)
}
return deck
}))
// returns object with deck ids as keys
const decksById = decks.reduce((acc, deck) => {
acc[deck.id] = deck
return acc
}, {})
return decksById
} }
} }

46
src/types.d.ts vendored

@ -1,46 +0,0 @@
interface KV<V> {
[key: string]: V;
}
interface ContentBlock {
type: string;
data: object;
}
interface CardContent {
time: number;
blocks: ContentBlock[];
version: string;
}
interface Card {
id: string;
name: string;
count: number;
tags: string[];
icon: string;
content: CardContent;
backIcon?: string;
color?: string;
}
interface Deck {
id: string;
name: string;
description: string;
color: string;
icon: string;
cards: Card[];
cardWidth: number;
cardHeight: number;
titleFontSize?: number;
}
interface Settings {
color: string;
}
interface StoredStuff {
decks: Deck[];
defaults: Settings;
}

@ -0,0 +1,65 @@
import { Ref } from 'vue'
import { PageSize, CardSize, Arrangement } from './consts'
export interface KV<V> {
[key: string]: V;
}
export interface IContentBlock {
type: string;
data: object;
}
export interface ICardContent {
time: number;
blocks: IContentBlock[];
version: string;
}
export interface ICard {
id: string;
name: string;
tags: string[];
icon: string;
content: ICardContent;
backIcon?: string;
color?: string;
}
export interface IDeck {
id: string;
name: string;
description: string;
color: string;
icon: string;
cards: ICard[];
cardSize: CardSize;
arrangement: Arrangement;
pageSize: PageSize;
roundedCorners: boolean;
}
export interface Settings {
/* no global settings, yet */
}
export interface StoredSettings {
decks: IDeck[];
defaults: Settings;
}
export interface Notification {
level: 'warning' | 'error' | 'info';
title: string;
content: string;
dismissed: boolean;
}
export interface State {
settings: Ref<Settings>;
decks: Ref<{ [key: string]: IDeck }>;
notifications: Ref<Notification[]>;
icons: Ref<string[]>;
popup: Ref<boolean>;
loading: Ref<boolean>;
}

@ -1,5 +0,0 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

@ -1,149 +1,90 @@
<template> <template>
<main name="deck" class="loading" v-if="loading"> <template v-if="errorState">
<header>...wait for it...</header> <header>Cannot find this deck</header>
<router-link to="/">« or go back if you're impatient</router-link>
</main>
<main name="deck" class="not-found" v-else-if="notFound">
<header>Deck not found</header>
<router-link to="/">« lets go back home</router-link> <router-link to="/">« lets go back home</router-link>
</main> </template>
<main name="deck" :class="{ popup }" v-else> <template v-else>
<div class="deck-bg"> <div class="deck-bg">
<img :src="deckIcon" /> <img :src="deckIcon" />
</div> </div>
<header> <header>
<span>{{ deck.name }}</span> <span>{{ deck.name }}</span>
<button class="edit-button" @click="popup = true">edit</button> <button class="edit-button">edit</button>
<button class="print-button">print</button>
<p>{{ deck.description }}</p> <p>{{ deck.description }}</p>
</header> </header>
<section name="deck-cards" class="cards" :class="{ centered: !deck.cards.length }"> <section name="deck-cards" class="cards" :class="{ centered: deck.cards.length === 0 }">
<deck-card v-for="(card, i) in deck.cards" <FlipCard v-for="card in deck.cards"
:key="card.id" :key="card.id"
:id="card.id"
:card="card" :card="card"
:deck="deck" :icon="deck.icon"
:is-selection="card === selection" :color="deck.color"
@click="selection = card" :size="deck.cardSize"
@close="selection = null"
@edit="editCard(card, $event.field, $event.value)"
@delete="removeCard(i)"
/> />
<deck-cover @click="newCard" /> <CardBack id="_add" @click="addCard" />
</section> </section>
</template>
<div id="popup" v-show="popup">
<div class="popup-content">
<EditDeckForm
:deck="deck"
@save="closeAndReload"
@close="popup = false"
/>
</div>
</div>
</main>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { defineComponent, watchEffect, ref } from 'vue'
import DeckCover from '@/components/deck-cover.vue' import { useRoute } from 'vue-router'
import DeckCard from '@/components/deck-card.vue' import { IDeck } from '@/types'
import EditDeckForm from '@/components/edit-deck-form.vue' import state from '@/state'
import { iconPath, defaultCard } from '@/lib' import iconPath from '@/lib/iconPath'
import FlipCard from '@/components/FlipCard.vue'
@Component({ import CardBack from '@/components/CardBack.vue'
components: { DeckCover, DeckCard, EditDeckForm }
}) const name = 'Deck'
export default class DeckView extends Vue {
private popup = false export default defineComponent({
private notFound = false components: { FlipCard, CardBack },
private loading = true setup () {
private deck: Deck | null = null const route = useRoute()
private selection: Card | null = null
const errorState = ref(false)
private mounted () { const deck = ref<IDeck | null>(null)
const currentDeckId = this.$route.params.id const deckIcon = ref('')
this.deck = this.$storage.findDeck(currentDeckId)
if (this.deck === null) this.notFound = true watchEffect(() => {
this.loading = false const deckId = route.params.id as string
} const existingDecks = Object.keys(state.decks.value)
const exists = existingDecks.indexOf(deckId) >= 0
private get deckIcon () { errorState.value = !exists
if (this.deck === null) return ''
return iconPath(this.deck.icon) if (exists) {
} deck.value = state.decks.value[deckId]
deckIcon.value = iconPath(deck.value.icon)
private closeAndReload () { }
this.deck = this.$storage.findDeck(this.deck?.id || '')
this.selection = null
this.popup = false
}
private newCard () {
if (this.deck === null) return
const newCard = defaultCard()
newCard.content = {
time: Date.now(),
blocks: [{
type: 'heading',
data: {
text: 'Next Level RPG Card',
level: 2
}
}, {
type: 'delimiter',
data: { variant: 'pointing-left' }
}, {
type: 'paragraph',
data: { text: 'This card is a rich text editor so you can basically do whatever you want.' }
}, {
type: 'paragraph',
data: { text: ' ' }
}, {
type: 'paragraph',
data: { text: 'You see that delimiter over there? It seems to be wrong, or maybe you like it that way. In any way you can change it by clicking on it and then on the little tool button on the right.' }
}],
version: '2.17.0'
}
this.deck.cards.push(newCard)
this.$storage.persist()
this.$nextTick(() => {
this.selection = newCard
}) })
}
private editCard<Card, K extends keyof Card> (card: Card, field: K, value: Card[K]) {
card[field] = value
this.$storage.persist()
}
private removeCard (index: number) {
if (this.deck === null) return
if (this.deck.cards.length - 1 < index) return
const userIsSure = confirm('Are you sure you want to permanently delete this card?') const addCard = () => {}
if (!userIsSure) return
this.deck.cards.splice(index, 1) state.loading.value = false
this.$storage.persist() return { errorState, deck, deckIcon, addCard }
this.closeAndReload() },
beforeRouteEnter (_to, _from, next) {
state.loading.value = true
next()
} }
} })
</script> </script>
<style scoped> <style scoped>
.edit-button { .edit-button, .print-button {
vertical-align: middle; vertical-align: middle;
margin-left: 1em;
margin-top: -2px; margin-top: -2px;
} }
.edit-button {
margin-left: 1em;
}
.deck-bg { .deck-bg {
position: absolute; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100vw; width: 100vw;

@ -1,53 +1,74 @@
<template> <template>
<main name="home" :class="{ popup }"> <header>RPG Cards for y'all</header>
<header>RPG Cards for y'all</header>
<section name="notifications"> <section name="deck-covers" class="cards" :class="{ centered: decks.length === 0 }">
<p class="warning"> <router-link :to="{ name: 'Deck', params: { id: deck.id } }" :key="deck.id" v-for="deck in decks">
<strong>This is a pre-alpha version.</strong> <CardBack :icon="deck.icon" :color="deck.color" :size="deck.cardSize">
Many features are still unstable or completely missing. {{ deck.name }} ({{ deck.cards.length }})
<br /> </CardBack>
Check out <a href="https://github.com/nkoehring/rpg-cards-ng/">the code repository</a> for more information. </router-link>
</p> <CardBack id="_add" @click="addDeck" />
</section> </section>
<section name="deck-covers" class="cards" :class="{ centered: !savedDecks.length }">
<router-link :to="{ name: 'Deck', params: { id: deck.id } }" :key="deck.id" v-for="deck in savedDecks"> <Popup>
<deck-cover :deck="deck" /> <div class="deck new-deck-form-wrapper">
</router-link> <header>Create a new deck of cards</header>
<deck-cover @click="newDeck" /> <DeckForm :deck="newDeck" @save="saveDeck" @cancel="cancelDeck" />
</section> <footer class="centered">
<p class="info" v-if="savedDecks.length === 0">Click the PLUS to create a new deck of cards.</p> You can also
<button @click="importDeck">import</button>
<div id="popup" v-show="popup"> an existing deck.
<div class="popup-content"> </footer>
<NewDeckForm @save="popup = false" @close="popup = false" />
</div>
</div> </div>
</main> </Popup>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { defineComponent, ref, computed } from 'vue'
import DeckCover from '@/components/deck-cover.vue' import { useState } from '@/state'
import NewDeckForm from '@/components/new-deck-form.vue'
@Component({ import Popup from '@/components/Popup.vue'
components: { NewDeckForm, DeckCover } import CardBack from '@/components/CardBack.vue'
}) import DeckForm from '@/components/DeckForm.vue'
export default class Home extends Vue {
private popup = false
private savedDecks: Deck[];
constructor () { export default defineComponent({
super() name: 'Home',
this.savedDecks = this.$storage.decks components: { Popup, CardBack, DeckForm },
} setup () {
const { actions: popupActions } = useState('popup')
const { collection: decks, actions: deckActions } = useState('decks')
private editDeck (deck: Deck) { const newDeckId = ref('')
console.log('would edit deck', deck.name, 'now') const newDeck = computed(() => decks.value[newDeckId.value])
}
const addDeck = () => {
const id = deckActions.new()
newDeckId.value = id
popupActions.show()
}
const saveDeck = (updatedDeck) => {
updatedDeck.id = newDeckId.value
deckActions.update(updatedDeck)
popupActions.hide()
}
private newDeck () { const cancelDeck = () => {
this.popup = true popupActions.hide()
deckActions.remove(newDeckId.value)
newDeckId.value = ''
}
return {
decks,
addDeck,
newDeck,
saveDeck,
cancelDeck,
hidePopup: popupActions.hide
// importDeck: deckActions.import,
}
} }
} })
</script> </script>

@ -0,0 +1,16 @@
<template>
<h1>Welcome {{ name }}</h1>
<p>This is a placeholder view.</p>
</template>
<script lang="ts">
import { defineComponent } from "vue"
const name = 'Print'
export default defineComponent({
setup() {
return { name }
}
})
</script>

@ -1,39 +1,26 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", "allowJs": true,
"allowSyntheticDefaultImports": true,
"declaration": false,
"esModuleInterop": true,
"experimentalDecorators": true,
"module": "esnext", "module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node", "moduleResolution": "node",
"experimentalDecorators": true, "noImplicitAny": false,
"esModuleInterop": true, "noLib": false,
"allowSyntheticDefaultImports": true,
"sourceMap": true, "sourceMap": true,
"strict": true,
"strictPropertyInitialization": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es2015",
"baseUrl": ".", "baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}, },
"exclude": [
"./node_modules"
],
"include": [ "include": [
"src/**/*.ts", "./src/**/*.ts",
"src/**/*.tsx", "./src/**/*.vue",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
], ],
"exclude": [
"node_modules"
]
} }

@ -1,10 +0,0 @@
module.exports = {
chainWebpack: config => {
config.module
.rule('raw')
.test(/\.txt$/)
.use('raw-loader')
.loader('raw-loader')
.end()
}
}

@ -0,0 +1,96 @@
const pkg = require('./package.json')
const { resolve } = require('path')
const { VueLoaderPlugin } = require('vue-loader')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const SriPlugin = require('webpack-subresource-integrity')
const htmlConfig = require('./html.config.json') || {}
const outputPath = resolve(__dirname, './dist')
const publicPath = resolve(__dirname, './public')
module.exports = (env = {}) => ({
mode: env.prod ? 'production' : 'development',
devtool: env.prod ? false : 'eval-source-map',
entry: resolve(__dirname, './src/main.ts'),
output: {
path: outputPath,
crossOriginLoading: 'anonymous'
},
optimization: {
splitChunks: {
chunks: 'async',
minSize: 32000,
maxSize: 48000
}
},
module: {
rules: [{
test: /\.vue$/i,
use: 'vue-loader'
}, {
test: /\.ts$/i,
loader: 'ts-loader',
options: { appendTsSuffixTo: [/\.vue$/] }
}, {
test: /\.css$/i,
use: ['style-loader', 'css-loader']
}, {
test: /\.(png|jpg|gif)$/i,
loader: 'url-loader',
options: { limit: 8192 }
}, {
test: /\.(png|jpg|gif|svg)$/i,
loader: 'file-loader',
options: {
name (/*resourcePath, resourceQuery*/) {
// see https://github.com/webpack-contrib/file-loader
// `resourcePath` - `/absolute/path/to/file.js`
// `resourceQuery` - `?foo=bar`
return env.prod ? '[contenthash].[ext]' : '[path][name].[ext]'
}
}
}, {
test: /\.(txt|raw)$/i,
use: 'raw-loader'
}]
},
resolve: {
extensions: ['.ts', '.js', '.vue', '.json'],
alias: {
'vue': '@vue/runtime-dom',
'@': resolve(__dirname, './src/'),
}
},
plugins: [
new VueLoaderPlugin(),
new CopyWebpackPlugin({
patterns: [{ from: publicPath, to: outputPath }]
}),
new HtmlWebpackPlugin({
title: htmlConfig.title || pkg.name,
meta: htmlConfig.meta || {},
// TODO: not setting template option kinda breaks the build
template: resolve(__dirname, htmlConfig.template || './index.html'),
scriptLoading: htmlConfig.scriptLoading || 'defer',
hash: true
}),
new FaviconsWebpackPlugin({
logo: htmlConfig.logo || './logo.png',
// see https://github.com/itgalaxy/favicons#usage
favicons: htmlConfig.favicons || {}
}),
new SriPlugin({
hashFuncNames: ['sha512'],
enabled: env.prod
})
],
devServer: {
inline: true,
hot: true,
stats: 'minimal',
contentBase: resolve(__dirname, 'dist'),
overlay: true
}
})

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save