Update frontend/CLAUDE.md
This commit is contained in:
+37
-19
@@ -1,23 +1,41 @@
|
|||||||
# Code Style
|
# Setup
|
||||||
- You never use comments
|
- We always use Nuxt together with Tailwind. Install tailwind like that: https://tailwindcss.com/docs/installation/framework-guides/nuxt
|
||||||
- We use `npm i @stdlib/string-format` for formatting strings. Always. Install if not yet done.
|
|
||||||
- We always use NUXT's useFetch
|
# Components
|
||||||
- We always use feature first packaging. Every class that is part of a entity is in its own folder
|
- Ausnahmslos template -> script -> style von oben nach unten
|
||||||
- We always define types like this (image/Image.ts):
|
- Immer `<script setup lang="ts"></script> und <style scoped></style>`
|
||||||
```typescript
|
|
||||||
export interface Image {
|
# General Code Best Practices:
|
||||||
id: string;
|
- Keine ternären Operatoren, Immer switch oder if
|
||||||
name: string;
|
- Null-Checks so früh wie möglich. Vermeiden von ! oder ?
|
||||||
tags?: Tag[];
|
- Nutz shared/useHttp für Requests.
|
||||||
|
- Nutz `import format from "@stdlib/string-format";`
|
||||||
|
|
||||||
|
# Types und API Calls
|
||||||
|
- Types und Api Calls werden wie folgt unterteilt. Immer ein Type und ein API Objekt wie
|
||||||
|
```javascript
|
||||||
|
export interface Project {
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
```
|
|
||||||
- And a types API like this (image/ImageAPI.ts):
|
export class ProjectAPI {
|
||||||
```typescript
|
static get() {
|
||||||
export class ImageAPI {
|
return usePost<Project>("/api/projects");
|
||||||
static getAll() {
|
|
||||||
return useFetch<Image[]>('/api/images/', { server: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
- We put sections/components that are part of a pages into its own dedicated folder inside ./components
|
- Verwendung im Komponente:
|
||||||
- Always identify snippets of code that can be extracted
|
```javascript
|
||||||
|
<script setup lang="ts">
|
||||||
|
const {...} state = ProjectAPI.get();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
state.execute();
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
# Pages und Components
|
||||||
|
- Seiten beinhalten minimal Inhalt. Der Hauptteil des Inhalts ist in components.
|
||||||
|
Dort werden auch Types/Klassen/Interfaces/Requests angelegt.
|
||||||
|
Wir arbeiten feature-first, also packen alle inhaltlich zusammengehörigen Code in einen Bereich also components/projects oder components/images
|
||||||
Reference in New Issue
Block a user