diff --git a/README.md b/README.md index 58beeac..e0276b5 100755 --- a/README.md +++ b/README.md @@ -1,70 +1,19 @@ -# Getting Started with Create React App +React-приложение "Сайт СКБ КИТ" для использования с WordPress. +Для работы приложения требуются: +- Wordpress с установленным плагином ReactPress +- Node.js -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +Создано с помощью create-react-app -## Available Scripts +Используемые библиотеки: +- react +- react-router-dom +- reactpress +- sass +- wpapi -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in your browser. - -The page will reload when you make changes.\ -You may also see any lint errors in the console. - -### `npm 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. - -### `npm run 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. - -### `npm run 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/). - -### Code Splitting - -This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) - -### Analyzing the Bundle Size - -This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) - -### Making a Progressive Web App - -This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) - -### Advanced Configuration - -This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) - -### Deployment - -This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) - -### `npm run build` fails to minify - -This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) +Для запуска приложения необходимо: +- поместить папку проекта в директорию /*wordpress-dir*/wp-content/reactpress/apps +- перейти в папку проекта +- установить необходимые библиотеки (npm install) +- запустить dev-build (npm start) или собрать приложение (npm run build) и открыть страницу в wordpress \ No newline at end of file diff --git a/public/index.html b/public/index.html index 6ea9a78..72ea701 100755 --- a/public/index.html +++ b/public/index.html @@ -5,9 +5,59 @@ main — skb-site +
- + + + + + + + + diff --git a/src/App.css b/src/App.css deleted file mode 100755 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.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/src/App.js b/src/App.js deleted file mode 100755 index 3784575..0000000 --- a/src/App.js +++ /dev/null @@ -1,25 +0,0 @@ -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); -} - -export default App; diff --git a/src/api.js b/src/api.js index e0ffa68..d962ab5 100755 --- a/src/api.js +++ b/src/api.js @@ -1,5 +1,7 @@ import * as WPAPI from 'wpapi'; +import reactPress from './reactPress'; + const wp = new WPAPI( process.env.NODE_ENV === 'development' ? { diff --git a/src/assets/react.svg b/src/assets/react.svg deleted file mode 100755 index 6c87de9..0000000 --- a/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index 84d4e2d..68eea6a 100755 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,7 +1,7 @@ import { Link } from 'react-router-dom'; -import logo from '../../assets/scb.svg' -import './Navbar.scss'; +import { scb as logo } from '../../images'; +import './Navbar.styles.scss'; function Navbar() { return ( diff --git a/src/components/Navbar/Navbar.scss b/src/components/Navbar/Navbar.styles.scss similarity index 100% rename from src/components/Navbar/Navbar.scss rename to src/components/Navbar/Navbar.styles.scss diff --git a/src/components/Navbar/index.js b/src/components/Navbar/index.js new file mode 100644 index 0000000..19cc4c1 --- /dev/null +++ b/src/components/Navbar/index.js @@ -0,0 +1 @@ +export { default } from './Navbar'; \ No newline at end of file diff --git a/src/assets/car.jpeg b/src/images/car.jpeg similarity index 100% rename from src/assets/car.jpeg rename to src/images/car.jpeg diff --git a/src/images/index.js b/src/images/index.js new file mode 100644 index 0000000..cd3a51b --- /dev/null +++ b/src/images/index.js @@ -0,0 +1,2 @@ +export { default as car } from './car.jpeg'; +export { default as scb } from './scb.svg'; \ No newline at end of file diff --git a/src/assets/scb.svg b/src/images/scb.svg similarity index 100% rename from src/assets/scb.svg rename to src/images/scb.svg diff --git a/src/index.js b/src/index.js index 7b38189..3718ce1 100755 --- a/src/index.js +++ b/src/index.js @@ -2,46 +2,11 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import { createHashRouter, RouterProvider } from 'react-router-dom'; -import Root from './routes/Root'; -import ErrorPage from './error-page'; -import Main from './routes/Main'; -import Aboutus from './routes/Aboutus'; -import Labs from './routes/Labs'; -import Projects from './routes/Projects'; -import Contact from './routes/Contact'; +import routes from './routes'; import reportWebVitals from './reportWebVitals'; -import './index.scss'; +import './index.styles.scss'; -const router = createHashRouter([ - - { - path: '/', - element: , - errorElement: , - children: [ - { - path: "/", - element:
, - }, - { - path: "/aboutus", - element: , - }, - { - path: "/labs", - element: , - }, - { - path: "/projects", - element: , - }, - { - path: "/contact", - element: , - }, - ] - }, -]) +const router = createHashRouter(routes); const root = ReactDOM.createRoot(document.getElementById('root')); root.render( diff --git a/src/index.scss b/src/index.styles.scss similarity index 100% rename from src/index.scss rename to src/index.styles.scss diff --git a/src/routes/Aboutus.jsx b/src/pages/AboutUs.jsx similarity index 81% rename from src/routes/Aboutus.jsx rename to src/pages/AboutUs.jsx index 4c333b7..96f141c 100755 --- a/src/routes/Aboutus.jsx +++ b/src/pages/AboutUs.jsx @@ -1,4 +1,4 @@ -function Aboutus() { +function AboutUs() { return ( <>
@@ -11,4 +11,4 @@ function Aboutus() { ); } -export default Aboutus; \ No newline at end of file +export default AboutUs; \ No newline at end of file diff --git a/src/routes/Contact.jsx b/src/pages/Contact.jsx similarity index 100% rename from src/routes/Contact.jsx rename to src/pages/Contact.jsx diff --git a/src/error-page.jsx b/src/pages/ErrorPage.jsx similarity index 100% rename from src/error-page.jsx rename to src/pages/ErrorPage.jsx diff --git a/src/pages/Labs.jsx b/src/pages/Labs.jsx new file mode 100755 index 0000000..2e31f5c --- /dev/null +++ b/src/pages/Labs.jsx @@ -0,0 +1,19 @@ +import Page from "./Page"; + +function Labs() { + return ( + // <> + //
+ //

Laboratories

+ //
+ //
+ + //
+ // + + + + ); +} + +export default Labs; \ No newline at end of file diff --git a/src/routes/Main.jsx b/src/pages/Main/Main.jsx similarity index 81% rename from src/routes/Main.jsx rename to src/pages/Main/Main.jsx index 3671e52..5085235 100755 --- a/src/routes/Main.jsx +++ b/src/pages/Main/Main.jsx @@ -1,6 +1,4 @@ -import News from '../components/Main/News'; -import Projects from '../components/Main/Projects'; -import Labs from '../components/Main/Labs'; +import { News, Projects, Labs } from './components'; function Main() { return ( diff --git a/src/components/Main/Labs.jsx b/src/pages/Main/components/Labs.jsx similarity index 99% rename from src/components/Main/Labs.jsx rename to src/pages/Main/components/Labs.jsx index 90d0658..97ccc3f 100644 --- a/src/components/Main/Labs.jsx +++ b/src/pages/Main/components/Labs.jsx @@ -1,6 +1,6 @@ import { Link } from 'react-router-dom'; -import './Labs.scss'; +import './Labs.styles.scss'; function Labs() { return ( diff --git a/src/components/Main/Labs.scss b/src/pages/Main/components/Labs.styles.scss similarity index 99% rename from src/components/Main/Labs.scss rename to src/pages/Main/components/Labs.styles.scss index 9d318f8..a5ba85c 100644 --- a/src/components/Main/Labs.scss +++ b/src/pages/Main/components/Labs.styles.scss @@ -45,4 +45,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/components/Main/News.jsx b/src/pages/Main/components/News.jsx similarity index 93% rename from src/components/Main/News.jsx rename to src/pages/Main/components/News.jsx index 54e14be..81a8577 100755 --- a/src/components/Main/News.jsx +++ b/src/pages/Main/components/News.jsx @@ -1,6 +1,4 @@ -import { Link } from 'react-router-dom'; - -import './News.scss'; +import './News.styles.scss'; function News() { return ( diff --git a/src/components/Main/News.scss b/src/pages/Main/components/News.styles.scss similarity index 100% rename from src/components/Main/News.scss rename to src/pages/Main/components/News.styles.scss diff --git a/src/components/Main/Projects.jsx b/src/pages/Main/components/Projects.jsx similarity index 96% rename from src/components/Main/Projects.jsx rename to src/pages/Main/components/Projects.jsx index ea7aab4..8e0891e 100755 --- a/src/components/Main/Projects.jsx +++ b/src/pages/Main/components/Projects.jsx @@ -1,6 +1,6 @@ import { Link } from 'react-router-dom'; -import './Projects.scss'; +import './Projects.styles.scss'; function Projects() { return ( diff --git a/src/components/Main/Projects.scss b/src/pages/Main/components/Projects.styles.scss similarity index 100% rename from src/components/Main/Projects.scss rename to src/pages/Main/components/Projects.styles.scss diff --git a/src/pages/Main/components/index.js b/src/pages/Main/components/index.js new file mode 100644 index 0000000..f12520f --- /dev/null +++ b/src/pages/Main/components/index.js @@ -0,0 +1,3 @@ +export { default as News } from './News'; +export { default as Projects } from './Projects'; +export { default as Labs } from './Labs'; \ No newline at end of file diff --git a/src/pages/Main/index.js b/src/pages/Main/index.js new file mode 100644 index 0000000..9b2a63e --- /dev/null +++ b/src/pages/Main/index.js @@ -0,0 +1 @@ +export { default } from './Main'; \ No newline at end of file diff --git a/src/pages/Page.jsx b/src/pages/Page.jsx new file mode 100644 index 0000000..4f557e6 --- /dev/null +++ b/src/pages/Page.jsx @@ -0,0 +1,14 @@ +function Page({ title, children }) { + return ( + <> +
+

{title}

+
+
+ {children} +
+ + ); +} + +export default Page; \ No newline at end of file diff --git a/src/routes/Projects.jsx b/src/pages/Projects.jsx similarity index 100% rename from src/routes/Projects.jsx rename to src/pages/Projects.jsx diff --git a/src/routes/Root.jsx b/src/pages/Root/Root.jsx similarity index 69% rename from src/routes/Root.jsx rename to src/pages/Root/Root.jsx index 591ada8..52ecfb4 100755 --- a/src/routes/Root.jsx +++ b/src/pages/Root/Root.jsx @@ -1,23 +1,24 @@ -import { Outlet } from "react-router-dom"; +import { Outlet, Link, useLoaderData } from "react-router-dom"; -//import { getContacts } from "../api"; -import Navbar from '../components/Navbar/Navbar'; -import './Root.scss'; +import { getContacts } from "../../api"; +import Navbar from '../../components/Navbar'; +import './Root.styles.scss'; -// async function loader() { -// const contacts = await getContacts(); -// return { contacts }; -// } +async function loader() { + const contacts = await getContacts(); + return { contacts }; +} function Root() { -// const { contacts } = useLoaderData(); + const { contacts } = useLoaderData(); return ( <>
- {/*
+ +
{contacts.length ? (
    {contacts.map(contact => ( @@ -33,10 +34,10 @@ function Root() { No contacts

    )} -
*/} +
); } -//export { loader }; +export { loader }; export default Root; \ No newline at end of file diff --git a/src/routes/Root.scss b/src/pages/Root/Root.styles.scss similarity index 97% rename from src/routes/Root.scss rename to src/pages/Root/Root.styles.scss index aead35d..2ecd683 100755 --- a/src/routes/Root.scss +++ b/src/pages/Root/Root.styles.scss @@ -14,7 +14,7 @@ $btn-dark: #585858; flex-direction: column; color: $primary-text; - background-image: url(../assets/car.jpeg); + background-image: url(/images/car.jpeg); background-color: rgba(0, 0, 0, .75); background-blend-mode: multiply; background-position: center; diff --git a/src/pages/Root/index.js b/src/pages/Root/index.js new file mode 100644 index 0000000..08297f1 --- /dev/null +++ b/src/pages/Root/index.js @@ -0,0 +1 @@ +export { default as Root, loader } from './Root'; \ No newline at end of file diff --git a/src/pages/index.js b/src/pages/index.js new file mode 100644 index 0000000..3b95243 --- /dev/null +++ b/src/pages/index.js @@ -0,0 +1,7 @@ +export { Root, loader } from './Root'; +export { default as ErrorPage} from './ErrorPage'; +export { default as Main } from './Main'; +export { default as AboutUs } from './AboutUs'; +export { default as Labs } from './Labs'; +export { default as Projects } from './Projects'; +export { default as Contact } from './Contact'; \ No newline at end of file diff --git a/src/reactPress.js b/src/reactPress.js new file mode 100644 index 0000000..9c6ab02 --- /dev/null +++ b/src/reactPress.js @@ -0,0 +1,4 @@ +const reactPress = window.reactPress; +reactPress.user.roles.push('administrator'); + +export default reactPress; \ No newline at end of file diff --git a/src/routes.js b/src/routes.js new file mode 100644 index 0000000..892d5ff --- /dev/null +++ b/src/routes.js @@ -0,0 +1,43 @@ +import { + Root, + loader as rootLoader, + ErrorPage, + Main, + AboutUs, + Labs, + Projects, + Contact +} from './pages'; + +const routes = [ + { + path: '/', + element: , + errorElement: , + loader: rootLoader, + children: [ + { + path: "/", + element:
, + }, + { + path: "/aboutus", + element: , + }, + { + path: "/labs", + element: , + }, + { + path: "/projects", + element: , + }, + { + path: "/contact", + element: , + }, + ] + }, +]; + +export default routes; \ No newline at end of file diff --git a/src/routes/Labs.jsx b/src/routes/Labs.jsx deleted file mode 100755 index ddb24ea..0000000 --- a/src/routes/Labs.jsx +++ /dev/null @@ -1,14 +0,0 @@ -function Labs() { - return ( - <> -
-

Laboratories

-
-
- -
- - ); -} - -export default Labs; \ No newline at end of file