Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit d7edbf2

Browse files
authored
Reimplement frontend in Svelte (#18)
* Switch from React+CRA to Svelte * Add routing, queries, and Bulma * Update API client for the ZeroTier One service * Style the navbar and implement dark mode toggle * Configure fonts * Improve dark mode colors and theme decomposition, and add toggle icon * Improve layout and scroll behavior for the navbar * Improve scrollbar visibility in dark mode * Tweak theme grayscale colors * Improve navbar height responsiveness * Reimplement home page in Svelte * Reimplement peers page in Svelte, add animations * Reimplement smart display of network names in Svelte * Reimplement network lists & info in Svelte * Don't use the tauri helper/os-check module, since it's an internal API * Svelte components with transitions shouldn't retry queries on mount * Hide empty sections of the Networks page, with animations * Improve contrast/readability of success & danger tags * Implement modal drawers with animations * Fix build configuration * Implement join form in Svelte, stop spurious clicks for modal background * Fix problems with freezing on Jetson Nano (aarch64, Ubuntu 18.04) * Make transitions in the Jetson Nano fix be local * Add rollup processing config to disable animations by env var * Fix shift-tab focus cycling behavior in the modals * Reimplement joining network by id in Svelte * Reimplement joining network by domain name in Svelte * Bump the version number * Reorganize stylesheets for reusability * Resolve linter complaints bout unused imports/variables * Resolve eslint issues
1 parent b5c9edc commit d7edbf2

131 files changed

Lines changed: 8313 additions & 15973 deletions

File tree

Some content is hidden

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

.eslintrc.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
module.exports = {
2+
parser: '@typescript-eslint/parser',
23
extends: [
3-
'airbnb',
4-
'airbnb-typescript',
5-
'airbnb/hooks',
4+
'eslint:recommended',
65
'plugin:@typescript-eslint/recommended',
7-
'plugin:jest/recommended',
8-
'plugin:prettier/recommended'
6+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
97
],
10-
plugins: ['react', '@typescript-eslint', 'jest'],
11-
env: {
12-
browser: true,
13-
es6: true,
14-
jest: true,
15-
},
16-
globals: {
17-
Atomics: 'readonly',
18-
SharedArrayBuffer: 'readonly',
19-
},
20-
parser: '@typescript-eslint/parser',
218
parserOptions: {
22-
ecmaFeatures: {
23-
jsx: true,
24-
},
25-
ecmaVersion: 2018,
9+
ecmaVersion: 2020,
2610
sourceType: 'module',
2711
project: './tsconfig.json',
12+
extraFileExtensions: ['.svelte']
13+
},
14+
env: {
15+
browser: true,
16+
es6: true
17+
},
18+
overrides: [
19+
{
20+
files: ['*.svelte'],
21+
processor: 'svelte3/svelte3',
22+
rules: {
23+
// For some reason, eslint generates false positives wherever I use svelte-query,
24+
// even though svelte-query has all the type annotations and they make sense to me.
25+
// We'll just rely on svelte-check to warn us about `any` values.
26+
'@typescript-eslint/no-unsafe-assignment': 'off',
27+
'@typescript-eslint/no-unsafe-member-access': 'off',
28+
'@typescript-eslint/no-unsafe-call': 'off',
29+
'@typescript-eslint/restrict-template-expressions': 'off',
30+
},
31+
}
32+
],
33+
plugins: ['svelte3', '@typescript-eslint'],
34+
settings: {
35+
'svelte3/typescript': require('typescript')
36+
// ignore style tags in Svelte because of Tailwind CSS
37+
// See https://github.com/sveltejs/eslint-plugin-svelte3/issues/70
38+
//'svelte3/ignore-styles': () => true
2839
},
2940
rules: {
3041
'linebreak-style': 'off',
31-
'prettier/prettier': [
32-
'warn',
33-
{
34-
endOfLine: 'auto',
35-
singleQuote: true,
36-
semi: true,
37-
trailingCommas: 'all'
38-
},
39-
],
40-
'react/jsx-props-no-spreading': 'off'
4142
},
43+
ignorePatterns: ['node_modules']
4244
};

.github/workflows/build-tauri-app.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ jobs:
2626
${{ runner.os }}-yarn-
2727
- name: Install app dependencies
2828
run: yarn --prefer-offline
29+
- name: Run format checker
30+
run: yarn formatted
2931
- name: Run linter
3032
run: yarn lint
33+
- name: Run svelte checker
34+
run: yarn svelte-check
3135
- name: Run frontend build
3236
run: yarn build
3337

@@ -145,7 +149,7 @@ jobs:
145149
echo "Run bundle build"
146150
# Note: right now tauri's appimage.sh is hardcoded to build AppImages
147151
# against x86_64, so we can't build AppImage bundles for ARM.
148-
cargo tauri build --bundle deb
152+
REMOVE_TRANSFORM_ANIMATIONS=1 cargo tauri build --bundle deb
149153
- name: Upload the build artifacts
150154
uses: actions/upload-artifact@v2
151155
with:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/.pnp
66
.pnp.js
77

8-
# testing
9-
/coverage
8+
# build
9+
/public/build/
1010

1111
# production
1212
/build
@@ -18,6 +18,7 @@
1818
.env.test.local
1919
.env.production.local
2020

21+
# package managers
2122
npm-debug.log*
2223
yarn-debug.log*
2324
yarn-error.log*

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
singleQuote: true,
3+
trailingComma: 'all',
4+
bracketSameLine: true,
5+
plugins: ['prettier-plugin-svelte'],
6+
svelteSortOrder: 'options-scripts-markup-styles',
7+
svelteStrictMode: false,
8+
svelteBracketNewLine: true,
9+
svelteIndentScriptAndStyle: true,
10+
}

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["svelte.svelte-vscode"]
3+
}

config-overrides.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

package.json

Lines changed: 47 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,60 @@
11
{
22
"name": "latreutes",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"private": true,
5-
"dependencies": {
6-
"@chakra-ui/icons": "^1.0.15",
7-
"@chakra-ui/react": "^1.6.7",
8-
"@chakra-ui/theme-tools": "^1.2.0",
9-
"@emotion/react": "^11",
10-
"@emotion/styled": "^11",
11-
"@fontsource/atkinson-hyperlegible": "^4.5.1",
12-
"@fontsource/oxygen-mono": "^4.5.0",
13-
"@tauri-apps/api": "^1.0.0-beta.6",
14-
"@testing-library/jest-dom": "^5.14.1",
15-
"@testing-library/react": "^11.2.7",
16-
"@testing-library/user-event": "^12.8.3",
17-
"@types/jest": "^26.0.24",
18-
"@types/node": "^12.20.19",
19-
"@types/react": "^17.0.18",
20-
"@types/react-dom": "^17.0.9",
21-
"formik": "^2.2.9",
22-
"framer-motion": "^4",
23-
"react": "^17.0.2",
24-
"react-dom": "^17.0.2",
25-
"react-query": "^3.21.0",
26-
"react-router-dom": "^5.2.1",
27-
"react-scripts": "^4.0.3",
28-
"react-tabs": "^3.2.2",
29-
"typescript": "^4.3.5",
30-
"validator": "^13.6.0",
31-
"web-vitals": "^1.1.2"
32-
},
335
"scripts": {
34-
"start": "BROWSER=none react-app-rewired start",
35-
"build": "react-app-rewired build",
36-
"test": "react-app-rewired test",
37-
"eject": "react-app-rewired eject",
6+
"build": "rollup -c",
7+
"dev": "rollup -c -w",
8+
"start": "sirv public --no-clear",
9+
"check": "svelte-check --tsconfig ./tsconfig.json",
3810
"tauri": "tauri",
39-
"lint": "tsc --noEmit && eslint src/**/*.ts{,x}",
40-
"lint:fix": "tsc --noEmit && eslint src/**/*.ts{,x} --fix"
41-
},
42-
"eslintConfig": {
43-
"extends": [
44-
"react-app",
45-
"react-app/jest"
46-
]
47-
},
48-
"browserslist": {
49-
"production": [
50-
">0.2%",
51-
"not dead",
52-
"not op_mini all"
53-
],
54-
"development": [
55-
"last 1 chrome version",
56-
"last 1 firefox version",
57-
"last 1 safari version"
58-
]
11+
"formatted": "prettier --check ./src/**/*.{js,svelte,html,ts}",
12+
"format": "prettier --write ./src/**/*.{js,svelte,html,ts}",
13+
"lint": "tsc --noEmit && prettier --write ./src/**/*.{js,svelte,html,ts} && eslint src/**/*.{js,ts,svelte}",
14+
"lint:fix": "tsc --noEmit && prettier --write ./src/**/*.{js,svelte,html,ts} && eslint --fix src/**/*.{js,ts,svelte}"
5915
},
6016
"devDependencies": {
61-
"@tauri-apps/cli": "^1.0.0-beta.8",
62-
"@types/react-router-dom": "^5.1.8",
63-
"@types/react-tabs": "^2.3.3",
17+
"@mdi/js": "^6.1.95",
18+
"@rollup/plugin-commonjs": "^17.0.0",
19+
"@rollup/plugin-node-resolve": "^11.0.0",
20+
"@rollup/plugin-typescript": "^8.0.0",
21+
"@tauri-apps/cli": "^1.0.0-beta.10",
22+
"@tsconfig/svelte": "^2.0.0",
6423
"@types/validator": "^13.6.3",
6524
"@typescript-eslint/eslint-plugin": "^4.29.3",
6625
"@typescript-eslint/parser": "^4.29.3",
67-
"eslint": "^7.2.0",
68-
"eslint-config-airbnb": "^18.2.1",
69-
"eslint-config-airbnb-typescript": "^14.0.0",
70-
"eslint-config-prettier": "^8.3.0",
26+
"bulma": "^0.9.3",
27+
"eslint": "^7.32.0",
7128
"eslint-plugin-import": "^2.24.2",
72-
"eslint-plugin-jest": "^24.4.0",
73-
"eslint-plugin-jsx-a11y": "^6.4.1",
74-
"eslint-plugin-prettier": "^3.4.1",
75-
"eslint-plugin-react": "^7.21.5",
76-
"eslint-plugin-react-hooks": "^1.7.0",
77-
"prettier": "^2.3.2",
78-
"react-app-rewired": "^2.1.8"
29+
"eslint-plugin-svelte3": "^3.2.1",
30+
"mdi-svelte": "^1.1.2",
31+
"node-sass": "^6.0.1",
32+
"prettier": "^2.4.1",
33+
"prettier-plugin-svelte": "^2.4.0",
34+
"rollup": "^2.3.4",
35+
"rollup-plugin-copy": "^3.4.0",
36+
"rollup-plugin-css-only": "^3.1.0",
37+
"rollup-plugin-livereload": "^2.0.0",
38+
"rollup-plugin-re": "^1.0.7",
39+
"rollup-plugin-svelte": "^7.0.0",
40+
"rollup-plugin-terser": "^7.0.0",
41+
"svelte": "^3.0.0",
42+
"svelte-accessible-accordion": "^2.0.0",
43+
"svelte-check": "^2.2.7",
44+
"svelte-dark-mode": "^2.0.0",
45+
"svelte-preprocess": "^4.0.0",
46+
"tslib": "^2.0.0",
47+
"typescript": "^4.0.0"
48+
},
49+
"dependencies": {
50+
"@felte/reporter-svelte": "^0.3.16",
51+
"@fontsource/atkinson-hyperlegible": "^4.5.1",
52+
"@fontsource/oxygen-mono": "^4.5.0",
53+
"@sveltestack/svelte-query": "^1.4.1",
54+
"@tauri-apps/api": "^1.0.0-beta.8",
55+
"felte": "^0.8.3",
56+
"sirv-cli": "^1.0.0",
57+
"svelte-routing": "^1.6.0",
58+
"validator": "^13.6.0"
7959
}
8060
}

public/favicon.ico

-3.78 KB
Binary file not shown.

public/favicon.png

3.05 KB
Loading

public/index.html

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,17 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
14-
manifest.json provides metadata used when your web app is installed on a
15-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16-
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
19-
Notice the use of %PUBLIC_URL% in the tags above.
20-
It will be replaced with the URL of the `public` folder during the build.
21-
Only files inside the `public` folder can be referenced from the HTML.
3+
<head>
4+
<meta charset='utf-8'>
5+
<meta name='viewport' content='width=device-width,initial-scale=1'>
226

23-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24-
work correctly both with client-side routing and a non-root public URL.
25-
Learn how to configure a non-root public URL by running `npm run build`.
26-
-->
27-
<title>React App</title>
28-
</head>
29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
33-
This HTML file is a template.
34-
If you open it directly in the browser, you will see an empty page.
7+
<title>Svelte app</title>
358

36-
You can add webfonts, meta tags, or analytics to this file.
37-
The build step will place the bundled scripts into the <body> tag.
9+
<link rel='icon' type='image/png' href='/favicon.png'>
10+
<link rel='stylesheet' href='/build/bundle.css'>
3811

39-
To begin the development, run `npm start` or `yarn start`.
40-
To create a production bundle, use `npm run build` or `yarn build`.
41-
-->
42-
</body>
12+
<script defer src='/build/bundle.js'></script>
13+
</head>
14+
15+
<body>
16+
</body>
4317
</html>

0 commit comments

Comments
 (0)