Skip to content

Commit

Permalink
Merge pull request #10 from maykinmedia/construction
Browse files Browse the repository at this point in the history
Construction
  • Loading branch information
svenvandescheur authored May 13, 2024
2 parents 0d1b331 + 30e6757 commit 4a25939
Show file tree
Hide file tree
Showing 40 changed files with 28,823 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/src/openarchiefbeheer/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
#

INSTALLED_APPS = [
"corsheaders",
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.contenttypes",
Expand Down Expand Up @@ -132,6 +133,7 @@
]

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
# 'django.middleware.locale.LocaleMiddleware',
Expand Down
8 changes: 8 additions & 0 deletions frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
38 changes: 38 additions & 0 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"env": {
"browser": true,
"es2021": true
},
"ignorePatterns": [
"*.js",
"*.config.js",
"dist/**/*",
"**/*.css",
"**/*.scss",
"**/*.md"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:storybook/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"react"
],
"rules": {
"react/react-in-jsx-scope": "off"
},
"settings": {
"react": {
"version": "detect"
}
}
}
25 changes: 25 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

*storybook.log
2 changes: 2 additions & 0 deletions frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd frontend
npx lint-staged
6 changes: 6 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": ["^lib/(.*)$", "^components/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}
28 changes: 28 additions & 0 deletions frontend/.storybook/decorators.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { StoryContext, StoryFn } from "@storybook/react";
import * as React from "react";
import { RouterProvider, createBrowserRouter } from "react-router-dom";

import App from "../src/App";

/**
* Decorators providing React Router integration (RouterProvider), optionally: when using this decorator a parameter
* "loader" can be specified providing React Router `LoaderFunction` for this `StoryFn`.
*/
export const ReactRouterDecorator = (
Story: StoryFn,
{ parameters }: StoryContext,
) => {
const router = createBrowserRouter([
{
path: "*",
element: <Story />,
loader: parameters.loader,
},
]);

return (
<App>
<RouterProvider router={router} />
</App>
);
};
24 changes: 24 additions & 0 deletions frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { StorybookConfig } from "@storybook/react-webpack5";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/preset-create-react-app",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
core: {
disableTelemetry: true, // 👈 Disables telemetry
},
docs: {
autodocs: "tag",
},
staticDirs: ["../public"],
};
export default config;
16 changes: 16 additions & 0 deletions frontend/.storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<style>
html,
body,
.sb-show-main,
#storybook-root {
height: 100%;
}

body {
margin: 0;
}

.sb-show-main {
padding: 0!important;
}
</style>
14 changes: 14 additions & 0 deletions frontend/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
46 changes: 46 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

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.

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.

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.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
120 changes: 120 additions & 0 deletions frontend/bin/create_page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

PAGES_DIR="src/pages"
INDEX_FILE="$PAGES_DIR/index.ts"

page_name=$1
page_name_lowercase=$(echo "$page_name" | tr '[:upper:]' '[:lower:]')
capitalized_page_name=$(echo "$page_name" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}')
page_dir="$PAGES_DIR/$page_name_lowercase"

# Function to check if a directory exists
function directory_exists() {
[ -d $1 ]
}

# Function to create a directory if it doesn't exist
function create_directory() {
if ! directory_exists $1; then
mkdir -p $1
fi
}

# Function to create the index.ts file
function create_index_file() {
echo "export * from \"./$capitalized_page_name\";" > "$2/index.ts"
}

# Function to create the CSS file
function create_css_file() {
echo ".${capitalized_page_name}Page {" > "$2/$capitalized_page_name.css"
echo " /* Rules here. */" >> "$2/$capitalized_page_name.css"
echo "}" >> "$2/$capitalized_page_name.css"
}

# Function to create the stories.tsx file
function create_stories_file() {
cat > "$2/$capitalized_page_name.stories.tsx" <<EOF
import type { Meta, StoryObj } from "@storybook/react";
import { ${capitalized_page_name}Page } from "./$capitalized_page_name";
const meta: Meta<typeof ${capitalized_page_name}Page> = {
title: "Pages/${capitalized_page_name}",
component: ${capitalized_page_name}Page,
};
export default meta;
type Story = StoryObj<typeof meta>;
export const ${page_name_lowercase}Page: Story = {
args: {
children: "The quick brown fox jumps over the lazy dog.",
},
};
EOF
}

# Function to create the page file
function create_page_file() {
cat > "$2/$capitalized_page_name.tsx" <<EOF
import React from "react";
import "./$capitalized_page_name.css";
export type ${capitalized_page_name}Props = React.ComponentProps<"main"> & {
// Props here.
};
/**
* ${capitalized_page_name} page
*/
export function ${capitalized_page_name}Page({ children, ...props }: ${capitalized_page_name}Props) {
return (
<main className="${capitalized_page_name}Page" {...props}>
{children}
</main>
);
}
EOF
}

# Function to update the index.ts file in pages
function update_index_file() {
echo "// Auto-generated file. Do not modify manually." > "$INDEX_FILE"
for page_dir in "$PAGES_DIR"/*/; do
page_name=$(basename "$page_dir")
echo "export * from \"./$page_name\";" >> "$INDEX_FILE"
done
}

# Main script

# Check if $PAGES_DIR directory exists, if not create it
create_directory $PAGES_DIR

# Check if a page name is provided
if [ -z "$1" ]; then
echo "Error: Please provide a page name."
exit 1
fi

# Check if page already exists
if directory_exists $page_dir; then
echo "Error: page '$capitalized_page_name' already exists."
exit 1
fi

# Create page directory
create_directory $page_dir

# Create individual files
create_index_file $capitalized_page_name $page_dir
create_css_file $capitalized_page_name $page_dir
create_stories_file $capitalized_page_name $page_dir
create_page_file $capitalized_page_name $page_dir

# Update pages/index.ts file
update_index_file

echo "page '$capitalized_page_name' created successfully."
Loading

0 comments on commit 4a25939

Please sign in to comment.