create-harper 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/template-react/eslint.config.js +23 -0
- package/template-react/package.json +11 -5
- package/template-react/src/App.jsx +2 -1
- package/template-react/src/counter.js +7 -0
- package/template-react/test/counter.test.js +15 -0
- package/template-react-ts/eslint.config.js +23 -0
- package/template-react-ts/package.json +12 -6
- package/template-react-ts/src/App.tsx +2 -1
- package/template-react-ts/src/counter.ts +7 -0
- package/template-react-ts/test/counter.test.ts +15 -0
- package/template-vanilla/eslint.config.js +23 -0
- package/template-vanilla/package.json +10 -4
- package/template-vanilla/test/counter.test.js +15 -0
- package/template-vanilla/web/counter.js +7 -0
- package/template-vanilla/web/index.html +1 -1
- package/template-vanilla/web/index.js +4 -2
- package/template-vanilla/web/styles.css +31 -31
- package/template-vanilla-ts/eslint.config.js +23 -0
- package/template-vanilla-ts/package.json +10 -4
- package/template-vanilla-ts/test/counter.test.js +15 -0
- package/template-vanilla-ts/web/counter.js +7 -0
- package/template-vanilla-ts/web/index.html +1 -1
- package/template-vanilla-ts/web/index.js +4 -2
- package/template-vanilla-ts/web/styles.css +31 -31
- package/template-vue/README.md +120 -0
- package/template-vue/_aiignore +1 -0
- package/template-vue/_env +3 -0
- package/template-vue/_env.example +3 -0
- package/template-vue/_github/workflow/deploy.yaml +33 -0
- package/template-vue/_gitignore +149 -0
- package/template-vue/_nvmrc +1 -0
- package/template-vue/config.yaml +23 -0
- package/template-vue/deploy-template/config.yaml +2 -0
- package/template-vue/deploy-template/fastify/static.js +14 -0
- package/template-vue/deploy-template/package.json +5 -0
- package/template-vue/eslint.config.js +23 -0
- package/template-vue/graphql.config.yml +3 -0
- package/template-vue/index.html +13 -0
- package/template-vue/package.json +34 -0
- package/template-vue/public/react.svg +14 -0
- package/template-vue/public/typescript.svg +16 -0
- package/template-vue/public/vite.svg +42 -0
- package/template-vue/public/vue.svg +9 -0
- package/template-vue/resources/README.md +11 -0
- package/template-vue/schemas/README.md +11 -0
- package/template-vue/src/App.vue +43 -0
- package/template-vue/src/counter.js +7 -0
- package/template-vue/src/main.js +6 -0
- package/template-vue/src/style.css +96 -0
- package/template-vue/test/counter.test.js +15 -0
- package/template-vue/vite.config.js +22 -0
- package/template-vue-ts/README.md +132 -0
- package/template-vue-ts/_aiignore +1 -0
- package/template-vue-ts/_env +3 -0
- package/template-vue-ts/_env.example +3 -0
- package/template-vue-ts/_github/workflow/deploy.yaml +33 -0
- package/template-vue-ts/_gitignore +149 -0
- package/template-vue-ts/_nvmrc +1 -0
- package/template-vue-ts/config.yaml +23 -0
- package/template-vue-ts/deploy-template/config.yaml +2 -0
- package/template-vue-ts/deploy-template/fastify/static.js +14 -0
- package/template-vue-ts/deploy-template/package.json +5 -0
- package/template-vue-ts/eslint.config.js +23 -0
- package/template-vue-ts/graphql.config.yml +3 -0
- package/template-vue-ts/index.html +13 -0
- package/template-vue-ts/package.json +37 -0
- package/template-vue-ts/public/react.svg +14 -0
- package/template-vue-ts/public/typescript.svg +16 -0
- package/template-vue-ts/public/vite.svg +42 -0
- package/template-vue-ts/public/vue.svg +9 -0
- package/template-vue-ts/resources/README.md +11 -0
- package/template-vue-ts/schemas/README.md +11 -0
- package/template-vue-ts/src/App.vue +43 -0
- package/template-vue-ts/src/counter.ts +7 -0
- package/template-vue-ts/src/main.ts +6 -0
- package/template-vue-ts/src/style.css +96 -0
- package/template-vue-ts/src/vite-env.d.ts +15 -0
- package/template-vue-ts/test/counter.test.ts +15 -0
- package/template-vue-ts/tsconfig.json +33 -0
- package/template-vue-ts/vite.config.ts +22 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-harper",
|
|
3
3
|
"description": "Scaffold a new Harper project in JavaScript or TypeScript.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "HarperDB",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"template-react/",
|
|
19
19
|
"template-react-ts/",
|
|
20
20
|
"template-vanilla/",
|
|
21
|
-
"template-vanilla-ts/"
|
|
21
|
+
"template-vanilla-ts/",
|
|
22
|
+
"template-vue/",
|
|
23
|
+
"template-vue-ts/"
|
|
22
24
|
],
|
|
23
25
|
"scripts": {
|
|
24
26
|
"commitlint": "commitlint --edit",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.browser,
|
|
10
|
+
...globals.node,
|
|
11
|
+
},
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'no-unused-vars': 'warn',
|
|
17
|
+
'no-console': 'off',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
ignores: ['node_modules/'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -6,19 +6,25 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"agent:run": "npx -y @harperfast/agent@latest",
|
|
8
8
|
"agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"lint": "
|
|
9
|
+
"start": "harperdb run .",
|
|
10
|
+
"dev": "harperdb dev .",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"test": "node --test test/*.test.js",
|
|
14
|
+
"test:watch": "node --watch --test test/*.test.js",
|
|
12
15
|
"build": "vite build",
|
|
13
|
-
"preview": "vite preview",
|
|
14
16
|
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && dotenv -- npm run deploy:component && rm -Rf deploy",
|
|
15
17
|
"deploy:component": "(cd deploy && harperdb deploy_component . project=web restart=rolling replicated=true)"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^10.0.1",
|
|
18
21
|
"@harperfast/vite-plugin": "^0.0.1",
|
|
19
22
|
"@vitejs/plugin-react": "^5.1.2",
|
|
20
23
|
"dotenv-cli": "^11.0.0",
|
|
21
|
-
"
|
|
24
|
+
"eslint": "^10.0.2",
|
|
25
|
+
"globals": "^17.4.0",
|
|
26
|
+
"harperdb": "^4.7.20",
|
|
27
|
+
"prettier": "^3.8.1",
|
|
22
28
|
"react": "^19.2.4",
|
|
23
29
|
"react-dom": "^19.2.4",
|
|
24
30
|
"vite": "npm:rolldown-vite@7.3.1"
|
|
@@ -2,11 +2,12 @@ import reactLogo from '/react.svg';
|
|
|
2
2
|
import typescriptLogo from '/typescript.svg';
|
|
3
3
|
import viteLogo from '/vite.svg';
|
|
4
4
|
import { useCallback, useState } from 'react';
|
|
5
|
+
import { increment } from './counter.js';
|
|
5
6
|
|
|
6
7
|
export function App() {
|
|
7
8
|
const [counter, setCounter] = useState(0);
|
|
8
9
|
const countUp = useCallback(() => {
|
|
9
|
-
setCounter(counter => counter
|
|
10
|
+
setCounter(counter => increment(counter));
|
|
10
11
|
}, []);
|
|
11
12
|
|
|
12
13
|
return (
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { decrement, increment } from '../src/counter.js';
|
|
4
|
+
|
|
5
|
+
test('increment function', () => {
|
|
6
|
+
assert.strictEqual(increment(0), 1);
|
|
7
|
+
assert.strictEqual(increment(1), 2);
|
|
8
|
+
assert.strictEqual(increment(-1), 0);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('decrement function', () => {
|
|
12
|
+
assert.strictEqual(decrement(0), -1);
|
|
13
|
+
assert.strictEqual(decrement(1), 0);
|
|
14
|
+
assert.strictEqual(decrement(-1), -2);
|
|
15
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.browser,
|
|
10
|
+
...globals.node,
|
|
11
|
+
},
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'no-unused-vars': 'warn',
|
|
17
|
+
'no-console': 'off',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
ignores: ['node_modules/'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -6,22 +6,28 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"agent:run": "npx -y @harperfast/agent@latest",
|
|
8
8
|
"agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"lint": "
|
|
12
|
-
"
|
|
13
|
-
"
|
|
9
|
+
"start": "harperdb run .",
|
|
10
|
+
"dev": "harperdb dev .",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"test": "node --test test/*.test.ts",
|
|
14
|
+
"test:watch": "node --watch --test test/*.test.ts",
|
|
15
|
+
"build": "vite build",
|
|
14
16
|
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && dotenv -- npm run deploy:component && rm -Rf deploy",
|
|
15
17
|
"deploy:component": "(cd deploy && harperdb deploy_component . project=web restart=rolling replicated=true)"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^10.0.1",
|
|
18
21
|
"@harperfast/vite-plugin": "^0.0.1",
|
|
19
22
|
"@types/node": "^24.10.1",
|
|
20
23
|
"@types/react": "^19.2.10",
|
|
21
24
|
"@types/react-dom": "^19.2.3",
|
|
22
25
|
"@vitejs/plugin-react": "^5.1.2",
|
|
23
26
|
"dotenv-cli": "^11.0.0",
|
|
24
|
-
"
|
|
27
|
+
"eslint": "^10.0.2",
|
|
28
|
+
"globals": "^17.4.0",
|
|
29
|
+
"harperdb": "^4.7.20",
|
|
30
|
+
"prettier": "^3.8.1",
|
|
25
31
|
"react": "^19.2.4",
|
|
26
32
|
"react-dom": "^19.2.4",
|
|
27
33
|
"typescript": "~5.9.3",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import reactLogo from '/react.svg';
|
|
2
2
|
import typescriptLogo from '/typescript.svg';
|
|
3
3
|
import viteLogo from '/vite.svg';
|
|
4
|
+
import { increment } from '@/counter.ts';
|
|
4
5
|
import { useCallback, useState } from 'react';
|
|
5
6
|
|
|
6
7
|
export function App() {
|
|
7
8
|
const [counter, setCounter] = useState(0);
|
|
8
9
|
const countUp = useCallback(() => {
|
|
9
|
-
setCounter(counter => counter
|
|
10
|
+
setCounter((counter: number) => increment(counter));
|
|
10
11
|
}, []);
|
|
11
12
|
|
|
12
13
|
return (
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { strictEqual } from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { decrement, increment } from '../src/counter.ts';
|
|
4
|
+
|
|
5
|
+
test('increment function', () => {
|
|
6
|
+
strictEqual(increment(0), 1);
|
|
7
|
+
strictEqual(increment(1), 2);
|
|
8
|
+
strictEqual(increment(-1), 0);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('decrement function', () => {
|
|
12
|
+
strictEqual(decrement(0), -1);
|
|
13
|
+
strictEqual(decrement(1), 0);
|
|
14
|
+
strictEqual(decrement(-1), -2);
|
|
15
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.browser,
|
|
10
|
+
...globals.node,
|
|
11
|
+
},
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'no-unused-vars': 'warn',
|
|
17
|
+
'no-console': 'off',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
ignores: ['node_modules/'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -8,13 +8,19 @@
|
|
|
8
8
|
"agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
|
|
9
9
|
"start": "harperdb run .",
|
|
10
10
|
"dev": "harperdb dev .",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"test": "node --test test/*.test.js",
|
|
14
|
+
"test:watch": "node --watch --test test/*.test.js",
|
|
11
15
|
"deploy": "dotenv -- npm run deploy:component",
|
|
12
|
-
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
13
|
-
"test": "echo 'No tests implemented yet'",
|
|
14
|
-
"lint": "echo 'No lint implemented yet'"
|
|
16
|
+
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
19
|
+
"@eslint/js": "^10.0.1",
|
|
17
20
|
"dotenv-cli": "^11.0.0",
|
|
18
|
-
"
|
|
21
|
+
"eslint": "^10.0.2",
|
|
22
|
+
"globals": "^17.4.0",
|
|
23
|
+
"harperdb": "^4.7.20",
|
|
24
|
+
"prettier": "^3.8.1"
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { decrement, increment } from '../web/counter.js';
|
|
4
|
+
|
|
5
|
+
test('increment function', () => {
|
|
6
|
+
assert.strictEqual(increment(0), 1);
|
|
7
|
+
assert.strictEqual(increment(1), 2);
|
|
8
|
+
assert.strictEqual(increment(-1), 0);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('decrement function', () => {
|
|
12
|
+
assert.strictEqual(decrement(0), -1);
|
|
13
|
+
assert.strictEqual(decrement(1), 0);
|
|
14
|
+
assert.strictEqual(decrement(-1), -2);
|
|
15
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { decrement, increment } from './counter.js';
|
|
2
|
+
|
|
1
3
|
let count = 0;
|
|
2
4
|
const counterDisplay = document.getElementById('count');
|
|
3
5
|
const decrementButton = document.getElementById('decrement');
|
|
@@ -8,11 +10,11 @@ function updateDisplay() {
|
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
decrementButton.addEventListener('click', () => {
|
|
11
|
-
count
|
|
13
|
+
count = decrement(count);
|
|
12
14
|
updateDisplay();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
incrementButton.addEventListener('click', () => {
|
|
16
|
-
count
|
|
18
|
+
count = increment(count);
|
|
17
19
|
updateDisplay();
|
|
18
20
|
});
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
body {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
font-family: Arial, sans-serif;
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
|
+
height: 100vh;
|
|
7
|
+
margin: 0;
|
|
8
|
+
background-color: #f5f5f5;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
main {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
text-align: center;
|
|
13
|
+
background-color: white;
|
|
14
|
+
padding: 2rem;
|
|
15
|
+
border-radius: 8px;
|
|
16
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.count {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
font-size: 4rem;
|
|
21
|
+
margin: 1rem 0;
|
|
22
|
+
color: #333;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.counter-controls {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
gap: 1rem;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
button {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
font-size: 1.5rem;
|
|
33
|
+
width: 3rem;
|
|
34
|
+
height: 3rem;
|
|
35
|
+
border: none;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
transition: background-color 0.2s;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.decrement {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
background-color: #ff6b6b;
|
|
43
|
+
color: white;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.decrement:hover {
|
|
47
|
-
|
|
47
|
+
background-color: #ff5252;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.increment {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
background-color: #4ecdc4;
|
|
52
|
+
color: white;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.increment:hover {
|
|
56
|
-
|
|
56
|
+
background-color: #39b2a9;
|
|
57
57
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
js.configs.recommended,
|
|
6
|
+
{
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.browser,
|
|
10
|
+
...globals.node,
|
|
11
|
+
},
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'no-unused-vars': 'warn',
|
|
17
|
+
'no-console': 'off',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
ignores: ['node_modules/'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -8,13 +8,19 @@
|
|
|
8
8
|
"agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
|
|
9
9
|
"start": "harperdb run .",
|
|
10
10
|
"dev": "harperdb dev .",
|
|
11
|
+
"lint": "eslint .",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"test": "node --test test/*.test.js",
|
|
14
|
+
"test:watch": "node --watch --test test/*.test.js",
|
|
11
15
|
"deploy": "dotenv -- npm run deploy:component",
|
|
12
|
-
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
13
|
-
"test": "echo 'No tests implemented yet'",
|
|
14
|
-
"lint": "echo 'No lint implemented yet'"
|
|
16
|
+
"deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
19
|
+
"@eslint/js": "^10.0.1",
|
|
17
20
|
"dotenv-cli": "^11.0.0",
|
|
18
|
-
"
|
|
21
|
+
"eslint": "^10.0.2",
|
|
22
|
+
"globals": "^17.4.0",
|
|
23
|
+
"harperdb": "^4.7.20",
|
|
24
|
+
"prettier": "^3.8.1"
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { decrement, increment } from '../web/counter.js';
|
|
4
|
+
|
|
5
|
+
test('increment function', () => {
|
|
6
|
+
assert.strictEqual(increment(0), 1);
|
|
7
|
+
assert.strictEqual(increment(1), 2);
|
|
8
|
+
assert.strictEqual(increment(-1), 0);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('decrement function', () => {
|
|
12
|
+
assert.strictEqual(decrement(0), -1);
|
|
13
|
+
assert.strictEqual(decrement(1), 0);
|
|
14
|
+
assert.strictEqual(decrement(-1), -2);
|
|
15
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { decrement, increment } from './counter.js';
|
|
2
|
+
|
|
1
3
|
let count = 0;
|
|
2
4
|
const counterDisplay = document.getElementById('count');
|
|
3
5
|
const decrementButton = document.getElementById('decrement');
|
|
@@ -8,11 +10,11 @@ function updateDisplay() {
|
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
decrementButton.addEventListener('click', () => {
|
|
11
|
-
count
|
|
13
|
+
count = decrement(count);
|
|
12
14
|
updateDisplay();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
incrementButton.addEventListener('click', () => {
|
|
16
|
-
count
|
|
18
|
+
count = increment(count);
|
|
17
19
|
updateDisplay();
|
|
18
20
|
});
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
body {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
font-family: Arial, sans-serif;
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
|
+
height: 100vh;
|
|
7
|
+
margin: 0;
|
|
8
|
+
background-color: #f5f5f5;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
main {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
text-align: center;
|
|
13
|
+
background-color: white;
|
|
14
|
+
padding: 2rem;
|
|
15
|
+
border-radius: 8px;
|
|
16
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.count {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
font-size: 4rem;
|
|
21
|
+
margin: 1rem 0;
|
|
22
|
+
color: #333;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.counter-controls {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
gap: 1rem;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
button {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
font-size: 1.5rem;
|
|
33
|
+
width: 3rem;
|
|
34
|
+
height: 3rem;
|
|
35
|
+
border: none;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
transition: background-color 0.2s;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.decrement {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
background-color: #ff6b6b;
|
|
43
|
+
color: white;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.decrement:hover {
|
|
47
|
-
|
|
47
|
+
background-color: #ff5252;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.increment {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
background-color: #4ecdc4;
|
|
52
|
+
color: white;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.increment:hover {
|
|
56
|
-
|
|
56
|
+
background-color: #39b2a9;
|
|
57
57
|
}
|