Skip to content

Commit 9f4103d

Browse files
committed
docs: cv app example
1 parent e3b8340 commit 9f4103d

File tree

117 files changed

+5598
-624
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+5598
-624
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { globalIgnores } from 'eslint/config'
2+
import baseConfig from '@trigen/eslint-config'
3+
import bundlerConfig from '@trigen/eslint-config/bundler'
4+
import reactConfig from '@trigen/eslint-config/react'
5+
import tsTypeCheckedConfig from '@trigen/eslint-config/typescript-type-checked'
6+
import testConfig from '@trigen/eslint-config/test'
7+
import env from '@trigen/eslint-config/env'
8+
9+
export default [
10+
globalIgnores(['**/dist/']),
11+
...baseConfig,
12+
...bundlerConfig,
13+
...reactConfig,
14+
...tsTypeCheckedConfig,
15+
...testConfig,
16+
env.browser,
17+
{
18+
languageOptions: {
19+
parserOptions: {
20+
projectService: true,
21+
tsconfigRootDir: import.meta.dirname
22+
}
23+
},
24+
rules: {
25+
'@typescript-eslint/no-invalid-void-type': 'off'
26+
}
27+
}
28+
]

examples/cvapp/react/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>CV APP</title>
7+
<link rel="stylesheet" href="/src/index.css" />
8+
<script type="module" src="/src/index.tsx"></script>
9+
</head>
10+
<body>
11+
<div id="app"></div>
12+
</body>
13+
</html>

examples/cvapp/react/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "cvapp",
3+
"type": "module",
4+
"author": "Dan Onoshko <danon0404@gmail.com>",
5+
"license": "ISC",
6+
"scripts": {
7+
"clear": "del ./dist",
8+
"dev": "vite",
9+
"build:sprite": "node ./scripts/svg-sprite.js",
10+
"build": "run tsc [ vite build ]",
11+
"preview": "vite preview",
12+
"lint:styles": "stylelint 'src/**/*.css'",
13+
"lint:scripts": "eslint --flag v10_config_lookup_from_file",
14+
"lint": "run -p lint:styles lint:scripts",
15+
"format:styles": "stylelint 'src/**/*.css' --fix",
16+
"format:scripts": "eslint --fix --flag v10_config_lookup_from_file",
17+
"format": "run -p format:styles format:scripts",
18+
"test:types": "tsc",
19+
"test": "run -p lint test:types"
20+
},
21+
"dependencies": {
22+
"clsx": "^2.1.1",
23+
"modern-normalize": "^3.0.1",
24+
"nanoid": "^5.1.6"
25+
},
26+
"devDependencies": {
27+
"@trigen/scripts": "^8.0.4",
28+
"@trigen/stylelint-config": "^8.0.0",
29+
"@types/svg-sprite": "^0.0.39",
30+
"@vitejs/plugin-react-swc": "^4.2.2",
31+
"postcss-custom-media": "^11.0.6",
32+
"stylelint": "^16.25.0",
33+
"svg-sprite": "^2.0.4",
34+
"typescript": "^5.9.3",
35+
"vite": "^7.2.2"
36+
}
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {
2+
resolve,
3+
join,
4+
basename
5+
} from 'node:path'
6+
import {
7+
readFile,
8+
writeFile,
9+
glob
10+
} from 'node:fs/promises'
11+
import SVGSpriter from 'svg-sprite'
12+
13+
const rootDir = resolve(import.meta.dirname, '..')
14+
const spriter = new SVGSpriter({
15+
mode: {
16+
symbol: true
17+
}
18+
})
19+
const iconFiles = glob(join(rootDir, 'src', 'assets', 'icons', '*.svg'))
20+
const tasks = []
21+
22+
for await (const filePath of iconFiles) {
23+
const fileName = basename(filePath)
24+
25+
tasks.push(readFile(filePath, 'utf-8').then((content) => {
26+
spriter.add(fileName, fileName, content)
27+
}))
28+
}
29+
30+
await Promise.all(tasks)
31+
32+
const { result } = await spriter.compileAsync()
33+
34+
await writeFile(join(rootDir, 'src', 'assets', 'sprite.svg'), result.symbol.sprite.contents)

examples/cvapp/react/src/App.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
onMount,
3+
onMountEffect
4+
} from '@nano_kit/store'
5+
import {
6+
app,
7+
page,
8+
layout,
9+
listenLinks,
10+
resetScroll
11+
} from '@nano_kit/react-router'
12+
import {
13+
$location,
14+
$prevRoute,
15+
navigation
16+
} from './stores/router'
17+
import { Layout } from './pages/Layout'
18+
import { Home } from './pages/Home'
19+
import { Application } from './pages/Application'
20+
21+
onMount($location, () => listenLinks(navigation))
22+
23+
onMountEffect($location, (initial) => {
24+
const shouldReset = (
25+
$prevRoute() !== 'newApplication'
26+
|| $location.$route() !== 'application'
27+
) && !initial
28+
29+
if (shouldReset) {
30+
resetScroll()
31+
}
32+
})
33+
34+
export const App = app($location, [
35+
layout(Layout, [
36+
page('home', Home),
37+
page('newApplication', Application),
38+
page('application', Application)
39+
])
40+
])
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)