aboutsummaryrefslogtreecommitdiff
path: root/paste-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'paste-ui/src')
-rw-r--r--paste-ui/src/App.css38
-rw-r--r--paste-ui/src/App.js20
-rw-r--r--paste-ui/src/App.test.js8
-rw-r--r--paste-ui/src/api.js0
-rw-r--r--paste-ui/src/index.css13
-rw-r--r--paste-ui/src/index.js17
-rw-r--r--paste-ui/src/list.js46
-rw-r--r--paste-ui/src/reportWebVitals.js13
-rw-r--r--paste-ui/src/setupTests.js5
-rw-r--r--paste-ui/src/stateExample.js32
-rw-r--r--paste-ui/src/style.css71
-rw-r--r--paste-ui/src/view.js54
12 files changed, 317 insertions, 0 deletions
diff --git a/paste-ui/src/App.css b/paste-ui/src/App.css
new file mode 100644
index 0000000..74b5e05
--- /dev/null
+++ b/paste-ui/src/App.css
@@ -0,0 +1,38 @@
+.App {
+ text-align: center;
+}
+
+.App-logo {
+ height: 40vmin;
+ pointer-events: none;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .App-logo {
+ animation: App-logo-spin infinite 20s linear;
+ }
+}
+
+.App-header {
+ background-color: #282c34;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ font-size: calc(10px + 2vmin);
+ color: white;
+}
+
+.App-link {
+ color: #61dafb;
+}
+
+@keyframes App-logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
diff --git a/paste-ui/src/App.js b/paste-ui/src/App.js
new file mode 100644
index 0000000..215de9c
--- /dev/null
+++ b/paste-ui/src/App.js
@@ -0,0 +1,20 @@
+import './style.css';
+
+import List from './list';
+import View from './view';
+
+import MovingDot from './stateExample';
+
+
+function App() {
+ let asdf = "aasdf";
+ return (
+ <div className="container">
+ <List></List>
+
+ <View id="dZ3mGNs"></View>
+ </div>
+ );
+}
+
+export default App;
diff --git a/paste-ui/src/App.test.js b/paste-ui/src/App.test.js
new file mode 100644
index 0000000..1f03afe
--- /dev/null
+++ b/paste-ui/src/App.test.js
@@ -0,0 +1,8 @@
+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();
+});
diff --git a/paste-ui/src/api.js b/paste-ui/src/api.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/paste-ui/src/api.js
diff --git a/paste-ui/src/index.css b/paste-ui/src/index.css
new file mode 100644
index 0000000..ec2585e
--- /dev/null
+++ b/paste-ui/src/index.css
@@ -0,0 +1,13 @@
+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;
+}
+
+code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+ monospace;
+}
diff --git a/paste-ui/src/index.js b/paste-ui/src/index.js
new file mode 100644
index 0000000..d563c0f
--- /dev/null
+++ b/paste-ui/src/index.js
@@ -0,0 +1,17 @@
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import './index.css';
+import App from './App';
+import reportWebVitals from './reportWebVitals';
+
+const root = ReactDOM.createRoot(document.getElementById('root'));
+root.render(
+ <React.StrictMode>
+ <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();
diff --git a/paste-ui/src/list.js b/paste-ui/src/list.js
new file mode 100644
index 0000000..9371367
--- /dev/null
+++ b/paste-ui/src/list.js
@@ -0,0 +1,46 @@
+import { useState } from "react";
+import { useEffect } from "react";
+
+
+export default function List() {
+ const [error, setError] = useState(null);
+ const [isLoaded, setIsLoaded] = useState(false);
+ const [items, setItems] = useState([]);
+
+ // Note: the empty deps array [] means
+ // this useEffect will run once
+ // similar to componentDidMount()
+ useEffect(() => {
+ fetch("http://localhost:6130/api/v1/list")
+ .then(res => res.json())
+ .then(
+ (result) => {
+ setIsLoaded(true);
+ setItems(result);
+ },
+ // Note: it's important to handle errors here
+ // instead of a catch() block so that we don't swallow
+ // exceptions from actual bugs in components.
+ (error) => {
+ setIsLoaded(true);
+ setError(error);
+ }
+ )
+ }, [])
+
+ if (error) {
+ return <div>Error: {error.message}</div>;
+ } else if (!isLoaded) {
+ return <div>Loading...</div>;
+ } else {
+ return (
+ <ul>
+ {items.map(item => (
+ <li>
+ ID: {item.id} Size: {item.size}
+ </li>
+ ))}
+ </ul>
+ );
+ }
+} \ No newline at end of file
diff --git a/paste-ui/src/reportWebVitals.js b/paste-ui/src/reportWebVitals.js
new file mode 100644
index 0000000..5253d3a
--- /dev/null
+++ b/paste-ui/src/reportWebVitals.js
@@ -0,0 +1,13 @@
+const reportWebVitals = onPerfEntry => {
+ if (onPerfEntry && onPerfEntry instanceof Function) {
+ import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+ getCLS(onPerfEntry);
+ getFID(onPerfEntry);
+ getFCP(onPerfEntry);
+ getLCP(onPerfEntry);
+ getTTFB(onPerfEntry);
+ });
+ }
+};
+
+export default reportWebVitals;
diff --git a/paste-ui/src/setupTests.js b/paste-ui/src/setupTests.js
new file mode 100644
index 0000000..8f2609b
--- /dev/null
+++ b/paste-ui/src/setupTests.js
@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';
diff --git a/paste-ui/src/stateExample.js b/paste-ui/src/stateExample.js
new file mode 100644
index 0000000..91fee18
--- /dev/null
+++ b/paste-ui/src/stateExample.js
@@ -0,0 +1,32 @@
+import { useState } from 'react';
+export default function MovingDot() {
+ const [position, setPosition] = useState({
+ x: 0,
+ y: 0
+ });
+ return (
+ <div
+ onPointerMove={e => {
+ setPosition({
+ x: e.clientX,
+ y: e.clientY
+ });
+ }}
+ style={{
+ position: 'relative',
+ width: '100vw',
+ height: '100vh',
+ }}>
+ <div style={{
+ position: 'absolute',
+ backgroundColor: 'red',
+ borderRadius: '50%',
+ transform: `translate(${position.x}px, ${position.y}px)`,
+ left: -10,
+ top: -10,
+ width: 20,
+ height: 20,
+ }} />
+ </div>
+ );
+} \ No newline at end of file
diff --git a/paste-ui/src/style.css b/paste-ui/src/style.css
new file mode 100644
index 0000000..472b18c
--- /dev/null
+++ b/paste-ui/src/style.css
@@ -0,0 +1,71 @@
+nav {
+ border-bottom: 3px solid #000;
+ padding-bottom: 10px;
+}
+a {
+ text-decoration: none;
+ color: #268bd2;
+}
+a:visited {
+ color: #d22653;
+}
+a:hover {
+ text-decoration: underline;
+}
+
+code {
+ color: #9672d5;
+ /* background-color: #ff000020; */
+ /* padding: 2px; */
+ font-size: .8em;
+ font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace";
+}
+
+pre code {
+ color: #000;
+ background-color: #FFFFEA;
+ display: block;
+ padding: 10px;
+ border: 1px solid;
+ line-height: 1.1;
+ overflow: auto;
+}
+
+
+blockquote {
+ border-left: 4px solid #aaa;
+ padding-left: 1em;
+}
+
+/*
+ * The following was shamelessly ripped from:
+ * http://bettermotherfuckingwebsite.com/
+ * And subsequently modified to suit my needs
+ */
+
+body {
+ margin: 40px auto;
+ max-width: 80%;
+ line-height: 1.6;
+ font-size: 1em;
+ color: #444;
+ padding: 0 10px;
+ /* Added because some browsers don't default to white */
+ background-color: #fff;
+}
+
+img {
+ width: 100%;
+ height: auto;
+}
+
+h1,h2,h3 {
+ line-height: 1.2
+}
+
+@media screen and (min-width: 960px) {
+ body {
+ max-width: 768px;
+ }
+}
+
diff --git a/paste-ui/src/view.js b/paste-ui/src/view.js
new file mode 100644
index 0000000..e3bf0df
--- /dev/null
+++ b/paste-ui/src/view.js
@@ -0,0 +1,54 @@
+import { useState } from "react";
+import { useEffect } from "react";
+
+
+export default function View(props) {
+ const [error, setError] = useState(null);
+ const [isLoaded, setIsLoaded] = useState(false);
+ const [item, setItems] = useState([]);
+
+ // Note: the empty deps array [] means
+ // this useEffect will run once
+ // similar to componentDidMount()
+ useEffect(() => {
+ fetch("http://localhost:6130/api/v1/view/" + props.id)
+ .then(res => res.json())
+ .then(
+ (result) => {
+ setIsLoaded(true);
+ setItems(result);
+ },
+ // Note: it's important to handle errors here
+ // instead of a catch() block so that we don't swallow
+ // exceptions from actual bugs in components.
+ (error) => {
+ setIsLoaded(true);
+ setError(error);
+ }
+ )
+ }, [])
+
+ if (error) {
+ return <div>Error: {error.message}</div>;
+ } else if (!isLoaded) {
+ return <div>Loading...</div>;
+ } else {
+ if ('Code' in item && item.Code != 200) {
+ return (
+ <p>
+ Error: {item.Code} {item.Msg}
+ </p>
+ );
+ }
+ return (
+ <div className="content">
+ <h2>ID: {props.id}</h2>
+ <pre>
+ <code>
+ {item.Content}
+ </code>
+ </pre>
+ </div>
+ );
+ }
+} \ No newline at end of file