Skip to content

Commit 5d6da32

Browse files
Merge pull request #2 from dataforgoodfr/juho/frontend-setup
init repo with internationalisation, frontend tools and libraries.
2 parents a3b2e1d + 45a2dda commit 5d6da32

Some content is hidden

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

52 files changed

+11968
-1
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
NOCODB_API_TOKEN=

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ downloads/
1717
eggs/
1818
.eggs/
1919
lib/
20+
!webapp/lib/
2021
lib64/
2122
lib64
2223
parts/
@@ -124,6 +125,7 @@ celerybeat.pid
124125

125126
# Environments
126127
.env
128+
.env.local
127129
.env.test
128130
.venv
129131
env/

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ repos:
1111
- id: check-merge-conflict
1212
- id: check-illegal-windows-names
1313
- id: mixed-line-ending
14+
- repo: local #run custom scripts from own repo
15+
hooks:
16+
- id: lint-staged-webapp
17+
name: Run lint-staged on webapp staged files
18+
entry: bash run-lint-staged-if-webapp.sh
19+
language: system
20+
pass_filenames: false # This hook handles filenames internally

run-lint-staged-if-webapp.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
STAGED_FILES=$(git diff --cached --name-only)
4+
5+
if echo "$STAGED_FILES" | grep -q '^webapp/'; then
6+
echo "Changes in webapp/ detected, running lint-staged..."
7+
cd webapp && npx lint-staged
8+
exit_code=$?
9+
exit $exit_code
10+
else
11+
echo "No changes in webapp/ -- skipping lint-staged."
12+
fi

webapp/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NOCODB_BASE_ID=xxx # Find your Base ID in NocoDB base menu.
2+
NOCODB_URL="https://noco.services.dataforgood.fr/api/v3" # With localhost: http://localhost:8500/api/v3
3+
NOCODB_TOKEN=xxx # Find your API token in NocoDB 'Team & settings' > 'API Tokens'.

webapp/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# vercel
34+
.vercel
35+
36+
# typescript
37+
*.tsbuildinfo
38+
next-env.d.ts

webapp/.lintstagedrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"*/**/*.{js,jsx,ts,tsx}": ["eslint"],
3+
"*/**/*.{json,css,md}": ["prettier --write"]
4+
}

webapp/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.11.1

webapp/.prettierrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"bracketSameLine": false,
7+
"jsxSingleQuote": true,
8+
"printWidth": 120,
9+
"proseWrap": "preserve",
10+
"quoteProps": "as-needed",
11+
"requirePragma": false,
12+
"semi": false,
13+
"singleQuote": true,
14+
"tabWidth": 2,
15+
"trailingComma": "none",
16+
"useTabs": true,
17+
"plugins": ["prettier-plugin-tailwindcss"]
18+
}

webapp/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
Run `npm install`
6+
7+
Set the environment variables in your .env.local file like defined in .env.example.
8+
9+
First, run the development server:
10+
11+
```bash
12+
npm run dev
13+
```
14+
15+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16+
17+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
18+
19+
## Learn More
20+
21+
To learn more about Next.js, take a look at the following resources:
22+
23+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
24+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
25+
26+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
27+
28+
## Components and UI libraries
29+
30+
We use [Shadcn](https://ui.shadcn.com/) for components, in combination with [TailwindCSS](https://tailwindcss.com/) to style a component inline.
31+
To add a shadcn component:
32+
```bash
33+
npx shadcn@latest add navigation-menu
34+
```
35+
For icons, we use the default library in Shadcn, [Lucide](https://www.shadcn.io/icons/lucide).
36+
37+
## Internationalisation i18n
38+
39+
For the internationalisation of the app we are using [next-i18next](https://github.com/i18next/next-i18next). Our setup is based on this article from [Locize](https://www.locize.com/blog/i18n-next-app-router/).
40+
41+
## BlogPosts / news markdown
42+
43+
We use the library [react-markdown](https://remarkjs.github.io/react-markdown/) to display blog posts / news. Visit [CommonMark](https://commonmark.org) for Markdown guidelines and tutorial. You can style the components by passing the components props to ReactMarkdown.
44+
45+
```bash
46+
<ReactMarkdown components={components}>{Content}</ReactMarkdown>
47+
```
48+
49+
## Linting and Code Formatting
50+
51+
This repo uses `ESLint` [according to the official next documentation](https://nextjs.org/docs/app/api-reference/config/eslint) and prettier for linting and code formatting. The configuration for `ESLint` is located in the `.eslint.config.mjs` file, and the configuration for `prettier` is in the `.prettierrc.json` file.
52+
53+
With the [ESLint Prettier plugin](https://www.npmjs.com/package/eslint-plugin-prettier/v/4.0.0) Prettier runs within ESLint and doesn't need a separate command. In order to apply `ESLint` to all existing files, run:
54+
55+
```
56+
npx eslint .
57+
```
58+
59+
and to fix fixable errors:
60+
```
61+
npx eslint . --fix
62+
```
63+
64+
Before each commit, our `husky🐶` uses the `lint-staged` package to automatically lint and format the staged files according to the rules specified in the `.lintstagedrc` file:
65+
66+
You can do this manually by running:
67+
68+
```
69+
npx lint-staged
70+
```
71+
72+
This ensures code quality and consistency across our codebase.

0 commit comments

Comments
 (0)