Skip to content

Commit 4a25939

Browse files
Merge pull request #10 from maykinmedia/construction
Construction
2 parents 0d1b331 + 30e6757 commit 4a25939

40 files changed

+28823
-0
lines changed

backend/src/openarchiefbeheer/conf/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#
9191

9292
INSTALLED_APPS = [
93+
"corsheaders",
9394
"django.contrib.auth",
9495
"django.contrib.sessions",
9596
"django.contrib.contenttypes",
@@ -132,6 +133,7 @@
132133
]
133134

134135
MIDDLEWARE = [
136+
"corsheaders.middleware.CorsMiddleware",
135137
"django.middleware.security.SecurityMiddleware",
136138
"django.contrib.sessions.middleware.SessionMiddleware",
137139
# 'django.middleware.locale.LocaleMiddleware',

frontend/.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true

frontend/.eslintrc.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"ignorePatterns": [
7+
"*.js",
8+
"*.config.js",
9+
"dist/**/*",
10+
"**/*.css",
11+
"**/*.scss",
12+
"**/*.md"
13+
],
14+
"extends": [
15+
"eslint:recommended",
16+
"plugin:@typescript-eslint/recommended",
17+
"plugin:react/recommended",
18+
"plugin:prettier/recommended",
19+
"plugin:storybook/recommended"
20+
],
21+
"parser": "@typescript-eslint/parser",
22+
"parserOptions": {
23+
"ecmaVersion": "latest",
24+
"sourceType": "module"
25+
},
26+
"plugins": [
27+
"@typescript-eslint",
28+
"react"
29+
],
30+
"rules": {
31+
"react/react-in-jsx-scope": "off"
32+
},
33+
"settings": {
34+
"react": {
35+
"version": "detect"
36+
}
37+
}
38+
}

frontend/.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
*storybook.log

frontend/.husky/pre-commit

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd frontend
2+
npx lint-staged

frontend/.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
3+
"importOrder": ["^lib/(.*)$", "^components/(.*)$", "^[./]"],
4+
"importOrderSeparation": true,
5+
"importOrderSortSpecifiers": true
6+
}

frontend/.storybook/decorators.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { StoryContext, StoryFn } from "@storybook/react";
2+
import * as React from "react";
3+
import { RouterProvider, createBrowserRouter } from "react-router-dom";
4+
5+
import App from "../src/App";
6+
7+
/**
8+
* Decorators providing React Router integration (RouterProvider), optionally: when using this decorator a parameter
9+
* "loader" can be specified providing React Router `LoaderFunction` for this `StoryFn`.
10+
*/
11+
export const ReactRouterDecorator = (
12+
Story: StoryFn,
13+
{ parameters }: StoryContext,
14+
) => {
15+
const router = createBrowserRouter([
16+
{
17+
path: "*",
18+
element: <Story />,
19+
loader: parameters.loader,
20+
},
21+
]);
22+
23+
return (
24+
<App>
25+
<RouterProvider router={router} />
26+
</App>
27+
);
28+
};

frontend/.storybook/main.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { StorybookConfig } from "@storybook/react-webpack5";
2+
3+
const config: StorybookConfig = {
4+
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
5+
addons: [
6+
"@storybook/preset-create-react-app",
7+
"@storybook/addon-links",
8+
"@storybook/addon-essentials",
9+
"@chromatic-com/storybook",
10+
"@storybook/addon-interactions",
11+
],
12+
framework: {
13+
name: "@storybook/react-webpack5",
14+
options: {},
15+
},
16+
core: {
17+
disableTelemetry: true, // 👈 Disables telemetry
18+
},
19+
docs: {
20+
autodocs: "tag",
21+
},
22+
staticDirs: ["../public"],
23+
};
24+
export default config;

frontend/.storybook/preview-body.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<style>
2+
html,
3+
body,
4+
.sb-show-main,
5+
#storybook-root {
6+
height: 100%;
7+
}
8+
9+
body {
10+
margin: 0;
11+
}
12+
13+
.sb-show-main {
14+
padding: 0!important;
15+
}
16+
</style>

frontend/.storybook/preview.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
const preview: Preview = {
4+
parameters: {
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/i,
9+
},
10+
},
11+
},
12+
};
13+
14+
export default preview;

frontend/README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `npm start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.\
15+
You will also see any lint errors in the console.
16+
17+
### `npm test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `npm run build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `npm run eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39+
40+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).

frontend/bin/create_page.sh

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
PAGES_DIR="src/pages"
4+
INDEX_FILE="$PAGES_DIR/index.ts"
5+
6+
page_name=$1
7+
page_name_lowercase=$(echo "$page_name" | tr '[:upper:]' '[:lower:]')
8+
capitalized_page_name=$(echo "$page_name" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}')
9+
page_dir="$PAGES_DIR/$page_name_lowercase"
10+
11+
# Function to check if a directory exists
12+
function directory_exists() {
13+
[ -d $1 ]
14+
}
15+
16+
# Function to create a directory if it doesn't exist
17+
function create_directory() {
18+
if ! directory_exists $1; then
19+
mkdir -p $1
20+
fi
21+
}
22+
23+
# Function to create the index.ts file
24+
function create_index_file() {
25+
echo "export * from \"./$capitalized_page_name\";" > "$2/index.ts"
26+
}
27+
28+
# Function to create the CSS file
29+
function create_css_file() {
30+
echo ".${capitalized_page_name}Page {" > "$2/$capitalized_page_name.css"
31+
echo " /* Rules here. */" >> "$2/$capitalized_page_name.css"
32+
echo "}" >> "$2/$capitalized_page_name.css"
33+
}
34+
35+
# Function to create the stories.tsx file
36+
function create_stories_file() {
37+
cat > "$2/$capitalized_page_name.stories.tsx" <<EOF
38+
import type { Meta, StoryObj } from "@storybook/react";
39+
40+
import { ${capitalized_page_name}Page } from "./$capitalized_page_name";
41+
42+
const meta: Meta<typeof ${capitalized_page_name}Page> = {
43+
title: "Pages/${capitalized_page_name}",
44+
component: ${capitalized_page_name}Page,
45+
};
46+
47+
export default meta;
48+
type Story = StoryObj<typeof meta>;
49+
50+
export const ${page_name_lowercase}Page: Story = {
51+
args: {
52+
children: "The quick brown fox jumps over the lazy dog.",
53+
},
54+
};
55+
EOF
56+
}
57+
58+
# Function to create the page file
59+
function create_page_file() {
60+
cat > "$2/$capitalized_page_name.tsx" <<EOF
61+
import React from "react";
62+
63+
import "./$capitalized_page_name.css";
64+
65+
export type ${capitalized_page_name}Props = React.ComponentProps<"main"> & {
66+
// Props here.
67+
};
68+
69+
/**
70+
* ${capitalized_page_name} page
71+
*/
72+
export function ${capitalized_page_name}Page({ children, ...props }: ${capitalized_page_name}Props) {
73+
return (
74+
<main className="${capitalized_page_name}Page" {...props}>
75+
{children}
76+
</main>
77+
);
78+
}
79+
EOF
80+
}
81+
82+
# Function to update the index.ts file in pages
83+
function update_index_file() {
84+
echo "// Auto-generated file. Do not modify manually." > "$INDEX_FILE"
85+
for page_dir in "$PAGES_DIR"/*/; do
86+
page_name=$(basename "$page_dir")
87+
echo "export * from \"./$page_name\";" >> "$INDEX_FILE"
88+
done
89+
}
90+
91+
# Main script
92+
93+
# Check if $PAGES_DIR directory exists, if not create it
94+
create_directory $PAGES_DIR
95+
96+
# Check if a page name is provided
97+
if [ -z "$1" ]; then
98+
echo "Error: Please provide a page name."
99+
exit 1
100+
fi
101+
102+
# Check if page already exists
103+
if directory_exists $page_dir; then
104+
echo "Error: page '$capitalized_page_name' already exists."
105+
exit 1
106+
fi
107+
108+
# Create page directory
109+
create_directory $page_dir
110+
111+
# Create individual files
112+
create_index_file $capitalized_page_name $page_dir
113+
create_css_file $capitalized_page_name $page_dir
114+
create_stories_file $capitalized_page_name $page_dir
115+
create_page_file $capitalized_page_name $page_dir
116+
117+
# Update pages/index.ts file
118+
update_index_file
119+
120+
echo "page '$capitalized_page_name' created successfully."

0 commit comments

Comments
 (0)