init project

main
alex 2024-08-05 19:56:47 +02:00
commit b01b0fc81a
12 changed files with 21102 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# Camera Slider

20814
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

39
package.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "camera-slider-web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"antd": "^5.20.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "BROWSER=none HOST=127.0.0.1 PORT=50252 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

17
public/index.html Normal file
View File

@ -0,0 +1,17 @@
<!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="Camera Slider by Jannex" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Camera Slider</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

BIN
public/logo192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
public/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

25
public/manifest.json Normal file
View File

@ -0,0 +1,25 @@
{
"short_name": "Camera Slider",
"name": "Camera Slider by Jannex",
"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"
}

3
public/robots.txt Normal file
View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

182
src/App.js Normal file
View File

@ -0,0 +1,182 @@
import {
Button,
Card,
Col,
Form,
Grid,
InputNumber,
Row,
Select,
Slider,
} from "antd";
import { useForm } from "antd/es/form/Form";
import { useEffect, useState } from "react";
const { useBreakpoint } = Grid;
const Constants = {
DISTANCE: {
MIN: 0,
MAX: 100,
},
ACCELERATION: {
MIN: 0,
MAX: 100,
},
DURATION: {
MIN: 1,
MAX: 60,
},
};
function App() {
const screens = useBreakpoint();
const [form] = useForm();
const [distance, setDistance] = useState([20, 50]);
const [acceleration, setAcceleration] = useState(0);
useEffect(() => {
// todo: fetch to esp to get current values
}, []);
return (
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
overflow: "auto",
marginTop: 60,
marginBottom: 60,
}}
>
<Card
title="Kamera Slider"
style={{
width: "90%",
maxWidth: 800,
}}
>
<Form
form={form}
layout="vertical"
onFinish={() => {
console.log("finish");
// todo: fetch to update values
}}
>
<Form.Item name="distance" label="Distanz">
<Row>
<Col xs={24} md={4}>
<InputNumber
min={Constants.DISTANCE.MIN}
max={Constants.DISTANCE.MAX}
value={distance[0]}
step={1}
onChange={(value) =>
setDistance((newDistance) => {
const newData = [...newDistance];
newData[0] = value;
return newData;
})
}
/>
</Col>
<Col xs={24} md={16}>
<Slider
range
defaultValue={[20, 50]}
marks={{ 0: "0", 100: "100" }}
min={Constants.DISTANCE.MIN}
max={Constants.DISTANCE.MAX}
value={distance}
onChange={(values) => setDistance(values)}
/>
</Col>
<Col xs={24} md={4}>
<InputNumber
min={Constants.DISTANCE.MIN}
max={Constants.DISTANCE.MAX}
style={{
margin: screens.md ? "0 26px" : "",
}}
value={distance[1]}
step={1}
onChange={(value) =>
setDistance((newDistance) => {
const newData = [...newDistance];
newData[1] = value;
return newData;
})
}
/>
</Col>
</Row>
</Form.Item>
<Form.Item name="duration" label="Dauer" initialValue={5}>
<InputNumber
step={1}
min={Constants.DURATION.MIN}
max={Constants.DURATION.MAX}
addonAfter={
<Select
defaultValue="seconds"
style={{
width: 120,
}}
>
<Select.Option value="seconds">Sekunden</Select.Option>
<Select.Option value="minutes">Minuten</Select.Option>
</Select>
}
/>
</Form.Item>
<Form.Item name="acceleration" label="Beschleunigung">
<Row>
<Col xs={24} md={20}>
<Slider
defaultValue={20}
marks={{ 0: "0", 100: "100" }}
min={Constants.ACCELERATION.MIN}
max={Constants.ACCELERATION.MAX}
value={acceleration}
onChange={(value) => setAcceleration(value)}
/>
</Col>
<Col xs={24} md={4}>
<InputNumber
min={Constants.ACCELERATION.MIN}
max={Constants.ACCELERATION.MAX}
style={{
margin: screens.md ? "0 26px" : "",
}}
value={acceleration}
onChange={(value) => setAcceleration(value)}
/>
</Col>
</Row>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" block>
Speichern
</Button>
</Form.Item>
</Form>
</Card>
</div>
);
}
export default App;

14
src/index.css Normal file
View File

@ -0,0 +1,14 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #ebebeb;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

7
src/index.js Normal file
View File

@ -0,0 +1,7 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);