Browse Source

basic configuration for react

Rostyslav Nahornyi 2 years ago
parent
commit
45fdf20add

+ 23 - 0
.gitignore

@@ -28,3 +28,26 @@ build/Release
 # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
 node_modules
 
+# 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*

File diff suppressed because it is too large
+ 27606 - 0
package-lock.json


+ 40 - 0
package.json

@@ -0,0 +1,40 @@
+{
+  "name": "audio-player",
+  "version": "0.1.0",
+  "private": true,
+  "dependencies": {
+    "@testing-library/jest-dom": "^5.16.4",
+    "@testing-library/react": "^13.1.1",
+    "@testing-library/user-event": "^13.5.0",
+    "react": "^18.0.0",
+    "react-dom": "^18.0.0",
+    "react-router-dom": "^6.3.0",
+    "react-scripts": "5.0.1",
+    "styled-components": "^5.3.5",
+    "web-vitals": "^2.1.4"
+  },
+  "scripts": {
+    "start": "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


+ 43 - 0
public/index.html

@@ -0,0 +1,43 @@
+<!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>

BIN
public/logo192.png


BIN
public/logo512.png


+ 25 - 0
public/manifest.json

@@ -0,0 +1,25 @@
+{
+  "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"
+}

+ 3 - 0
public/robots.txt

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

+ 19 - 0
src/App.js

@@ -0,0 +1,19 @@
+import React from "react";
+import { BrowserRouter, Routes, Route } from "react-router-dom";
+import { Home, Playlists, Profile, Queue, Tracks } from "./Pages";
+
+const App = () => {
+    return (
+        <BrowserRouter>
+            <Routes>
+                <Route path="/" element={<Home />} />
+                <Route path="profile" element={<Profile />} />
+                <Route path="queue" element={<Queue />} />
+                <Route path="tracks" element={<Tracks />} />
+                <Route path="playlists" element={<Playlists />} />
+            </Routes>
+        </BrowserRouter>
+    );
+};
+
+export default App;

+ 9 - 0
src/Components/LeftBar/LeftBar.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const LeftBar = () => {
+  return (
+    <div>LeftBar</div>
+  )
+}
+
+export default LeftBar

+ 8 - 0
src/Components/Profile/Profile.jsx

@@ -0,0 +1,8 @@
+import LeftBar from './LeftBar/LeftBar';
+import Profile from './Profile/Profile';
+
+
+export {
+    LeftBar,
+    Profile,
+}

+ 0 - 0
src/Components/index.js


+ 9 - 0
src/Pages/Home/Home.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Home = () => {
+  return (
+    <div>Home</div>
+  )
+}
+
+export default Home

+ 9 - 0
src/Pages/Playlists/Playlists.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Playlists = () => {
+  return (
+    <div>Playlists</div>
+  )
+}
+
+export default Playlists

+ 9 - 0
src/Pages/Profile/Profile.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Profile = () => {
+  return (
+    <div>Profile</div>
+  )
+}
+
+export default Profile

+ 9 - 0
src/Pages/Queue/Queue.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Queue = () => {
+  return (
+    <div>Queue</div>
+  )
+}
+
+export default Queue

+ 9 - 0
src/Pages/Tracks/Tracks.jsx

@@ -0,0 +1,9 @@
+import React from 'react'
+
+const Tracks = () => {
+  return (
+    <div>Tracks</div>
+  )
+}
+
+export default Tracks

+ 13 - 0
src/Pages/index.js

@@ -0,0 +1,13 @@
+import Home from './Home/Home';
+import Profile from './Profile/Profile';
+import Queue from './Queue/Queue';
+import Tracks from './Tracks/Tracks';
+import Playlists from './Playlists/Playlists';
+
+export {
+    Home, 
+    Profile,
+    Queue,
+    Tracks,
+    Playlists,
+}

+ 6 - 0
src/index.js

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

+ 1 - 0
src/utils/constants.js

@@ -0,0 +1 @@
+const backendURL = "http://player.node.ed.asmer.org.ua";

+ 18 - 0
src/utils/getGQL.js

@@ -0,0 +1,18 @@
+export const getGQL = (url) => (query, variables) => {
+    fetch(url, {
+        method: "POST",
+        headers: {
+            "Content-Type": "application/json",
+            ...(localStorage.authToken
+                ? { Authorization: "Bearer " + localStorage.authToken }
+                : {}),
+        },
+        body: JSON.stringify({ query, variables }),
+    })
+        .then((res) => res.json())
+        .then((data) => {
+            if (data.data) {
+                return Object.values(data.data)[0];
+            } else throw new Error(JSON.stringify(data.errors));
+        });
+};