Skip to content

Commit

Permalink
Updated packages
Browse files Browse the repository at this point in the history
Transferred from create_react_app to vite
  • Loading branch information
PasiVuohijoki committed Nov 14, 2023
1 parent d69273b commit 94dd762
Show file tree
Hide file tree
Showing 131 changed files with 5,415 additions and 11,936 deletions.
14 changes: 7 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SASS_PATH=node_modules:src
REACT_APP_API_URL=http://localhost:8000/v1
REACT_APP_OPENID_CONNECT_CLIENT_ID=https://api.hel.fi/auth/mvj
REACT_APP_OPENID_CONNECT_AUTHORITY_URL=http://tunnistamo-backend:8888/
REACT_APP_OPENID_CONNECT_API_TOKEN_URL=http://tunnistamo-backend:8888/api-tokens/
REACT_APP_OPENID_CONNECT_API_TOKEN_KEY=https://api.hel.fi/auth/mvj
REACT_APP_OPENID_CONNECT_SCOPE=openid profile mvj https://api.hel.fi/auth/mvj
SASS_PATH=/node_modules:/src
VITE_APP_API_URL=http://localhost:8000/v1
VITE_APP_OPENID_CONNECT_CLIENT_ID=https://api.hel.fi/auth/mvj
VITE_APP_OPENID_CONNECT_AUTHORITY_URL=http://tunnistamo-backend:8888/
VITE_APP_OPENID_CONNECT_API_TOKEN_URL=http://tunnistamo-backend:8888/api-tokens/
VITE_APP_OPENID_CONNECT_API_TOKEN_KEY=https://api.hel.fi/auth/mvj
VITE_APP_OPENID_CONNECT_SCOPE=openid profile mvj https://api.hel.fi/auth/mvj
21 changes: 17 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"env": {
"browser": true,
"es2021": true
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:react/jsx-runtime"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -16,6 +18,11 @@
"ecmaVersion": 12,
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
}
},
"plugins": [
"react",
"@typescript-eslint"
Expand All @@ -28,8 +35,14 @@
"error",
"unix"
],
"quotes": [
"off"
"@typescript-eslint/quotes": [
2, "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"jsx-quotes": [
2, "prefer-double"
],
"semi": [
"warn"
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ name: Node.js CI

on:
push:
branches: [ main, develop ]
branches: [main, develop]
pull_request:
branches: [ main, develop ]
branches: [main, develop]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn build
- run: yarn test:coverage
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn build
# - run: yarn test:coverage
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-slim AS appbase
FROM node:18-slim AS appbase

COPY tools /tools
COPY scripts /scripts
Expand Down Expand Up @@ -62,9 +62,6 @@ ENV NODE_ENV $NODE_ENV
# copy in our source code last, as it changes the most
COPY --chown=appuser:appuser . .

# Bake package.json start command into the image
CMD ["react-scripts", "start"]

# ===================================
FROM appbase as staticbuilder
# ===================================
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:18-alpine

WORKDIR /app

Expand All @@ -13,8 +13,8 @@ RUN mkdir node_modules/.cache && chmod -R 777 node_modules/.cache

COPY . .

RUN yarn prepare-renew-endpoint
# RUN yarn prepare-renew-endpoint

VOLUME [ "/app" ]

CMD ["yarn", "start-server"]
# CMD ["yarn", "dev"]
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

This is the public user interface that allows citizens and organizations in Helsinki to browse and attend into ongoing
plot search competitions. This is a part of MVJ ("Maanvuokrausjärjestelmä") which also contains UI for city
officials to handle ground rental related matters. This public UI and the closed-from-public UI for city
officials to handle ground rental related matters. This public UI and the closed-from-public UI for city
officials share the same MVJ-backend.

Based on [React Boilerplate](https://github.com/nordsoftware/react-boilerplate)
Originally based on [React Boilerplate](https://github.com/nordsoftware/react-boilerplate)
Later the now deprecated Create React App is replaced with [Vite](https://vitejs.dev/)

## Development Environment

Expand All @@ -17,29 +18,32 @@ To build up a development environment please follow these steps:
### Usage w/o docker

1. Check requirements:
1. Project runs on node 16
1. Project runs on node 18
2. Yarn needs to be installed
2. On project root `run yarn` to install packages
2. On project root run `yarn` to install packages
3. Run `yarn start` to run dev server

## Code style

Formatting wise, consistent code style is primarily enforced with [Prettier](https://prettier.io/)
automatically when files are committed to the repository. Some code style guidelines should be
followed manually by the developer as listed below.

### Functional vs class-based components

Prefer functional components, hooks, and other modern React concepts over the more traditional
class and HOC based approaches.

### Style definitions and class names

Prefer specifying the styles for components in Sass stylesheets. Inline CSS rules should
primarily be used when they need to be dynamic (for example, a background image based on the
current application state).

All class names we are in control of should follow the [Block-Element-Modifier](http://getbem.com/naming/)
naming system. In the context of a React application, each component represents one block,
so the outermost element rendered by that component should have a class named after the component
itself if there are any styles to attach to it or its children. Any inner elements rendered by that
naming system. In the context of a React application, each component represents one block,
so the outermost element rendered by that component should have a class named after the component
itself if there are any styles to attach to it or its children. Any inner elements rendered by that
same component will then follow the BEM style normally, all using the component name as the block base.
Use PascalCase for the block part of the name and kebab-case for the element and modifier parts.

Expand All @@ -50,24 +54,28 @@ type Props = {
disabled?: boolean;
wrapText?: boolean;
text?: string;
}

const CustomButton = ({ disabled = false, wrapText = false, text = '' } : Props): JSX.Element => {
return <button className={classNames(
"CustomButton", {
"CustomButton--disabled": disabled,
"CustomButton--wrap-text": wrapText
})
}>
<span className="CustomButton__label">
{text}
</span>
</button>;
};

const CustomButton = ({
disabled = false,
wrapText = false,
text = "",
}: Props): JSX.Element => {
return (
<button
className={classNames("CustomButton", {
"CustomButton--disabled": disabled,
"CustomButton--wrap-text": wrapText,
})}
>
<span className="CustomButton__label">{text}</span>
</button>
);
};
```

"Magic" class names that are first defined somewhere and then sprinkled over different
components when needed should not be used; if parts of different components need to be
"Magic" class names that are first defined somewhere and then sprinkled over different
components when needed should not be used; if parts of different components need to be
styled the same way, either make a new shared component that will provide that style or
use Sass mixins, whichever is more appropriate for that situation.

Expand Down
2 changes: 1 addition & 1 deletion i18next-parser.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
contextSeparator: '_',
createOldCatalogs: false,
defaultNamespace: 'common',
Expand Down
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title></title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
Loading

0 comments on commit 94dd762

Please sign in to comment.