Skip to content

Commit

Permalink
chore(nui): WIP React rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed Dec 30, 2021
1 parent ce802e7 commit b2b1a64
Show file tree
Hide file tree
Showing 35 changed files with 391 additions and 460 deletions.
6 changes: 3 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ client_script 'ui.lua'
server_script 'dist/build.js'

files {
'ui/public/index.html',
'ui/public/**/*'
'ui/build/index.html',
'ui/build/**/*'
}

ui_page 'src/ui/public/index.html'
ui_page 'ui/build/index.html'

provide 'mysql-async'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"postinstall-postinstall": "^2.1.0",
"typescript": "^4.5.4"
}
}
}
23 changes: 21 additions & 2 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
/node_modules/
/public/build/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

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

npm-debug.log*
yarn-debug.log*
yarn-error.log*
46 changes: 46 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

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

## Available Scripts

In the project directory, you can run:

### `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/).
24 changes: 24 additions & 0 deletions ui/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require("path");
module.exports = {
webpack: {
configure: (webpackConfig) => {
// Because CEF has issues with loading source maps properly atm,
// lets use the best we can get in line with `eval-source-map`
if (webpackConfig.mode === 'development' && process.env.IN_GAME_DEV) {
webpackConfig.devtool = 'eval-source-map'
webpackConfig.output.path = path.join(__dirname, 'build')
}

return webpackConfig
}
},

devServer: (devServerConfig) => {
if (process.env.IN_GAME_DEV) {
// Used for in-game dev mode
devServerConfig.writeToDisk = true
}

return devServerConfig
}
}
69 changes: 46 additions & 23 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
{
"name": "svelte-app",
"version": "1.0.0",
"name": "web",
"version": "0.1.0",
"homepage": "web/build",
"private": true,
"dependencies": {
"@chakra-ui/react": "^1.7.3",
"@emotion/react": "11",
"@emotion/styled": "11",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^16.11.9",
"@types/react": "^17.0.35",
"@types/react-dom": "^17.0.11",
"framer-motion": "4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.5.2",
"web-vitals": "^2.1.2"
},
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear"
"start": "cross-env PUBLIC_URL=/ craco start",
"start:game": "cross-env IN_GAME_DEV=1 craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-typescript": "^8.0.0",
"@tsconfig/svelte": "^2.0.0",
"rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.0.0",
"svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.0.0"
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"dependencies": {
"sirv-cli": "^1.0.0",
"svelte-spa-router": "^3.2.0"
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"craco": "^0.0.3",
"cross-env": "^7.0.3"
}
}
11 changes: 0 additions & 11 deletions ui/public/global.css

This file was deleted.

25 changes: 16 additions & 9 deletions ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<title>Svelte app</title>

<link rel="stylesheet" href="./global.css" />
<link rel="stylesheet" href="./build/bundle.css" />

<script defer src="./build/bundle.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>NUI React Boilerplate</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.
<body></body>
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
87 changes: 0 additions & 87 deletions ui/rollup.config.js

This file was deleted.

36 changes: 0 additions & 36 deletions ui/src/App.svelte

This file was deleted.

Empty file added ui/src/components/App.css
Empty file.
25 changes: 25 additions & 0 deletions ui/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import './App.css';
import { Center, Box } from '@chakra-ui/react';
import { debugData } from '../utils/debugData';
import TopBar from './NavBars/TopBar';
import SideBar from './NavBars/SideBar';

debugData([
{
action: 'setVisible',
data: true,
},
]);

const App: React.FC = () => {
return (
<Center w="100%" h="100%">
<Box width="60%" height="60%" backgroundColor="#191E26" borderRadius="1vh" color="white" fontFamily="Poppins">
<TopBar />
<SideBar />
</Box>
</Center>
);
};

export default App;
Loading

0 comments on commit b2b1a64

Please sign in to comment.