Skip to content

Commit 65503fc

Browse files
committed
chores: cleanup and doc update
1 parent 0efa2bb commit 65503fc

File tree

7 files changed

+20810
-1332
lines changed

7 files changed

+20810
-1332
lines changed

frontend/docs/ARCHITECTURE.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ SvelteKit has a lot of features and it is time well-spend to read about them.
66

77
Mainly we use SvelteKit for the following reasons:
88

9-
* Well-maintained framework that is lightweight and does lead to very fast light-weight frontend code.
10-
* Rich ecosystem of third party components
11-
* Open Source
12-
* Other frameworks, such as React, require you to choose among many different third party components that are not always compatible or different React developers are used to different third party components
9+
- Well-maintained framework that is lightweight and does lead to very fast light-weight frontend code.
10+
- Rich ecosystem of third party components
11+
- Open Source
12+
- Other frameworks, such as React, require you to choose among many different third party components that are not always compatible or different React developers are used to different third party components
1313

1414
# Static assets
15-
All static assets to be included in the frontend can be found in [../static/](../static/). We have mainly a local copy of the Material icons used in the application. This is also recommended by [Google](https://developers.google.com/fonts/docs/material_icons#setup_method_2_self_hosting). This is faster and more secure than directly fetching them every time when the application us opened by th user from a Google server.
15+
16+
All static assets to be included in the frontend can be found in [../static/](../static/) (except fonts/icons).
17+
18+
Fonts are NPM packages from [Fontsource](https://fontsource.org/). This means they are included in the web app instead of fetching them during runtime from an external source. You need to install the fonts as devDependency, include them in [../src/routes/+layout.svelte](../src/routes/+layout.svelte) and update the scss file [../src/app.scss](../src/app.scss) with the class used for the fonts.
19+
20+
We have mainly a local copy of the Material icons used in the application. This is also recommended by [Google](https://developers.google.com/fonts/docs/material_icons#setup_method_2_self_hosting). This is faster and more secure than directly fetching them every time when the application us opened by th user from a Google server.
1621

1722
# SvelteKit
23+
1824
We use here [SvelteKit](https://svelte.dev/docs/kit/introduction) to make developing with Svelte simpler and it includes a lot of best practices.
1925

2026
# Logger
@@ -29,14 +35,12 @@ We provide a global HTTP Client (see [../src/lib/httpclient/](../src/lib/httpcli
2935

3036
By using the HTTP Client you do not need to implement the same error handling functionality in each component that does HTTP requests.
3137

32-
3338
# Accessibility
3439

3540
You should take care to implement [accessibility](https://svelte.dev/docs/kit/accessibility) in your application - this makes the application more usable for everyone.
3641

3742
Note: We had to deactivate (see [../svelte.config.js](../svelte.config.js) to activate it) one accessibility component: The route announcer. The reason was that it [clashes with Content-Security Policies](https://github.com/sveltejs/kit/issues/11993).
3843

39-
4044
# Security
4145

4246
## Content-Security-Policy
@@ -45,17 +49,14 @@ The backend emits content security policy HTTP headers. They are very strict and
4549

4650
The application supports strict content-security-policies **_WITHOUT_** unsafe-\*. We do so by letting the backend insert every request to the frontend a random nonce (see [backend documentation](../../backend/docs/CONFIGURE.md)) into the scripts
4751

48-
4952
Note: When running the frontend without the backend then no content security policies are applied. It is thus highly recommended to test all UI functionality with the backend.
5053

5154
## Input/Output Sanitzation
5255

53-
5456
As a web frontend it is crucial that you do proper input/output sanitization in frontend AND backend. For the frontend the following mechanisms are relevant:
5557

5658
- By default Svelte does not render any HTML/Scripts inserted as variables or by the user: https://svelte.dev/tutorial/svelte/html-tags
5759

5860
You should not render HTML/Scripts in variables or by the user, because this allows simple [Cross-Site Scripting attacks](https://en.wikipedia.org/wiki/Cross-site_scripting).
5961

60-
6162
Note: You always need to ADDITIONALLY do sanitization in the backend (see [documentation](../../backend/docs/ARCHITECTURE.md)).

frontend/src/app.scss

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
3-
41
// Elevation mixins.
52
@use '@material/elevation/index' as elevation;
63

@@ -16,7 +13,6 @@
1613
@use '@material/theme/color-palette';
1714
@use '@material/theme/theme-color';
1815

19-
2016
.mdc-snackbar.httpclient-error {
2117
@include snackbar.fill-color(color-palette.$red-500);
2218
@include snackbar.label-ink-color(theme-color.accessible-ink-color(color-palette.$red-500));
@@ -32,26 +28,26 @@
3228

3329
// see routes/+layout.svelte on the import of the fontsource package
3430
.material-icons {
35-
font-family: 'Material Icons';
36-
font-weight: normal;
37-
font-style: normal;
38-
font-size: 24px; /* Preferred icon size */
39-
display: inline-block;
40-
line-height: 1;
41-
text-transform: none;
42-
letter-spacing: normal;
43-
word-wrap: normal;
44-
white-space: nowrap;
45-
direction: ltr;
46-
47-
/* Support for all WebKit browsers. */
48-
-webkit-font-smoothing: antialiased;
49-
/* Support for Safari and Chrome. */
50-
text-rendering: optimizeLegibility;
51-
52-
/* Support for Firefox. */
53-
-moz-osx-font-smoothing: grayscale;
54-
55-
/* Support for IE. */
56-
font-feature-settings: 'liga';
57-
}
31+
font-family: 'Material Icons';
32+
font-weight: normal;
33+
font-style: normal;
34+
font-size: 24px; /* Preferred icon size */
35+
display: inline-block;
36+
line-height: 1;
37+
text-transform: none;
38+
letter-spacing: normal;
39+
word-wrap: normal;
40+
white-space: nowrap;
41+
direction: ltr;
42+
43+
/* Support for all WebKit browsers. */
44+
-webkit-font-smoothing: antialiased;
45+
/* Support for Safari and Chrome. */
46+
text-rendering: optimizeLegibility;
47+
48+
/* Support for Firefox. */
49+
-moz-osx-font-smoothing: grayscale;
50+
51+
/* Support for IE. */
52+
font-feature-settings: 'liga';
53+
}

frontend/src/routes/+layout.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script lang="ts">
2-
import "@fontsource/material-icons";
2+
// include fonts
3+
import '@fontsource/material-icons';
4+
// include app assets
35
import { assets } from '$app/paths';
46
import Header from '../lib/header/Header.svelte';
57
interface Props {

0 commit comments

Comments
 (0)