mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-17 17:28:07 +00:00
feat(scaffold): remove unused scaffolds, fix zplug
This commit is contained in:
@@ -2,66 +2,81 @@
|
||||
|
||||
SCAFFOLDS_DIR="$DOTFILES/scaffolds"
|
||||
|
||||
tpl() {
|
||||
function tpl() {
|
||||
tpl_name="$1"
|
||||
shift
|
||||
|
||||
case $tpl_name in
|
||||
nextjs | cra)
|
||||
app_name="$1"
|
||||
shift
|
||||
tpl_data=""
|
||||
mkdir -p $app_name
|
||||
cd $app_name
|
||||
echo "Creating '$tpl_name' app in directory: '$(pwd)'"
|
||||
case $tpl_name in
|
||||
nextjs)
|
||||
tpl_data='{"nextComponents":true}'
|
||||
src_dir="./"
|
||||
yarn create next-app --typescript .
|
||||
ef | editorfiles)
|
||||
tpl_name="editorfiles"
|
||||
npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/editorfiles" -o . - $@
|
||||
;;
|
||||
cra)
|
||||
tpl_data='{"nextComponents":false}'
|
||||
src_dir="./src"
|
||||
yarn create react-app --template typescript .
|
||||
yes | rm -rf ./src/
|
||||
*)
|
||||
echo_red "Usage: tpl [editorfiles]"
|
||||
;;
|
||||
esac
|
||||
npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/$tpl_name" -w 1 -o . -d $tpl_data $app_name
|
||||
npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/react-app-common" -w 1 -o $src_dir -d $tpl_data $app_name
|
||||
echo_gray "Merging package.json..."
|
||||
jq 'reduce inputs as $s (.; .*$s)' ./package.json $SCAFFOLDS_DIR/_merge/$tpl_name/package.json >./package.json.tmp
|
||||
mv -f ./package.json.tmp ./package.json && rm -f ./package.json.tmp
|
||||
echo_gray "Copying sub scaffolds..."
|
||||
mkdir -p ./scaffolds
|
||||
cp -R $SCAFFOLDS_DIR/_subs/$tpl_name/ ./scaffolds/
|
||||
tpl editorfiles
|
||||
echo_gray "Installing additional dependencies..."
|
||||
yarn install
|
||||
echo_gray "Prettifying files..."
|
||||
prettier -w "**/*.{js,jsx,ts,tsx,json,html}"
|
||||
echo_gray "Done"
|
||||
;;
|
||||
ef | editorfiles)
|
||||
tpl_name="editorfiles"
|
||||
npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/editorfiles" -o . - $@
|
||||
;;
|
||||
fl | flutter | flutter-app)
|
||||
tpl_name="flutter-app"
|
||||
echo_cyan "Creating app '$@'..."
|
||||
flutter create $@
|
||||
cd $1
|
||||
echo_cyan "Installing packages..."
|
||||
flutter pub add firebase_core cloud_firestore firebase_crashlytics firebase_remote_config firebase_auth provider shared_preferences google_sign_in sign_in_with_apple dynamic_themes cached_network_image wakelock intl intl_generator
|
||||
echo_cyan "Copying files..."
|
||||
npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/$tpl_name" -o ./ $@
|
||||
cp -R $SCAFFOLDS_DIR/_subs/$tpl_name/ ./
|
||||
echo_cyan "Updating pubspec.yaml..."
|
||||
echo "$(cat $SCAFFOLDS_DIR/_merge/$tpl_name/pubspec.yaml)" >>./pubspec.yaml
|
||||
echo_cyan "Done"
|
||||
;;
|
||||
*)
|
||||
echo_red "Usage: tpl [nextjs|cra|editorfiles|flutter-app]"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
# tpl_name="$1"
|
||||
# shift
|
||||
#
|
||||
# case $tpl_name in
|
||||
# nextjs | cra)
|
||||
# app_name="$1"
|
||||
# shift
|
||||
# tpl_data=""
|
||||
# mkdir -p $app_name
|
||||
# cd $app_name
|
||||
# echo "Creating '$tpl_name' app in directory: '$(pwd)'"
|
||||
# case $tpl_name in
|
||||
# nextjs)
|
||||
# tpl_data='{"nextComponents":true}'
|
||||
# src_dir="./"
|
||||
# yarn create next-app --typescript .
|
||||
# ;;
|
||||
# cra)
|
||||
# tpl_data='{"nextComponents":false}'
|
||||
# src_dir="./src"
|
||||
# yarn create react-app --template typescript .
|
||||
# yes | rm -rf ./src/
|
||||
# ;;
|
||||
# esac
|
||||
# npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/$tpl_name" -w 1 -o . -d $tpl_data $app_name
|
||||
# npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/react-app-common" -w 1 -o $src_dir -d $tpl_data $app_name
|
||||
# echo_gray "Merging package.json..."
|
||||
# jq 'reduce inputs as $s (.; .*$s)' ./package.json $SCAFFOLDS_DIR/_merge/$tpl_name/package.json >./package.json.tmp
|
||||
# mv -f ./package.json.tmp ./package.json && rm -f ./package.json.tmp
|
||||
# echo_gray "Copying sub scaffolds..."
|
||||
# mkdir -p ./scaffolds
|
||||
# cp -R $SCAFFOLDS_DIR/_subs/$tpl_name/ ./scaffolds/
|
||||
# tpl editorfiles
|
||||
# echo_gray "Installing additional dependencies..."
|
||||
# yarn install
|
||||
# echo_gray "Prettifying files..."
|
||||
# prettier -w "**/*.{js,jsx,ts,tsx,json,html}"
|
||||
# echo_gray "Done"
|
||||
# ;;
|
||||
# ef | editorfiles)
|
||||
# tpl_name="editorfiles"
|
||||
# npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/editorfiles" -o . - $@
|
||||
# ;;
|
||||
# fl | flutter | flutter-app)
|
||||
# tpl_name="flutter-app"
|
||||
# echo_cyan "Creating app '$@'..."
|
||||
# flutter create $@
|
||||
# cd $1
|
||||
# echo_cyan "Installing packages..."
|
||||
# flutter pub add firebase_core cloud_firestore firebase_crashlytics firebase_remote_config firebase_auth provider shared_preferences google_sign_in sign_in_with_apple dynamic_themes cached_network_image wakelock intl intl_generator
|
||||
# echo_cyan "Copying files..."
|
||||
# npx -y simple-scaffold@latest -t "$SCAFFOLDS_DIR/$tpl_name" -o ./ $@
|
||||
# cp -R $SCAFFOLDS_DIR/_subs/$tpl_name/ ./
|
||||
# echo_cyan "Updating pubspec.yaml..."
|
||||
# echo "$(cat $SCAFFOLDS_DIR/_merge/$tpl_name/pubspec.yaml)" >>./pubspec.yaml
|
||||
# echo_cyan "Done"
|
||||
# ;;
|
||||
# *)
|
||||
# echo_red "Usage: tpl [nextjs|cra|editorfiles|flutter-app]"
|
||||
# ;;
|
||||
# esac
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"gen:page": "npx -y simple-scaffold@latest -t scaffolds/page -s false -o pages ",
|
||||
"gen:component": "npx -y simple-scaffold@latest -t scaffolds/component -s false -o components/atoms"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/cache": "^11.9.3",
|
||||
"@emotion/react": "^11.9.3",
|
||||
"@emotion/server": "^11.4.0",
|
||||
"@emotion/styled": "^11.9.3",
|
||||
"@mui/icons-material": "^5.8.4",
|
||||
"@mui/material": "^5.9.2",
|
||||
"axios": "^0.27.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mobx-react-lite": "^3.4.0",
|
||||
"mobx": "^6.6.1",
|
||||
"node-fetch": "^3.2.10",
|
||||
"react-hook-form": "^7.34.0",
|
||||
"react-i18next": "^11.3.0",
|
||||
"react-query": "^3.39.2",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-router": "^6.3.0",
|
||||
"react-use": "^17.4.0",
|
||||
"stylis-plugin-rtl": "^2.1.1",
|
||||
"stylis": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/stylis": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
||||
"@typescript-eslint/parser": "^5.34.0",
|
||||
"css-loader": "^6.7.1",
|
||||
"csv-parse": "^5.3.0",
|
||||
"eslint-config-next": "12.2.3",
|
||||
"eslint": "8.20.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"ts-node": "^10.9.1"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
script_runner:
|
||||
scripts:
|
||||
- build:apk: flutter build apk
|
||||
- name: get-version
|
||||
cmd: dart scripts/get_version.dart
|
||||
suppress_header_output: true
|
||||
- name: get-name
|
||||
cmd: dart scripts/get_name.dart
|
||||
suppress_header_output: true
|
||||
- push: 'version=$(get-version); name=$(get-name); echo "Pushing ${name}-$version.apk"; adb push build/app/outputs/flutter-apk/app-release.apk /sdcard/Download/${name}-${version}.apk'
|
||||
- install: adb install -r build/app/outputs/flutter-apk/app-release.apk
|
||||
- to-device: build:apk && push && install
|
||||
- auto-fix: dart fix --apply
|
||||
- format: flutter format -l 100 --fix lib/ test/
|
||||
|
||||
- gen:page: npx simple-scaffold@latest -t templates/page -o lib/modules -s true
|
||||
- gen:model: npx simple-scaffold@latest -t templates/model -o lib/models -s false
|
||||
- gen:widget: npx simple-scaffold@latest -t templates/widget -o lib/widgets -s false
|
||||
- gen:icons: flutter pub run icons_launcher:create
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"gen:page": "npx -y simple-scaffold@latest -t scaffolds/page -s false -o pages ",
|
||||
"gen:component": "npx -y simple-scaffold@latest -t scaffolds/component -s false -o components/atoms",
|
||||
"build:docker": "docker build -t nextjs-docker .",
|
||||
"start:docker": "docker run -p 3100:3000 nextjs-docker"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/cache": "^11.9.3",
|
||||
"@emotion/react": "^11.9.3",
|
||||
"@emotion/server": "^11.4.0",
|
||||
"@emotion/styled": "^11.9.3",
|
||||
"@mui/icons-material": "^5.8.4",
|
||||
"@mui/material": "^5.9.2",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/stylis": "^4.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
||||
"@typescript-eslint/parser": "^5.34.0",
|
||||
"axios": "^0.27.2",
|
||||
"css-loader": "^6.7.1",
|
||||
"csv-parse": "^5.3.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mobx-react-lite": "^3.4.0",
|
||||
"mobx": "^6.6.1",
|
||||
"next-i18next": "^11.3.0",
|
||||
"next-transpile-modules": "^9.0.0",
|
||||
"node-fetch": "^3.2.10",
|
||||
"react-hook-form": "^7.34.0",
|
||||
"react-query": "^3.39.2",
|
||||
"react-use": "^17.4.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"stylis-plugin-rtl": "^2.1.1",
|
||||
"stylis": "^4.1.1",
|
||||
"ts-node": "^10.9.1"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { sxc } from 'core/utils/object_utils'
|
||||
import { CustomComponent } from 'core/types'
|
||||
|
||||
export interface {{pascalCase name}}Props extends CustomComponent<BoxProps> {
|
||||
//
|
||||
}
|
||||
|
||||
export const {{pascalCase name}}: React.FC<{{pascalCase name}}Props> = ({ sx, children }) => {
|
||||
return <Box sx={sxc({}, sx)}>{children}</Box>
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import React from 'react'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Box from '@mui/material/Box'
|
||||
import { PageWrapper } from 'components/atoms/PageWrapper'
|
||||
|
||||
// NOTE
|
||||
// This page mights need to be SSRed using `getStaticProps`. If that's the case,
|
||||
// we will need to use `getStaticPaths` to generate the routes.
|
||||
|
||||
export const {{pascalCase name}}: React.FC = () => {
|
||||
const router = useHistory()
|
||||
const params = router.query
|
||||
const { t } = useTranslation('{{snakeCase name}}')
|
||||
|
||||
return (
|
||||
<PageWrapper pageTitle="{{ startCase name }}">
|
||||
<Box>
|
||||
{{ pascalCase name }} Page
|
||||
</Box>
|
||||
</PageWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
export default {{pascalCase name}}
|
||||
@@ -1,9 +0,0 @@
|
||||
class {{pascalCase name}} {
|
||||
{{pascalCase name}}();
|
||||
|
||||
factory {{pascalCase name}}.fromJson(Map<String,dynamic> json) => throw UnimplementedError();
|
||||
|
||||
Map<String,dynamic> toJson() => throw UnimplementedError();
|
||||
|
||||
{{pascalCase name}} copyWith() => throw UnimplementedError();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class {{pascalCase name}}Page extends StatelessWidget {
|
||||
const {{pascalCase name}}Page({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class {{pascalCase name}} extends StatelessWidget {
|
||||
const {{pascalCase name}}({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { sxc } from 'core/utils/object_utils'
|
||||
import { CustomComponent } from 'core/types'
|
||||
|
||||
export interface {{pascalCase name}}Props extends CustomComponent<BoxProps> {
|
||||
//
|
||||
}
|
||||
|
||||
export const {{pascalCase name}}: React.FC<{{pascalCase name}}Props> = ({ sx, children }) => {
|
||||
return <Box sx={sxc({}, sx)}>{children}</Box>
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import React from 'react'
|
||||
import { NextPage, NextPageContext } from 'next'
|
||||
import { useRouter } from 'next/router'
|
||||
import { getI18nProps } from 'core/i18n'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import Box from '@mui/material/Box'
|
||||
import { PageWrapper } from 'components/atoms/PageWrapper'
|
||||
|
||||
// NOTE
|
||||
// This page mights need to be SSRed using `getStaticProps`. If that's the case,
|
||||
// we will need to use `getStaticPaths` to generate the routes.
|
||||
|
||||
export const {{pascalCase name}}: NextPage = () => {
|
||||
const router = useRouter()
|
||||
const params = router.query
|
||||
const { t } = useTranslation('{{snakeCase name}}')
|
||||
|
||||
return (
|
||||
<PageWrapper pageTitle="{{ startCase name }}" htmlTitle="{{ pascalCase name }}" htmlDescription="{{ pascalCase name }} App">
|
||||
<Box>
|
||||
{{ pascalCase name }} Page
|
||||
</Box>
|
||||
</PageWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getServerSideProps({ locale }: NextPageContext) {
|
||||
return {
|
||||
props: await getI18nProps(locale, ['{{snakeCase name}}']),
|
||||
}
|
||||
}
|
||||
|
||||
export default {{pascalCase name}}
|
||||
@@ -1,46 +0,0 @@
|
||||
# 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:
|
||||
|
||||
### `yarn 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.
|
||||
|
||||
### `yarn 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.
|
||||
|
||||
### `yarn 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.
|
||||
|
||||
### `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/).
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB |
@@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/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="%PUBLIC_URL%/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>React App</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`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB |
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -1,9 +0,0 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
@@ -1,55 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box from '@mui/material/Box'
|
||||
import Image from '{{#if nextComponents}}next/image{{else}}components/atoms/Image{{/if}}'
|
||||
import Typography from '@mui/material/Typography'
|
||||
import Link from '@mui/material/Link'
|
||||
import logo from './logo.svg'
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Box sx={ { textAlign: 'center' } }>
|
||||
<Box
|
||||
component="header"
|
||||
sx={ {
|
||||
backgroundColor: "#282c34",
|
||||
minHeight: "100vh",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
fontSize: "calc(10px + 2vmin)",
|
||||
color: "white",
|
||||
} }>
|
||||
<Image
|
||||
src={logo}
|
||||
alt="logo"
|
||||
sx={ {
|
||||
height: "40vmin",
|
||||
pointerEvents: "none",
|
||||
animation: "App-logo-spin infinite 20s linear",
|
||||
"@keyframes App-logo-spin": {
|
||||
from: {
|
||||
transform: "rotate(0deg)",
|
||||
},
|
||||
to: {
|
||||
transform: "rotate(360deg)",
|
||||
}
|
||||
}
|
||||
} } />
|
||||
<Typography>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</Typography>
|
||||
<Link
|
||||
sx={ { color: "#61dafb" } }
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</Link>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,9 +0,0 @@
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { CustomComponent, HTMLComponent } from 'core/types'
|
||||
|
||||
export type ImageProps = CustomComponent<BoxProps> & HTMLComponent<HTMLImageElement>
|
||||
export const Image: React.FC<ImageProps> = (props) => {
|
||||
return <Box component="img" {...props} />
|
||||
}
|
||||
|
||||
export default Image
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom'
|
||||
import React from 'react'
|
||||
|
||||
export const LinkBehavior = React.forwardRef<
|
||||
HTMLAnchorElement,
|
||||
Omit<RouterLinkProps, 'to'> & {
|
||||
href: RouterLinkProps['to']
|
||||
}
|
||||
>((props, ref) => {
|
||||
const { href, ...rest } = props
|
||||
return <RouterLink ref={ref} to={href!} {...rest} />
|
||||
})
|
||||
|
||||
export default LinkBehavior
|
||||
@@ -1,64 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import CssBaseline from '@mui/material/CssBaseline'
|
||||
import ThemeProvider from '@mui/material/styles/ThemeProvider'
|
||||
import { lightTheme, themeDir } from 'theme'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { QueryClientProvider, QueryClient } from 'react-query'
|
||||
import { useSilentLoginFlow } from 'stores/user_store'
|
||||
import reportWebVitals from './reportWebVitals'
|
||||
import App from './App'
|
||||
|
||||
let windowInit = false
|
||||
|
||||
const _{{ pascalCase name }}App: React.FC = () => {
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: Infinity,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const { i18n } = useTranslation()
|
||||
const themeWithDirection = React.useMemo(
|
||||
() => themeDir(lightTheme, i18n.dir(i18n.language)),
|
||||
[i18n],
|
||||
)
|
||||
const silentLogin = useSilentLoginFlow()
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!windowInit && typeof window !== 'undefined') {
|
||||
windowInit = true
|
||||
silentLogin()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [typeof window])
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider theme={themeWithDirection}>
|
||||
<CssBaseline />
|
||||
<App />
|
||||
</ThemeProvider>
|
||||
</QueryClientProvider>
|
||||
)
|
||||
}
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
)
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<_{{ pascalCase name }}App />
|
||||
</React.StrictMode>
|
||||
)
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
@@ -1,39 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": "./src/",
|
||||
},
|
||||
"ts-node": {
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"mui.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"templates/**/*"
|
||||
]
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
templates/
|
||||
scaffolds/
|
||||
gen/
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
templates/
|
||||
scaffolds/
|
||||
gen/
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
void main() {
|
||||
// get version from pubspec.yaml
|
||||
final pubspecFile = File('pubspec.yaml');
|
||||
final version = pubspecFile
|
||||
.readAsStringSync()
|
||||
.split('\n')
|
||||
.firstWhere((x) => x.startsWith('name:'))
|
||||
.split(':')
|
||||
.last
|
||||
.trim();
|
||||
// ignore: avoid_print
|
||||
print(version);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
void main() {
|
||||
// get version from pubspec.yaml
|
||||
final pubspecFile = File('pubspec.yaml');
|
||||
final version = pubspecFile
|
||||
.readAsStringSync()
|
||||
.split('\n')
|
||||
.firstWhere((x) => x.startsWith('version:'))
|
||||
.split(':')
|
||||
.last
|
||||
.trim();
|
||||
// ignore: avoid_print
|
||||
print(version);
|
||||
}
|
||||
16
scaffolds/nextjs/.vscode/settings.json
vendored
16
scaffolds/nextjs/.vscode/settings.json
vendored
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"{{ hyphenCase name }}",
|
||||
"MAPBOX",
|
||||
"mapboxgl",
|
||||
"stylis",
|
||||
"Unmatch"
|
||||
],
|
||||
"i18n-ally.localesPaths": [
|
||||
"public/locales"
|
||||
],
|
||||
"i18n-ally.sourceLanguage": "he",
|
||||
"i18n-ally.displayLanguage": "he",
|
||||
"i18next.i18nPaths": "public/locales",
|
||||
"i18n-ally.keystyle": "nested",
|
||||
}
|
||||
30
scaffolds/nextjs/.vscode/snippets.code-snippets
vendored
30
scaffolds/nextjs/.vscode/snippets.code-snippets
vendored
@@ -1,30 +0,0 @@
|
||||
{
|
||||
// Place your {{ hyphenCase name }}-web workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||
// Placeholders with the same ids are connected.
|
||||
// Example:
|
||||
// "Print to console": {
|
||||
// "scope": "javascript,typescript",
|
||||
// "prefix": "log",
|
||||
// "body": [
|
||||
// "console.log('$1');",
|
||||
// "$2"
|
||||
// ],
|
||||
// "description": "Log output to console"
|
||||
// }
|
||||
"Load Translation SSR Props": {
|
||||
"scope": "javascriptreact,typescriptreact",
|
||||
"prefix": "tssr",
|
||||
"body": [
|
||||
"export async function getStaticProps({ locale }: NextPageContext) {",
|
||||
" return {",
|
||||
" props: await getI18nProps(locale ?? 'he', ['${1:{{ hyphenCase name }} }']),",
|
||||
" }",
|
||||
"}",
|
||||
],
|
||||
"description": "Load Translation SSR Props",
|
||||
}
|
||||
}
|
||||
20
scaffolds/nextjs/.vscode/tasks.json
vendored
20
scaffolds/nextjs/.vscode/tasks.json
vendored
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "dev",
|
||||
"problemMatcher": [],
|
||||
"label": "npm: dev",
|
||||
"detail": "next dev"
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "build",
|
||||
"group": "build",
|
||||
"problemMatcher": [],
|
||||
"label": "npm: build",
|
||||
"detail": "next build"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
# Install dependencies only when needed
|
||||
FROM node:16-alpine AS deps
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||
RUN \
|
||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||
elif [ -f package-lock.json ]; then npm ci; \
|
||||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM node:16-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Next.js collects completely anonymous telemetry data about general usage.
|
||||
# Learn more here: https://nextjs.org/telemetry
|
||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN yarn build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM node:16-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# You only need to copy next.config.js if you are NOT using the default configuration
|
||||
COPY --from=builder /app/next.config.js ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,48 +0,0 @@
|
||||
# {{ pascalCase name }} Web App
|
||||
|
||||
## Dev Requirements
|
||||
|
||||
1. [Node.js](https://nodejs.org/en/download/)
|
||||
2. Yarn: `npm install -g yarn`
|
||||
|
||||
> These requirements are for development mode only.
|
||||
> You can run this project statically using Docker without having to install other dependencies.
|
||||
|
||||
## Run in dev mode
|
||||
|
||||
Dev mode allows hot reloading of files & components, and JIT build; as opposed to AOT build +
|
||||
static serving.
|
||||
|
||||
1. Install/update project dependencies: `yarn install`
|
||||
2. Add `.env.local` file to the repository root folder, and fill it with the correct env variables:
|
||||
|
||||
```shell
|
||||
ENV_VAR=
|
||||
```
|
||||
|
||||
3. Run in development mode with hot reload: `yarn dev`
|
||||
4. Open [http://localhost:3000](http://localhost:3000) with your browser
|
||||
|
||||
## Run using Docker
|
||||
|
||||
Add the `.env.local` file mentioned in "Run in dev mode" to build the Docker with the correct
|
||||
environment. Then, you can build the container and run as an image:
|
||||
|
||||
### Shell - Manual
|
||||
|
||||
```shell
|
||||
# build
|
||||
docker build -t nextjs-docker .
|
||||
# run
|
||||
# this docker exposes port 3000, you may forward to any other port
|
||||
# (in this case 3100, to avoid conflict with dev mode run)
|
||||
docker run -p 3100:3000 nextjs-docker
|
||||
```
|
||||
|
||||
### NPM Script - Automated
|
||||
|
||||
```shell
|
||||
# build & run via npm scripts if you have Node.js installed
|
||||
yarn build:docker
|
||||
yarn start:docker
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
import NextLink, { LinkProps as NextLinkProps } from 'next/link'
|
||||
import MUILink, { LinkProps as MUILinkProps } from '@mui/material/Link'
|
||||
|
||||
export const LinkBehavior: React.FC<MUILinkProps> = (props) => {
|
||||
const { href, children, ...rest } = props
|
||||
return (
|
||||
<NextLink passHref href={href!}>
|
||||
<MUILink {...rest}>{children}</MUILink>
|
||||
</NextLink>
|
||||
)
|
||||
}
|
||||
|
||||
export default LinkBehavior
|
||||
@@ -1,11 +0,0 @@
|
||||
import createCache from '@emotion/cache'
|
||||
import stylisRTLPlugin from 'stylis-plugin-rtl'
|
||||
import { prefixer } from 'stylis'
|
||||
|
||||
export const createEmotionCache = () => {
|
||||
return createCache({
|
||||
key: 'css',
|
||||
prepend: true,
|
||||
stylisPlugins: [prefixer, stylisRTLPlugin],
|
||||
})
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
module.exports = {
|
||||
debug: process.env.NODE_ENV === 'development',
|
||||
i18n: {
|
||||
defaultLocale: 'en',
|
||||
locales: ['en'],
|
||||
},
|
||||
defaultNS: '{{ hyphenCase name }}',
|
||||
reloadOnPrerender: process.env.NODE_ENV === 'development',
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const withTM = require('next-transpile-modules')(['@mui/material']) // pass the modules you would like to see transpiled
|
||||
const { i18n } = require('./next-i18next.config')
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
output: 'standalone',
|
||||
reactStrictMode: true,
|
||||
swcMinify: true,
|
||||
i18n,
|
||||
images: {
|
||||
domains: ['placeholder.photo'],
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = withTM(nextConfig)
|
||||
@@ -1,67 +0,0 @@
|
||||
import React from 'react'
|
||||
import type { AppProps } from 'next/app'
|
||||
import CssBaseline from '@mui/material/CssBaseline'
|
||||
import ThemeProvider from '@mui/material/styles/ThemeProvider'
|
||||
import { lightTheme, themeDir } from 'core/theme'
|
||||
import { CacheProvider, EmotionCache } from '@emotion/react'
|
||||
import { createEmotionCache } from 'core/emotion'
|
||||
import { enableStaticRendering } from 'mobx-react-lite'
|
||||
import { appWithTranslation, useTranslation } from 'next-i18next'
|
||||
import nextI18nConfig from '../next-i18next.config'
|
||||
import { QueryClientProvider, QueryClient } from 'react-query'
|
||||
import { ENV } from 'core/env'
|
||||
import { useSilentLoginFlow } from 'core/stores/user_store'
|
||||
|
||||
export interface {{ pascalCase name }}AppProps extends AppProps {
|
||||
emotionCache?: EmotionCache
|
||||
}
|
||||
|
||||
let windowInit = false
|
||||
|
||||
const clientSideEmotionCache = createEmotionCache()
|
||||
const isBrowserLoaded = ENV.BROWSER_LOADED
|
||||
enableStaticRendering(!isBrowserLoaded)
|
||||
|
||||
const _{{ pascalCase name }}App: React.FC<{{ pascalCase name }}AppProps> = (props) => {
|
||||
const { Component, pageProps, emotionCache = clientSideEmotionCache } = props
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: Infinity,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const { i18n } = useTranslation()
|
||||
const themeWithDirection = React.useMemo(
|
||||
() => themeDir(lightTheme, i18n.dir(i18n.language)),
|
||||
[i18n],
|
||||
)
|
||||
const silentLogin = useSilentLoginFlow()
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!windowInit && typeof window !== 'undefined') {
|
||||
windowInit = true
|
||||
silentLogin()
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [typeof window])
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<CacheProvider value={emotionCache}>
|
||||
<ThemeProvider theme={themeWithDirection}>
|
||||
<CssBaseline />
|
||||
<Component {...pageProps} />
|
||||
</ThemeProvider>
|
||||
</CacheProvider>
|
||||
</QueryClientProvider>
|
||||
)
|
||||
}
|
||||
|
||||
const {{ pascalCase name }}App = appWithTranslation(_{{ pascalCase name }}App, nextI18nConfig)
|
||||
|
||||
export default {{ pascalCase name }}App
|
||||
@@ -1,91 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
||||
import { createEmotionCache } from 'core/emotion'
|
||||
import createEmotionServer from '@emotion/server/create-instance'
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
render() {
|
||||
return (
|
||||
<Html lang="he" dir="rtl">
|
||||
<Head>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="*" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="emotion-insertion-point" content="" />
|
||||
{(this.props as any).emotionStyleTags}
|
||||
</Head>
|
||||
<body>
|
||||
{/* Main page content - deferred */}
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// `getInitialProps` belongs to `_document` (instead of `_app`),
|
||||
// it's compatible with static-site generation (SSG).
|
||||
MyDocument.getInitialProps = async (ctx) => {
|
||||
// Resolution order
|
||||
//
|
||||
// On the server:
|
||||
// 1. app.getInitialProps
|
||||
// 2. page.getInitialProps
|
||||
// 3. document.getInitialProps
|
||||
// 4. app.render
|
||||
// 5. page.render
|
||||
// 6. document.render
|
||||
//
|
||||
// On the server with error:
|
||||
// 1. document.getInitialProps
|
||||
// 2. app.render
|
||||
// 3. page.render
|
||||
// 4. document.render
|
||||
//
|
||||
// On the client
|
||||
// 1. app.getInitialProps
|
||||
// 2. page.getInitialProps
|
||||
// 3. app.render
|
||||
// 4. page.render
|
||||
|
||||
const originalRenderPage = ctx.renderPage
|
||||
|
||||
// You can consider sharing the same emotion cache between all the SSR requests to speed up performance.
|
||||
// However, be aware that it can have global side effects.
|
||||
const cache = createEmotionCache()
|
||||
const { extractCriticalToChunks } = createEmotionServer(cache)
|
||||
|
||||
/* eslint-disable */
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App) =>
|
||||
function EnhanceApp(props) {
|
||||
const _injectedProps: any = { emotionCache: cache }
|
||||
return <App {..._injectedProps} {...props} />
|
||||
},
|
||||
})
|
||||
/* eslint-enable */
|
||||
|
||||
const initialProps = await Document.getInitialProps(ctx)
|
||||
// This is important. It prevents emotion to render invalid HTML.
|
||||
// See https://github.com/mui-org/material-ui/issues/26561#issuecomment-855286153
|
||||
const emotionStyles = extractCriticalToChunks(initialProps.html)
|
||||
const emotionStyleTags = emotionStyles.styles.map((style) => (
|
||||
<style
|
||||
data-emotion={`${style.key} ${style.ids.join(' ')}`}
|
||||
key={style.key}
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{ __html: style.css }}
|
||||
/>
|
||||
))
|
||||
|
||||
return {
|
||||
...initialProps,
|
||||
// Styles fragment is rendered after the app and page rendering finish.
|
||||
styles: [...React.Children.toArray(initialProps.styles), ...emotionStyleTags],
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import React from 'react'
|
||||
import type { NextPage } from 'next'
|
||||
import Head from 'next/head'
|
||||
import { Routes, usePushRoute } from 'core/routes'
|
||||
|
||||
const Home: NextPage = () => {
|
||||
const goTo = usePushRoute()
|
||||
|
||||
React.useEffect(() => {
|
||||
goTo(Routes.Signup)
|
||||
}, [goTo])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
{/* TODO update */}
|
||||
<title>{{ pascalCase name }}</title>
|
||||
<meta name="description" content="{{ pascalCase name }} App" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Home
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"app_name": "{{ startCase name }}",
|
||||
"app_bar": {
|
||||
"menu": {
|
||||
"home": "Home"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"baseUrl": "./",
|
||||
},
|
||||
"ts-node": {
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"mui.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"templates/**/*"
|
||||
]
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { sxc } from 'core/utils/object_utils'
|
||||
import { CustomComponent } from 'core/types'
|
||||
import Image from '{{#if nextComponents}}next/image{{else}}components/atoms/Image{{/if}}'
|
||||
import { apiFallbackImageUrl } from 'core/utils/image_utils'
|
||||
|
||||
export interface AvatarProps extends CustomComponent<BoxProps> {
|
||||
src: string
|
||||
size?: number
|
||||
padding?: number
|
||||
}
|
||||
|
||||
export const Avatar: React.FC<AvatarProps> = ({ sx, size = 160, src, padding = 8 }) => {
|
||||
return (
|
||||
<Box
|
||||
sx={sxc(
|
||||
{
|
||||
width: size,
|
||||
height: size,
|
||||
borderRadius: '50%',
|
||||
overflow: 'hidden',
|
||||
boxShadow: (theme) => theme.boxShadows.avatar,
|
||||
padding: `${padding}px`,
|
||||
},
|
||||
sx,
|
||||
)}
|
||||
>
|
||||
<Box
|
||||
sx={ {
|
||||
width: size - padding * 2,
|
||||
height: size - padding * 2,
|
||||
borderRadius: '50%',
|
||||
overflow: 'hidden',
|
||||
} }
|
||||
>
|
||||
<Image
|
||||
src={apiFallbackImageUrl(src)}
|
||||
{{#if nextComponents}}
|
||||
objectFit="cover"
|
||||
{{/if}}
|
||||
width={size}
|
||||
height={size}
|
||||
alt={src}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
import Autocomplete, { AutocompleteProps } from '@mui/material/Autocomplete'
|
||||
import TextField from '@mui/material/TextField'
|
||||
import React from 'react'
|
||||
import { Controller, Control, Path } from 'react-hook-form'
|
||||
import { CustomComponent, Option } from 'core/types'
|
||||
import { optionFrom } from 'core/utils/object_utils'
|
||||
|
||||
export interface ControlledAutocompleteProps<T, K extends Path<T>, Multiple extends boolean = false>
|
||||
extends CustomComponent<Partial<AutocompleteProps<Option, Multiple, false, false>>> {
|
||||
control: Control<T>
|
||||
name: K
|
||||
options: Option[]
|
||||
helperText?: React.ReactNode
|
||||
placeholder?: string
|
||||
required?: boolean
|
||||
multiple?: Multiple
|
||||
}
|
||||
|
||||
export const ControlledAutocomplete = <T, K extends Path<T>, Multiple extends boolean = false>(
|
||||
props: ControlledAutocompleteProps<T, K, Multiple>,
|
||||
) => {
|
||||
const { control, name, options, helperText, placeholder, onChange, multiple, ...rest } = props
|
||||
|
||||
const _value = React.useMemo(
|
||||
(): Multiple extends true ? Option<string>[] : Option<string> | null =>
|
||||
control._formValues[name]
|
||||
? multiple
|
||||
? control._formValues[name].map(optionFrom)
|
||||
: optionFrom(control._formValues[name])
|
||||
: multiple
|
||||
? []
|
||||
: null,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[control._formValues[name]],
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const [value, setValue] = React.useState(_value ?? (multiple ? ([] as string[]) : ('' as any)))
|
||||
React.useEffect(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
() => setValue(_value ?? (multiple ? ([] as string[]) : ('' as any))),
|
||||
[_value, multiple],
|
||||
)
|
||||
|
||||
return (
|
||||
<Controller<T, K>
|
||||
control={control}
|
||||
name={name}
|
||||
rules={ { required: props.required } }
|
||||
render={({ field, formState: { errors } }) => (
|
||||
<Autocomplete
|
||||
onChange={(e, d, r) => {
|
||||
setValue(d as typeof _value)
|
||||
field.onChange(Array.isArray(d) ? d.map((d) => d?.value) : d?.value)
|
||||
onChange?.(e, d, r)
|
||||
}}
|
||||
value={value}
|
||||
options={options}
|
||||
getOptionLabel={(opt) => opt?.label}
|
||||
isOptionEqualToValue={(opt, value) => opt.value === value.value}
|
||||
multiple={multiple}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
fullWidth
|
||||
placeholder={placeholder}
|
||||
helperText={helperText}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
error={Boolean((errors as any)[name])}
|
||||
/>
|
||||
)}
|
||||
{...rest}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
import Select, { SelectProps } from '@mui/material/Select'
|
||||
import MenuItem from '@mui/material/MenuItem'
|
||||
import React from 'react'
|
||||
import { Controller, Control, Path } from 'react-hook-form'
|
||||
import { CustomComponent, Option } from 'core/types'
|
||||
import { useRerender } from 'core/utils/react_utils'
|
||||
|
||||
export interface ControlledSelectProps<
|
||||
R extends string,
|
||||
T,
|
||||
K extends Path<T>,
|
||||
Multiple extends boolean = false,
|
||||
> extends CustomComponent<Partial<SelectProps<R>>> {
|
||||
control: Control<T>
|
||||
name: K
|
||||
options: Option<R>[]
|
||||
helperText?: React.ReactNode
|
||||
placeholder?: string
|
||||
required?: boolean
|
||||
multiple?: Multiple
|
||||
}
|
||||
|
||||
export const ControlledSelect = <
|
||||
R extends string,
|
||||
T,
|
||||
K extends Path<T>,
|
||||
Multiple extends boolean = false,
|
||||
>(
|
||||
props: ControlledSelectProps<R, T, K, Multiple>,
|
||||
) => {
|
||||
const {
|
||||
control,
|
||||
name,
|
||||
options,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
helperText,
|
||||
placeholder,
|
||||
onChange,
|
||||
multiple = false,
|
||||
...rest
|
||||
} = props
|
||||
|
||||
const _value = React.useMemo(
|
||||
(): typeof multiple extends true ? R[] : R | null =>
|
||||
(control._formValues[name]
|
||||
? multiple
|
||||
? (control._formValues[name] as R[]).map((x) => options.find((y) => y.value === x)!.value)
|
||||
: options.find((x) => x.value === control._formValues[name])!.value
|
||||
: multiple
|
||||
? []
|
||||
: null) as typeof multiple extends true ? R[] : R | null,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[control._formValues[name], multiple, name, options],
|
||||
)
|
||||
const [value, setValue] = React.useState<string | string[]>(
|
||||
(Array.isArray(_value) ? _value : _value) ?? (multiple ? [] : ''),
|
||||
)
|
||||
React.useEffect(() => setValue(_value ?? (multiple ? [] : '')), [_value, multiple])
|
||||
const rerender = useRerender()
|
||||
|
||||
return (
|
||||
<Controller<T, K>
|
||||
control={control}
|
||||
name={name}
|
||||
rules={ { required: props.required } }
|
||||
render={({ field, formState: { errors } }) => (
|
||||
<Select
|
||||
onChange={(e, d) => {
|
||||
const { value: changeValue } = e.target!
|
||||
if (!multiple) {
|
||||
field.onChange(changeValue)
|
||||
setValue(changeValue)
|
||||
} else {
|
||||
const valueArr = value as R[]
|
||||
const fieldValue = valueArr.includes(changeValue as unknown as R)
|
||||
? valueArr.filter((x) => x !== changeValue)
|
||||
: [...valueArr, changeValue]
|
||||
field.onChange(fieldValue)
|
||||
setValue(fieldValue)
|
||||
}
|
||||
|
||||
onChange?.(e, d)
|
||||
rerender()
|
||||
}}
|
||||
value={value as R}
|
||||
renderValue={
|
||||
((v) =>
|
||||
Array.isArray(v)
|
||||
? placeholder
|
||||
: options.find((x) => x.value === v)?.label ?? placeholder) as (
|
||||
value: string | string[],
|
||||
) => React.ReactNode
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
error={Boolean((errors as any)[name])}
|
||||
{...rest}
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<MenuItem
|
||||
key={opt.value}
|
||||
value={opt.value}
|
||||
sx={
|
||||
Boolean(Array.isArray(value) ? value.includes(opt.value) : value === opt.value)
|
||||
? {
|
||||
backgroundColor: (theme) => theme.palette.grey[200],
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{opt.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import ChevronLeft from '@mui/icons-material/ChevronLeft'
|
||||
import MenuIcon from '@mui/icons-material/Menu'
|
||||
import Notifications from '@mui/icons-material/Notifications'
|
||||
import Toolbar from '@mui/material/Toolbar'
|
||||
import AppBar from '@mui/material/AppBar'
|
||||
import React from 'react'
|
||||
import IconButton from '@mui/material/IconButton'
|
||||
import Box from '@mui/material/Box'
|
||||
import { Routes, usePushRoute } from 'core/routes'
|
||||
import { useTranslation } from '{{#if nextComponents}}next-i18next{{else}}react-i18next{{/if}}'
|
||||
import Menu from '@mui/material/Menu'
|
||||
import MenuItem from '@mui/material/MenuItem'
|
||||
|
||||
export const TOOLBAR_HEIGHT = 68
|
||||
|
||||
export const MainAppBar: React.FC = React.memo(function MainAppBar() {
|
||||
const [menuRef, setMenuRef] = React.useState<HTMLButtonElement | null>(null)
|
||||
const goTo = usePushRoute()
|
||||
const { t } = useTranslation('{{ hyphenCase name }}')
|
||||
|
||||
const handleMenuClick = React.useCallback((e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
setMenuRef(e.currentTarget)
|
||||
}, [])
|
||||
|
||||
const handleMenuClose = React.useCallback(() => {
|
||||
setMenuRef(null)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBar color="inherit">
|
||||
<Toolbar sx={ { height: `${TOOLBAR_HEIGHT}px` } }>
|
||||
<IconButton onClick={handleMenuClick} color="inherit">
|
||||
<MenuIcon />
|
||||
</IconButton>
|
||||
<IconButton color="inherit" onClick={() => goTo(Routes.Notifications)}>
|
||||
<Notifications />
|
||||
</IconButton>
|
||||
<Box display="flex" flexGrow={1} alignItems="center" justifyContent="center">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src="/logo.svg" alt="{{ pascalCase name }}" width={115} height={25} />
|
||||
</Box>
|
||||
<IconButton color="inherit">
|
||||
<ChevronLeft />
|
||||
</IconButton>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
|
||||
<Menu anchorEl={menuRef} open={!!menuRef} onClose={handleMenuClose}>
|
||||
<MenuItem onClick={() => goTo(Routes.Home)}>
|
||||
{t('app_bar.menu.home')}
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
)
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { CustomComponent } from 'core/types'
|
||||
import CircularProgress from '@mui/material/CircularProgress'
|
||||
import { TOOLBAR_HEIGHT } from './MainAppBar'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface PageLoaderProps extends CustomComponent<BoxProps> {
|
||||
//
|
||||
}
|
||||
|
||||
export const PageLoader: React.FC<PageLoaderProps> = ({ sx }) => {
|
||||
return (
|
||||
<Box
|
||||
position="absolute"
|
||||
top={TOOLBAR_HEIGHT}
|
||||
bottom={0}
|
||||
left={0}
|
||||
right={0}
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
width="100%"
|
||||
height="calc(100vh - 90px)"
|
||||
sx={sx}
|
||||
>
|
||||
<CircularProgress size={64} />
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import React from 'react'
|
||||
import Box, { BoxProps } from '@mui/material/Box'
|
||||
import { sxc } from 'core/utils/object_utils'
|
||||
import { CustomComponent } from 'core/types'
|
||||
import { MainAppBar, TOOLBAR_HEIGHT } from './MainAppBar'
|
||||
import Toolbar from '@mui/material/Toolbar'
|
||||
import { PageLoader } from './PageLoader'
|
||||
import Typography from '@mui/material/Typography'
|
||||
{{#if nextComponents}}
|
||||
import Head from 'next/head'
|
||||
{{/if}}
|
||||
|
||||
export interface PageWrapperProps extends CustomComponent<BoxProps> {
|
||||
fixedMaxWidth?: boolean
|
||||
loading?: boolean
|
||||
pageTitle?: React.ReactNode
|
||||
{{#if nextComponents}}
|
||||
htmlTitle?: string
|
||||
htmlDescription?: string
|
||||
{{/if}}
|
||||
render?: (props: PageWrapperProps) => React.ReactNode
|
||||
}
|
||||
|
||||
export const PageWrapper: React.FC<PageWrapperProps> = (props) => {
|
||||
const {
|
||||
sx,
|
||||
children,
|
||||
loading,
|
||||
fixedMaxWidth = true,
|
||||
{{#if nextComponents}}
|
||||
htmlTitle,
|
||||
htmlDescription,
|
||||
{{/if}}
|
||||
pageTitle,
|
||||
render,
|
||||
} = props
|
||||
return (
|
||||
<Box
|
||||
sx={sxc(
|
||||
{
|
||||
padding: (theme) => theme.spacing(3, 2),
|
||||
margin: '0 auto',
|
||||
},
|
||||
fixedMaxWidth && {
|
||||
maxWidth: 600,
|
||||
},
|
||||
sx,
|
||||
)}
|
||||
>
|
||||
{{#if nextComponents}}
|
||||
{htmlTitle || htmlDescription ? (
|
||||
<Head>
|
||||
<title>{htmlTitle}</title>
|
||||
<meta name="description" content={htmlDescription} />
|
||||
</Head>
|
||||
) : null}
|
||||
{{/if}}
|
||||
{/* App Bar */}
|
||||
<MainAppBar />
|
||||
{/* Empty toolbar - to save space for fixed app bar */}
|
||||
<Toolbar sx={ { height: `${TOOLBAR_HEIGHT}px` } } />
|
||||
{pageTitle ? (
|
||||
<Typography fontWeight={600} variant="h5">
|
||||
{pageTitle}
|
||||
</Typography>
|
||||
) : null}
|
||||
{loading ? <PageLoader /> : render?.(props) ?? children}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { useTranslation } from '{{#if nextComponents}}next-i18next{{else}}react-i18next{{/if}}';
|
||||
import React from 'react'
|
||||
|
||||
export function useNumberFormatter(options?: Intl.NumberFormatOptions): Intl.NumberFormat {
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
return React.useMemo(() => {
|
||||
return Intl.NumberFormat(i18n.language, options)
|
||||
}, [i18n.language, options])
|
||||
}
|
||||
export function useCurrencyFormatter(options?: Intl.NumberFormatOptions): Intl.NumberFormat {
|
||||
return useNumberFormatter({
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
...options,
|
||||
})
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import axios, { Axios, AxiosResponse } from 'axios'
|
||||
import { ENV } from '../env'
|
||||
|
||||
const client = axios.create({
|
||||
baseURL: ENV.API_BASE + '/api/v1',
|
||||
})
|
||||
|
||||
export class ApiCollection {
|
||||
client!: Axios
|
||||
|
||||
constructor() {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
public setAuthHeaders(token: string) {
|
||||
this.client.defaults.headers.common['Authorization'] = `Bearer ${token}`
|
||||
}
|
||||
|
||||
public unsetAuthHeaders() {
|
||||
delete this.client.defaults.headers.common['Authorization']
|
||||
}
|
||||
|
||||
protected async parse<T, K extends keyof T>(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
result: Promise<AxiosResponse<T>>,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
key: K,
|
||||
): Promise<T[K]>
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
protected async parse<T, K extends keyof T>(result: Promise<AxiosResponse<T>>): Promise<T>
|
||||
protected async parse<T, K extends keyof T>(
|
||||
result: Promise<AxiosResponse<T>>,
|
||||
key?: K,
|
||||
): Promise<T | T[K]> {
|
||||
const { data } = await result
|
||||
return key ? data[key] : data
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export {}
|
||||
@@ -1,55 +0,0 @@
|
||||
import { ENV } from '../env'
|
||||
import { User } from '../models/user'
|
||||
import { ProviderType } from '../stores/user_store'
|
||||
import { ApiCollection } from './api'
|
||||
|
||||
export type GetUserResponse = User
|
||||
|
||||
export interface UserRegisterRequest {
|
||||
firstName: string
|
||||
lastName: string
|
||||
}
|
||||
|
||||
export interface UserLoginParams {
|
||||
provider: ProviderType
|
||||
accessToken: string
|
||||
}
|
||||
|
||||
export interface UserRegisterResponse {
|
||||
id_token: string
|
||||
registered: boolean
|
||||
ready: boolean
|
||||
}
|
||||
|
||||
class UserApi extends ApiCollection {
|
||||
getCurrentUser(): Promise<GetUserResponse> {
|
||||
return this.parse(this.client.get<GetUserResponse>('/user/current'))
|
||||
}
|
||||
|
||||
login({ provider, accessToken }: UserLoginParams): Promise<UserRegisterResponse> {
|
||||
return this.parse(
|
||||
this.client.post<UserRegisterResponse>(
|
||||
'/login',
|
||||
{ provider },
|
||||
{
|
||||
baseURL: ENV.API_BASE,
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Provider: provider,
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
updateUser(details: UserRegisterRequest): Promise<UserRegisterResponse> {
|
||||
return this.parse(this.client.patch<UserRegisterResponse>('/user', details))
|
||||
}
|
||||
|
||||
unsubscribeUser() {
|
||||
this.parse(this.client.delete<UserRegisterResponse>('/user'))
|
||||
}
|
||||
}
|
||||
|
||||
export const userApi = new UserApi()
|
||||
export default userApi
|
||||
@@ -1,7 +0,0 @@
|
||||
export const ENV = {
|
||||
{{#if nextComponents}}
|
||||
BROWSER_LOADED: typeof window !== 'undefined',
|
||||
{{/if}}
|
||||
API_BASE: '/api',
|
||||
IS_DEBUG: process.env.NODE_ENV === 'development',
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
|
||||
export async function getI18nProps(locale: string | undefined | null, namespaces: string[]) {
|
||||
return serverSideTranslations(
|
||||
locale ?? 'he',
|
||||
Array.from(new Set(['{{ hyphenCase name }}', ...namespaces])),
|
||||
)
|
||||
}
|
||||
|
||||
// export async function getI18nPropsFn(namespaces: string[]) {
|
||||
// return async ({ locale }: NextPageContext) => {
|
||||
// return { props: await serverSideTranslations(locale ?? 'he', namespaces) }
|
||||
// }
|
||||
// }
|
||||
@@ -1,5 +0,0 @@
|
||||
export interface User {
|
||||
firstName: string
|
||||
lastName: string
|
||||
email: string
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { {{#unless nextComponents}}useNavigate as {{/unless}}useRouter } from '{{#if nextComponents}}next/router{{else}}react-router{{/if}}'
|
||||
import React from 'react'
|
||||
|
||||
export const Routes = {
|
||||
Home: '/',
|
||||
Register: '/register',
|
||||
Login: '/login',
|
||||
}
|
||||
|
||||
type RoutePush = (route: string, params?: { [key: string]: string }) => {{#if nextComponents}}Promise<boolean>{{else}}void{{/if}}
|
||||
|
||||
export function usePushRoute(): RoutePush {
|
||||
const router = useRouter()
|
||||
const goTo = React.useCallback(
|
||||
(route: string, params?: { [key: string]: string }) =>
|
||||
{{#if nextComponents}}
|
||||
router.push(buildRoute(route, params ?? {})),
|
||||
{{else}}
|
||||
router(buildRoute(route, params ?? {})),
|
||||
{{/if}}
|
||||
|
||||
[router],
|
||||
)
|
||||
return goTo
|
||||
}
|
||||
|
||||
export function buildRoute(route: string, params: { [key: string]: string }): string {
|
||||
if (!route.includes(':')) {
|
||||
console.warn('Route does not contain any params', route)
|
||||
return route
|
||||
}
|
||||
return Object.entries(params).reduce((acc, [key, value]) => acc.replace(`:${key}`, value), route)
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
import { makeAutoObservable } from 'mobx'
|
||||
import { User } from '../models/user'
|
||||
import userApi, { UserLoginParams, UserRegisterResponse } from '../api/user.api'
|
||||
import { ENV } from '../env'
|
||||
import { Routes, usePushRoute } from '../routes'
|
||||
import { {{#unless nextComponents}}useLocation as {{/unless}}useRouter } from '{{#if nextComponents}}next/router{{else}}react-router{{/if}}'
|
||||
|
||||
export type ProviderType = 'facebook' | 'google'
|
||||
|
||||
export interface ParsedProviderDetails {
|
||||
provider: ProviderType
|
||||
accessToken: string
|
||||
email: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
}
|
||||
|
||||
class UserStore {
|
||||
maybeUser: User | null = null
|
||||
provider: ProviderType | null = null
|
||||
/** Token used to login to {{ hyphenCase name }} only - sourced from social login */
|
||||
accessToken: string | null = null
|
||||
/** Token used to auth inside {{ hyphenCase name }} - sourced from `/login` endpoint */
|
||||
idToken: string | null = null
|
||||
loading = true
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
|
||||
if ({{#if nextComponents}}ENV.BROWSER_LOADED && {{/if}}localStorage.getItem('idToken')) {
|
||||
this.getStoredIdToken()
|
||||
}
|
||||
if ({{#if nextComponents}}ENV.BROWSER_LOADED && {{/if}}localStorage.getItem('accessToken')) {
|
||||
this.getStoredAccessToken()
|
||||
}
|
||||
}
|
||||
|
||||
public async login(params: UserLoginParams): Promise<UserRegisterResponse> {
|
||||
this.loading = true
|
||||
const resp = await userApi.login(params)
|
||||
const { user, id_token: idToken } = resp
|
||||
this.setUser(user)
|
||||
this.setIdToken(idToken)
|
||||
this.setAccessToken(params.provider, params.accessToken)
|
||||
this.loading = false
|
||||
return resp
|
||||
}
|
||||
|
||||
public async silentLogin(): Promise<UserRegisterResponse | undefined> {
|
||||
this.loading = true
|
||||
this.getStoredAccessToken()
|
||||
if (this.provider && this.accessToken) {
|
||||
const resp = await this.login({ provider: this.provider, accessToken: this.accessToken })
|
||||
this.loading = false
|
||||
return resp
|
||||
}
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
/** Token used to login to {{ hyphenCase name }} only - sourced from social login */
|
||||
public getStoredAccessToken() {
|
||||
const provider = localStorage.getItem('tokenProvider') as ProviderType | null
|
||||
const token = localStorage.getItem('accessToken')
|
||||
if (provider && token) {
|
||||
this.setAccessToken(provider, token)
|
||||
}
|
||||
}
|
||||
|
||||
/** Token used to auth inside {{ hyphenCase name }} - sourced from `/login` endpoint */
|
||||
public getStoredIdToken() {
|
||||
const token = localStorage.getItem('idToken')
|
||||
if (token) {
|
||||
this.setIdToken(token)
|
||||
}
|
||||
}
|
||||
|
||||
public get user(): User {
|
||||
return this.maybeUser!
|
||||
}
|
||||
|
||||
private setUser(user: User) {
|
||||
this.maybeUser = user
|
||||
}
|
||||
|
||||
public get isLoggedIn(): boolean {
|
||||
return Boolean(this.maybeUser)
|
||||
}
|
||||
|
||||
/** Token used to login to {{ hyphenCase name }} only - sourced from social login */
|
||||
private setAccessToken(provider: ProviderType, accessToken: string) {
|
||||
{{#if nextComponents}} if (ENV.BROWSER_LOADED) { {{/if}}
|
||||
localStorage.setItem('accessToken', accessToken)
|
||||
localStorage.setItem('tokenProvider', provider)
|
||||
{{#if nextComponents}} } {{/if}}
|
||||
this.accessToken = accessToken
|
||||
this.provider = provider
|
||||
}
|
||||
|
||||
/** Token used to auth inside {{ hyphenCase name }} - sourced from `/login` endpoint */
|
||||
private setIdToken(idToken: string) {
|
||||
{{#if nextComponents}} if (ENV.BROWSER_LOADED) { {{/if}}
|
||||
localStorage.setItem('idToken', idToken)
|
||||
{{#if nextComponents}} } {{/if}}
|
||||
this.idToken = idToken
|
||||
userApi.setAuthHeaders(idToken)
|
||||
}
|
||||
}
|
||||
|
||||
const _userStore = new UserStore()
|
||||
|
||||
/** Don't forget to wrap in observer if needed */
|
||||
export function useUserStore(): UserStore {
|
||||
return _userStore
|
||||
}
|
||||
|
||||
/** Don't forget to wrap in observer if needed */
|
||||
export function useUser(): User {
|
||||
return useUserStore().user
|
||||
}
|
||||
|
||||
function _useLoginRedirect(force?: boolean): (registered: boolean) => void {
|
||||
const goTo = usePushRoute()
|
||||
const router = useRouter()
|
||||
|
||||
return (registered) => {
|
||||
if (!force && router.pathname !== '/') {
|
||||
return
|
||||
}
|
||||
if (registered || force) {
|
||||
// TODO use [Routes.Home] once redirect is removed
|
||||
goTo(Routes.Home)
|
||||
} else {
|
||||
goTo(Routes.Register)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function useLoginFlow(forceRedirect?: boolean): (details: UserLoginParams) => Promise<void> {
|
||||
const store = useUserStore()
|
||||
const redirect = _useLoginRedirect(forceRedirect)
|
||||
|
||||
return async (details) => {
|
||||
const { registered } = await store.login(details)
|
||||
redirect(registered)
|
||||
}
|
||||
}
|
||||
|
||||
export function useSilentLoginFlow(forceRedirect?: boolean): () => Promise<void> {
|
||||
const store = useUserStore()
|
||||
const redirect = _useLoginRedirect(forceRedirect)
|
||||
const goTo = usePushRoute()
|
||||
const router = useRouter()
|
||||
|
||||
return async () => {
|
||||
try {
|
||||
const resp = await store.silentLogin()
|
||||
if (!resp) {
|
||||
// TODO check public route permission instead of directly checking against [Routes.Home]
|
||||
if (!store.isLoggedIn && router.pathname !== Routes.Home) {
|
||||
goTo(Routes.Register)
|
||||
}
|
||||
return
|
||||
}
|
||||
redirect(resp.registered)
|
||||
} catch (e) {
|
||||
goTo(Routes.Register)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import { alpha } from '@mui/material/styles'
|
||||
import createTheme, { Theme } from '@mui/material/styles/createTheme'
|
||||
import { LinkProps } from '@mui/material/Link'
|
||||
import LinkBehavior from 'components/atoms/Link'
|
||||
|
||||
const colors = {
|
||||
primary: '#000000',
|
||||
}
|
||||
|
||||
const shadows = {
|
||||
input: `0 2px 10px ${alpha('#000000', 0.25)}`,
|
||||
card: `0 1px 9px ${alpha('#000000', 0.25)}`,
|
||||
avatar: `0 1px 9px ${alpha('#000000', 0.25)}`,
|
||||
}
|
||||
|
||||
export const lightTheme = createTheme({
|
||||
boxShadows: shadows,
|
||||
typography: {
|
||||
fontFamily: 'Roboto, Helvetica, sans-serif',
|
||||
},
|
||||
palette: {
|
||||
mode: 'light',
|
||||
},
|
||||
components: {
|
||||
MuiLink: {
|
||||
defaultProps: {
|
||||
component: LinkBehavior,
|
||||
} as LinkProps,
|
||||
},
|
||||
MuiButtonBase: {
|
||||
defaultProps: {
|
||||
LinkComponent: LinkBehavior,
|
||||
},
|
||||
},
|
||||
MuiSelect: {
|
||||
defaultProps: {
|
||||
variant: 'outlined',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export function themeDir(theme: Theme, direction: 'ltr' | 'rtl'): Theme {
|
||||
return { ...theme, direction }
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import React from 'react'
|
||||
|
||||
export interface HTMLComponent<T extends HTMLElement>
|
||||
extends React.PropsWithChildren<React.HTMLProps<T>>,
|
||||
CustomComponent {
|
||||
//
|
||||
}
|
||||
|
||||
export type CustomComponent<T = unknown> = T & {
|
||||
className?: string
|
||||
}
|
||||
|
||||
export interface Option<T = unknown> {
|
||||
value: T
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface ReactOptions<T = unknown> extends Omit<Option<T>, 'label'> {
|
||||
label: React.ReactNode
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export function asArray<T extends any[]>(value: T | T[0]): T {
|
||||
if (value === null || value === undefined) return [] as any
|
||||
return Array.isArray(value) ? value : ([value] as any)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import React from 'react'
|
||||
import { FieldErrors } from 'react-hook-form'
|
||||
|
||||
export function useFormErrorText<T>(
|
||||
errors: FieldErrors<T>,
|
||||
): (key: keyof T, error: string) => string | undefined {
|
||||
const fn = React.useCallback(
|
||||
(key: keyof T, error: string) => (errors?.[key] ? error : undefined),
|
||||
[errors],
|
||||
)
|
||||
|
||||
return fn
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
import React from 'react'
|
||||
import debounce from 'lodash/debounce'
|
||||
import { DebouncedFunc } from 'lodash'
|
||||
import { ENV } from '../env'
|
||||
|
||||
export interface UseWindowSizeOptions {
|
||||
type: 'inner' | 'outer'
|
||||
delay?: number
|
||||
}
|
||||
export function useWindowSize({
|
||||
type = 'inner',
|
||||
delay = 100,
|
||||
}: Partial<UseWindowSizeOptions> = {}): {
|
||||
width: number
|
||||
height: number
|
||||
} {
|
||||
const wKey: keyof Window = React.useMemo(() => `${type}Width` as keyof Window, [type])
|
||||
const hKey: keyof Window = React.useMemo(() => `${type}Height` as keyof Window, [type])
|
||||
|
||||
const [windowSize, setWindowSize] = React.useState({
|
||||
{{#if nextComponents}}
|
||||
width: ENV.BROWSER_LOADED ? window[wKey] : 0,
|
||||
height: ENV.BROWSER_LOADED ? window[hKey] : 0,
|
||||
{{else}}
|
||||
width: window[wKey],
|
||||
height: window[hKey],
|
||||
{{/if}}
|
||||
})
|
||||
|
||||
const handleResize = useDebounce(
|
||||
(): void => setWindowSize({ width: window?.[wKey] ?? 0, height: window?.[hKey] ?? 0 }),
|
||||
delay,
|
||||
[hKey, wKey, delay],
|
||||
)
|
||||
|
||||
React.useEffect(() => {
|
||||
window.addEventListener('resize', handleResize)
|
||||
return () => window.removeEventListener('resize', handleResize)
|
||||
}, [hKey, handleResize, wKey])
|
||||
|
||||
return windowSize
|
||||
}
|
||||
|
||||
export function useDebounce<T extends (...any: unknown[]) => unknown>(
|
||||
fn: T,
|
||||
delay: number | undefined = undefined,
|
||||
deps: unknown[] = [],
|
||||
): DebouncedFunc<T> {
|
||||
const cb = React.useMemo(() => debounce(fn, delay), [fn, delay])
|
||||
return React.useCallback(cb, [cb, ...deps])
|
||||
}
|
||||
|
||||
export function preventDefault<
|
||||
T extends React.SyntheticEvent,
|
||||
Cb extends (e: T, ...args: unknown[]) => void = (e: T, ...args: unknown[]) => void,
|
||||
>(cb: Cb): Cb {
|
||||
return ((e: T, ...args: unknown[]): void => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
cb(e, ...args)
|
||||
}) as unknown as Cb
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
export function fallbackImageUrl(
|
||||
text: string,
|
||||
{ width, height }: Record<'width' | 'height', number>,
|
||||
): string {
|
||||
const qs = new URLSearchParams({
|
||||
bg_color: '008000',
|
||||
fg_color: 'FFFFFF',
|
||||
text,
|
||||
})
|
||||
|
||||
return `https://placeholder.photo/img/${width}x${height}?` + qs.toString()
|
||||
}
|
||||
|
||||
export function apiFallbackImageUrl(url: string): string {
|
||||
return `/api/image?url=${decodeURIComponent(url)}`
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
export function useLocaleDirection(): 'ltr' | 'rtl' {
|
||||
const { i18n } = useTranslation()
|
||||
return i18n.dir(i18n.language)
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { SxProps } from '@mui/material/styles'
|
||||
import { Theme } from '@mui/material/styles/createTheme'
|
||||
import { SystemCssProperties } from '@mui/system/styleFunctionSx'
|
||||
import { Option } from '../types'
|
||||
import { asArray } from './array_utils'
|
||||
|
||||
export function uniqueKeyFromObj<T>(object: T, keys?: Array<keyof T>): string {
|
||||
if (!keys) {
|
||||
keys = Object.keys(object) as Array<keyof T>
|
||||
}
|
||||
return keys.map((key) => String(object[key]).replaceAll(/[^a-z0-9]+/gi, '_')).join('-')
|
||||
}
|
||||
|
||||
export function uniqueKeyFrom(...array: Array<any>): string {
|
||||
return array.map((item) => String(item).replaceAll(/[^a-z0-9]+/gi, '_')).join('-')
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines `sx` props easily
|
||||
* @param sx sx prop for this component
|
||||
* @param rest passed sx props from parent
|
||||
* @returns sx compatible props combined
|
||||
*/
|
||||
export function sxc(
|
||||
sx: SxProps<Theme>,
|
||||
...rest: Array<SxProps<Theme> | SystemCssProperties<Theme> | undefined | false>
|
||||
): SxProps<Theme> {
|
||||
return [...asArray(sx), ...asArray(rest)]
|
||||
}
|
||||
|
||||
export function optionFrom(value: string): Option<string> {
|
||||
return { label: value, value }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export async function delayedPromise(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
import React from 'react'
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query'
|
||||
import { ListResult } from '../api/api_types'
|
||||
|
||||
export function useRerender(): () => void {
|
||||
const [, rerender] = React.useState(0)
|
||||
return React.useCallback(() => rerender((r) => r + 1), [rerender])
|
||||
}
|
||||
|
||||
type MaybeKey<K extends string> = `maybe${Capitalize<K>}`
|
||||
|
||||
export type EnhancedQueryResponse<T, K extends keyof T> = UseQueryResult<T> & {
|
||||
[key in MaybeKey<Exclude<K, number | symbol>>]: T[K] | undefined
|
||||
} & {
|
||||
[key in K]: T[K]
|
||||
}
|
||||
|
||||
type EnhancedQueryHook<T, K extends keyof T> = (
|
||||
options?: RequiredQueryOptions<T>,
|
||||
) => EnhancedQueryResponse<T, K>
|
||||
|
||||
export type RequiredQueryOptions<T> = Omit<UseQueryOptions<T>, 'queryKey' | 'queryFn'>
|
||||
|
||||
type StateUpdater<T> = T extends unknown[]
|
||||
? {
|
||||
add: (item: T[number]) => void
|
||||
update: (item: T[number]) => void
|
||||
remove: (item: T[number]) => void
|
||||
}
|
||||
: {
|
||||
set: (item: T) => void
|
||||
}
|
||||
|
||||
type EnhancedQueryOptions<
|
||||
K extends Exclude<keyof T, number | symbol>,
|
||||
T,
|
||||
IKey extends keyof (T[K] extends unknown[] ? T[K][number] : never),
|
||||
> = {
|
||||
cacheKey: string
|
||||
responseKey: K
|
||||
innerKey?: IKey
|
||||
defaultOptions?: RequiredQueryOptions<T>
|
||||
// objectId?: (a: never) => unknown
|
||||
// objectId?: (a: SingleGetter<T, K, IKey>) => unknown
|
||||
}
|
||||
|
||||
type InnerObjTest<T, K extends keyof T> = T[K] extends unknown[] ? T[K][number] : never
|
||||
|
||||
type SingleGetter<
|
||||
T,
|
||||
K extends keyof T,
|
||||
IKey extends keyof InnerObjTest<T, K>,
|
||||
> = T[K] extends unknown[]
|
||||
? IKey extends keyof T[K][number]
|
||||
? T[K][number][IKey]
|
||||
: T[K][number]
|
||||
: IKey extends keyof T[K]
|
||||
? T[K][IKey]
|
||||
: T[K]
|
||||
|
||||
export function createUseApi<
|
||||
T,
|
||||
K extends Exclude<keyof T, number | symbol>,
|
||||
IKey extends keyof (T[K] extends unknown[] ? T[K][number] : never),
|
||||
>(
|
||||
api: () => Promise<T>,
|
||||
{ cacheKey, responseKey, defaultOptions }: EnhancedQueryOptions<K, T, IKey>,
|
||||
): EnhancedQueryHook<T, K> {
|
||||
return (options): EnhancedQueryResponse<T, K> => {
|
||||
const [cache, setCache] = React.useState<T[K]>()
|
||||
|
||||
const { data = {} as T, ...rest } = useQuery([cacheKey], api, {
|
||||
...defaultOptions,
|
||||
...options,
|
||||
onSuccess: (data) => {
|
||||
setCache(data[responseKey])
|
||||
options?.onSuccess?.(data)
|
||||
},
|
||||
} as Omit<UseQueryOptions<T>, 'queryKey' | 'queryFn'>)
|
||||
const ent = data[responseKey]!
|
||||
|
||||
const response: EnhancedQueryResponse<T, K> = {
|
||||
...(rest as UseQueryResult<T>),
|
||||
[responseKey]: ent,
|
||||
['maybe' + responseKey[0].toUpperCase() + responseKey.slice(1)]: ent,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: cache as never,
|
||||
}
|
||||
console.log(cacheKey, 'response', response.data, response)
|
||||
return response
|
||||
}
|
||||
}
|
||||
23
scaffolds/react-app-common/mui.d.ts
vendored
23
scaffolds/react-app-common/mui.d.ts
vendored
@@ -1,23 +0,0 @@
|
||||
import { PaletteOptions, PaletteColorOptions } from '@mui/material/styles/createPalette'
|
||||
|
||||
declare module '@mui/material/styles/createTheme' {
|
||||
type Shadows =
|
||||
| 'input'
|
||||
| 'card'
|
||||
| 'avatar'
|
||||
|
||||
interface ThemeOptions {
|
||||
boxShadows: Record<Shadows, string>
|
||||
}
|
||||
|
||||
interface Theme {
|
||||
boxShadows: Record<Shadows, string>
|
||||
}
|
||||
}
|
||||
declare module '@mui/material/styles/createPalette' {
|
||||
export interface PaletteOptions {
|
||||
link?: PaletteColorOptions
|
||||
disabled?: PaletteColorOptions
|
||||
disabledBackground?: PaletteColorOptions
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ HIST_STAMPS="%d/%m/%Y %I:%M:%S"
|
||||
|
||||
source ~/.zplug/init.zsh
|
||||
|
||||
zplug "$DOTFILES/plugins", from:local
|
||||
zplug "$DOTFILES/plugins", use:"*.plugin.zsh", from:local
|
||||
|
||||
zplug "mfaerevaag/wd", as:command, use:"wd.sh", hook-load:"wd() { . $ZPLUG_REPOS/mfaerevaag/wd/wd.sh }"
|
||||
zplug "romkatv/powerlevel10k", as:theme, depth:1
|
||||
|
||||
Reference in New Issue
Block a user