Skip to content

Commit

Permalink
Merge pull request #39 from lil5/master
Browse files Browse the repository at this point in the history
Move to bun, vite, prettier & Add template upload/download
  • Loading branch information
tuanpham-dev authored Apr 9, 2024
2 parents f2616be + b2013e1 commit 63172bd
Show file tree
Hide file tree
Showing 38 changed files with 1,754 additions and 12,411 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Github Pages
on:
push:
branches: ['master']
workflow_dispatch:

permissions:
pages: write
id-token: write

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: yarn
- run: yarn build --base=/react-invoice-generator/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
name: 'github-pages'
path: 'dist'

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
with:
path: dist
41 changes: 21 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# 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

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"semi": false,
"printWidth": 100
}
25 changes: 4 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test`
### `yarn lint` (`lint:write`)

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
Launches Prettier, an opinionated code formatter.

https://prettier.io/

### `yarn build`

Expand All @@ -28,21 +29,3 @@ It correctly bundles React in production mode and optimizes the build for the be

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

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

### `yarn 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/).
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/public/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Invoice Generator</title>
<link rel="preconnect" href="https://fonts.bunny.net" />
<link href="https://fonts.bunny.net/css?family=nunito:400,600" rel="stylesheet" />
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="/public/manifest.json" />

<link rel="apple-touch-icon" href="/public/logo192.png" />
<meta
name="description"
content="React Invoice Generator allows you quickly make invoices and save them as PDF"
/>
</head>
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
73 changes: 30 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,41 @@
"name": "invoice-generator",
"version": "0.2.1",
"private": true,
"type": "module",
"homepage": "https://tuanpham-dev.github.io/react-invoice-generator/",
"dependencies": {
"@react-pdf/renderer": "^2.0.18",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"date-fns": "^2.16.1",
"rc-slider": "9.2.4",
"react": "^16.13.1",
"react-datepicker": "^3.3.0",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"react-textarea-autosize": "^8.2.0",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
"dev": "vite",
"build": "tsc && vite build",
"lint": "prettier -c .",
"lint:write": "prettier -w .",
"preview": "vite preview"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dependencies": {
"@react-pdf/renderer": "^3.4.2",
"@uidotdev/usehooks": "^2.4.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"date-fns": "^3.6.0",
"file-saver": "^2.0.5",
"gh-pages": "^6.1.1",
"rc-slider": "10.5.0",
"react": "^18.2.0",
"react-datepicker": "^6.6.0",
"react-dom": "^18.2.0",
"react-textarea-autosize": "^8.5.3",
"sass": "^1.72.0",
"typescript": "^5.4.3",
"vite": "^5.2.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/date-fns": "^2.6.0",
"@types/rc-slider": "^8.6.5",
"@types/react-datepicker": "^3.1.1",
"@types/react-textarea-autosize": "^4.3.5",
"gh-pages": "^3.1.0",
"node-sass": "^4.14.1"
"@types/file-saver": "^2.0.7",
"@types/node": "^20.11.30",
"@types/rc-slider": "^9.3.0",
"@types/react": "^18.2.73",
"@types/react-datepicker": "^6.2.0",
"@types/react-dom": "^18.2.23",
"@types/react-textarea-autosize": "^8.0.0",
"prettier": "^3.2.5"
}
}
44 changes: 0 additions & 44 deletions public/index.html

This file was deleted.

3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import InvoicePage from './components/InvoicePage'
import { Invoice } from './data/types'

Expand All @@ -10,7 +9,7 @@ function App() {
if (savedInvoice) {
data = JSON.parse(savedInvoice)
}
} catch (_e) { }
} catch (_e) {}

const onInvoiceUpdated = (invoice: Invoice) => {
window.localStorage.setItem('invoiceData', JSON.stringify(invoice))
Expand Down
1 change: 1 addition & 0 deletions src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Document.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FC } from 'react'
import { FC, PropsWithChildren } from 'react'
import { Document as PdfDocument } from '@react-pdf/renderer'

interface Props {
pdfMode?: boolean
}

const Document: FC<Props> = ({ pdfMode, children }) => {
const Document: FC<PropsWithChildren<Props>> = ({ pdfMode, children }) => {
return <>{pdfMode ? <PdfDocument>{children}</PdfDocument> : <>{children}</>}</>
}

Expand Down
Loading

1 comment on commit 63172bd

@lil5
Copy link
Contributor

@lil5 lil5 commented on 63172bd May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this to work you need:

  1. Settings Pages Build and deployment Source = GitHub Actions
  2. Settings Actions General Workflow permissions = Read and write permissions

Please sign in to comment.