Explorar el Código

07.03.2023 18:45

Volddemar4ik hace 1 año
padre
commit
7e0b1b3486

+ 21 - 34
js/Project/project/src/App.js

@@ -6,16 +6,13 @@ import { Provider, connect, useDispatch, useSelector } from 'react-redux';
 import { store } from './components/redux/index';
 import createHistory from "history/createBrowserHistory";
 
-
-// импорт структуры страницы
-import AsideMenu from './components/pages/structure/aside_menu';
-
 // импорт страниц
 import { CUser } from './components/user';
 import { ReduxFeed } from './components/feed';
 import { CComments } from './components/post';
 import { CreatePost } from './components/create_post';
-import Header from './components/header';
+import Header from './components/structure/header';
+import Footer from './components/structure/footer';
 
 // url проекта
 export const url = 'http://hipstagram.node.ed.asmer.org.ua/graphql'
@@ -49,35 +46,21 @@ function App() {
         <Provider store={store}>
             <Router history={history}>
                 <div className="wrapper">
-
-                    {/* <AsideMenu /> */}
-                    <section style={{ width: '50%', margin: '0 auto', minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
-                        {/* <main style={{ backgroundColor: '#dcdbff', flex: '1 1 auto' }}> */}
-                        <Header />
-
-                        <main style={{ flexGrow: '1' }}>
-                            {/* <Header /> */}
-
-                            {/* прописывание редиректа */}
-                            {/* <Redirect from='/direct' to='/profile' /> */}
-
-                            <Switch>
-                                <Route path="/autorization" component={Autorization} />
-                                <Route path="/user/:userId" component={CUser} />
-
-                                <Route path="/registration" component={Registration} />
-                                <Route path="/" component={ReduxFeed} exact />
-                                <Route path="/createpost" component={CreatePost} />
-                                <Route path="/about" component={PageAbout} />
-                                <Route path="/post/:postId" component={CComments} />
-
-
-                                <Route path="*" component={Page404} />
-                                {/* <Page404 /> - это аналог записи выше */}
-                            </Switch>
-                        </main>
-                        <footer style={{ backgroundColor: '#dbffe7', flexShrink: '0' }}>Hipstagram from Volddemar4ik</footer>
-                    </section>
+                    <Header />
+                    <main style={{ flexGrow: '1' }}>
+                        <Switch>
+                            <Route path="/autorization" component={Autorization} />
+                            <Route path="/user/:userId" component={CUser} />
+                            <Route path="/registration" component={Registration} />
+                            <Route path="/" component={ReduxFeed} exact />
+                            <Route path="/createpost" component={CreatePost} />
+                            <Route path="/about" component={PageAbout} />
+                            <Route path="/post/:postId" component={CComments} />
+                            <Route path="*" component={Page404} />
+                            {/* <Page404 /> - это аналог записи выше */}
+                        </Switch>
+                    </main>
+                    <Footer />
                 </div>
             </Router >
         </Provider >
@@ -85,3 +68,7 @@ function App() {
 }
 
 export default App;
+
+
+//прописывание редиректа
+//<Redirect from='/direct' to='/profile' />

+ 7 - 0
js/Project/project/src/components/feed/aboutMe.js

@@ -0,0 +1,7 @@
+function AboutMe() {
+    return (
+        <div>Тут будет информация о моем профиле</div>
+    )
+}
+
+export default AboutMe

+ 26 - 11
js/Project/project/src/components/feed/index.js

@@ -10,28 +10,43 @@ import Paper from '@mui/material/Paper';
 import { styled } from '@mui/material/styles';
 
 import { actionfindPosts } from '../redux/action';
-
 import { RecipeReviewCard as Card } from './card';
+import { Container } from '@mui/system';
+import AboutMe from './aboutMe';
+
 
 
 // сам item для поста
+// const Item = styled(Paper)(({ theme }) => ({
 const Item = styled(Paper)(({ theme }) => ({
-    backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
-    width: 500
+    padding: '0 10px',
+    borderRadius: 0,
+    boxShadow: 'none'
 }))
+// })
+
+
 
 function Feed({ feed = [] }) {
     return (
-        <Box sx={{
-            width: '500',
-            height: '600',
-            margin: '10, 20'
+        <Container sx={{
+            width: '80%',
+            mt: 1
         }}>
-            {/* spacing - это отступ между карточками в ленте */}
-            <Stack spacing={1}>
-                {feed.map(post => <Item key={post._id}><Card postData={post} /></Item>)}
+            {/* тут будет лента новостей */}
+            <Stack direction="row" spacing={2}>
+                <Item sx={{
+                    width: 500
+                }}>
+                    <Stack>
+                        {feed.map(post => <Item key={post._id}><Card postData={post} /></Item>)}
+                    </Stack>
+                </Item>
+                <Item>
+                    <AboutMe />
+                </Item>
             </Stack>
-        </Box >
+        </Container>
     )
 }
 

+ 0 - 107
js/Project/project/src/components/header/index.js

@@ -1,107 +0,0 @@
-import React, { useState } from 'react';
-import AppBar from '@mui/material/AppBar';
-import Box from '@mui/material/Box';
-import Toolbar from '@mui/material/Toolbar';
-import IconButton from '@mui/material/IconButton';
-import Typography from '@mui/material/Typography';
-import Menu from '@mui/material/Menu';
-import Container from '@mui/material/Container';
-import Avatar from '@mui/material/Avatar';
-import Tooltip from '@mui/material/Tooltip';
-import MenuItem from '@mui/material/MenuItem';
-import InstagramIcon from '@mui/icons-material/Instagram';
-import { connect } from 'react-redux';
-
-const settings = ['Профиль', 'Выйти'];
-
-
-// отрисовываем логин
-const UserName = ({ login }) => <div> {login}</div>
-const CUserName = connect(state => ({ login: state.auth.payload?.sub?.login }))(UserName)
-
-
-
-
-function ResponsiveAppBar() {
-    const [anchorElUser, setAnchorElUser] = useState(null);
-
-    const handleOpenUserMenu = (event) => {
-        setAnchorElUser(event.currentTarget);
-    };
-
-    const handleCloseUserMenu = () => {
-        setAnchorElUser(null);
-    };
-
-    // const consolling = () => {
-    //     console.log('click')
-    //     // < Redirect to = '/' />
-    // }
-
-    return (
-        <AppBar position="sticky" top='0' color='inherit'>
-            <Container maxWidth="xl">
-                <Toolbar disableGutters>
-
-                    <InstagramIcon sx={{ display: { xs: 'flex' }, mr: 1 }} />
-
-                    <Typography
-                        variant="h6"
-                        noWrap
-                        component="a"
-                        href="/"
-                        sx={{
-                            mr: 2,
-                            display: { xs: 'none', md: 'flex' },
-                            fontFamily: 'monospace',
-                            fontWeight: 700,
-                            letterSpacing: '.3rem',
-                            color: 'inherit',
-                            textDecoration: 'none',
-                        }}
-                    >
-                        Hipstagram
-
-                        {/* отрисовка логина */}
-                        <CUserName />
-
-                    </Typography>
-
-                    <Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }} />
-
-                    <Box sx={{ flexGrow: 0 }}>
-                        <Tooltip title="Настройки">
-                            <IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
-                                <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
-                            </IconButton>
-                        </Tooltip>
-                        <Menu
-                            sx={{ mt: '45px' }}
-                            id="menu-appbar"
-                            anchorEl={anchorElUser}
-                            anchorOrigin={{
-                                vertical: 'top',
-                                horizontal: 'right',
-                            }}
-                            keepMounted
-                            transformOrigin={{
-                                vertical: 'top',
-                                horizontal: 'right',
-                            }}
-                            open={Boolean(anchorElUser)}
-                            onClose={handleCloseUserMenu}
-                        >
-                            {settings.map((setting) => (
-                                // <MenuItem key={setting} onClick={handleCloseUserMenu}>
-                                <MenuItem key={setting} onClick={handleCloseUserMenu}>
-                                    <Typography textAlign="center">{setting}</Typography>
-                                </MenuItem>
-                            ))}
-                        </Menu>
-                    </Box>
-                </Toolbar>
-            </Container>
-        </AppBar>
-    );
-}
-export default ResponsiveAppBar;

+ 24 - 0
js/Project/project/src/components/structure/footer.js

@@ -0,0 +1,24 @@
+import { Typography } from "@mui/material"
+import { Container } from "@mui/system"
+
+function Footer() {
+    return (
+        <footer>
+            <Container>
+                <Typography
+                    gutterBottom
+                    textAlign='center'
+                    sx={{
+                        mt: 10, // тут каждая единица - это 8px
+                        color: 'inherit',
+                    }}>
+                    Project created by @Volddemar4ik
+                </Typography>
+            </Container >
+        </footer>
+    )
+}
+
+export default Footer
+
+

+ 189 - 0
js/Project/project/src/components/structure/header.js

@@ -0,0 +1,189 @@
+import React, { useState } from 'react';
+import AppBar from '@mui/material/AppBar';
+import Box from '@mui/material/Box';
+import Toolbar from '@mui/material/Toolbar';
+import IconButton from '@mui/material/IconButton';
+import Typography from '@mui/material/Typography';
+import Menu from '@mui/material/Menu';
+import Container from '@mui/material/Container';
+import Avatar from '@mui/material/Avatar';
+import Tooltip from '@mui/material/Tooltip';
+import MenuItem from '@mui/material/MenuItem';
+import InstagramIcon from '@mui/icons-material/Instagram';
+import { connect } from 'react-redux';
+
+// отрисовываем логин
+const UserName = ({ login }) => <span>{login}</span>
+const CUserName = connect(state => ({ login: state.auth.payload?.sub?.login }))(UserName)
+
+function ResponsiveAppBar() {
+    const [anchorElUser, setAnchorElUser] = useState(null);
+
+    const handleOpenUserMenu = (event) => {
+        setAnchorElUser(event.currentTarget);
+    };
+
+    const handleCloseUserMenu = () => {
+        setAnchorElUser(null);
+    };
+
+    // const consolling = () => {
+    //     console.log('click')
+    //     // < Redirect to = '/' />
+    // }
+
+    // return (
+    //     <AppBar position="sticky" top='0' color='inherit'>
+    //         <Container maxWidth="xl">
+    //             <Toolbar disableGutters>
+
+    //                 <InstagramIcon sx={{ display: { xs: 'flex' }, mr: 1 }} />
+
+    //                 <Typography
+    //                     variant="h6"
+    //                     noWrap
+    //                     component="a"
+    //                     href="/"
+    //                     sx={{
+    //                         mr: 2,
+    //                         display: { xs: 'none', md: 'flex' },
+    //                         fontFamily: 'monospace',
+    //                         fontWeight: 700,
+    //                         letterSpacing: '.3rem',
+    //                         color: 'inherit',
+    //                         textDecoration: 'none',
+    //                     }}
+    //                 >
+    //                     Hipstagram
+
+    //                     {/* отрисовка логина */}
+    //                     {/* <CUserName /> */}
+
+    //                 </Typography>
+
+    //                 <Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }} />
+
+    //                 <Box sx={{ flexGrow: 0 }}>
+    //                     <Tooltip >
+    //                         <IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
+    //                             <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
+    //                         </IconButton>
+    //                     </Tooltip>
+    //                     <Menu
+    //                         sx={{ mt: '45px' }}
+    //                         id="menu-appbar"
+    //                         anchorEl={anchorElUser}
+    //                         anchorOrigin={{
+    //                             vertical: 'top',
+    //                             horizontal: 'right',
+    //                         }}
+    //                         keepMounted
+    //                         transformOrigin={{
+    //                             vertical: 'top',
+    //                             horizontal: 'right',
+    //                         }}
+    //                         open={Boolean(anchorElUser)}
+    //                         onClose={handleCloseUserMenu}
+    //                     >
+    //                         {/* {settings.map((setting) => (
+    //                             // <MenuItem key={setting} onClick={handleCloseUserMenu}>
+    //                             <MenuItem key={setting} onClick={handleCloseUserMenu}>
+    //                                 <Typography textAlign="center">{setting}</Typography>
+    //                             </MenuItem>
+    //                         ))} */}
+    //                         <MenuItem key={1} onClick={() => console.log('click user')}>
+    //                             <Typography textAlign="center">
+    //                                 <CUserName />
+    //                             </Typography>
+    //                         </MenuItem>
+    //                         <MenuItem key={2} onClick={() => console.log('click user')}>
+    //                             <Typography textAlign="center">
+    //                                 Выйти
+    //                             </Typography>
+    //                         </MenuItem>
+
+    //                     </Menu>
+    //                 </Box>
+    //             </Toolbar>
+    //         </Container>
+    //     </AppBar >
+    // );
+
+
+    return (
+        <AppBar position='sticky' color='inherit'>
+            <Container maxWidth="xl">
+                <Toolbar disableGutters>
+                    <IconButton edge='start'>
+                        <InstagramIcon sx={{
+                            display: { xs: 'flex' },
+                            mr: 1,
+                            color: 'black'
+                        }} />
+                    </IconButton>
+                    <Typography
+                        variant="h6"
+                        noWrap
+                        component="a"
+                        href="/"
+                        sx={{
+                            display: { xs: 'none', md: 'flex' },
+                            fontFamily: 'monospace',
+                            fontWeight: 700,
+                            letterSpacing: '.3rem',
+                            color: 'inherit',
+                            textDecoration: 'none',
+                            flexGrow: '1'
+                        }}
+                    >
+                        Hipstagram
+                    </Typography>
+                    <Box sx={{ flexGrow: 0 }}>
+                        <Tooltip >
+                            <IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
+                                <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
+                            </IconButton>
+                        </Tooltip>
+                        <Menu
+                            sx={{ mt: '45px' }}
+                            id="menu-appbar"
+                            anchorEl={anchorElUser}
+                            anchorOrigin={{
+                                vertical: 'top',
+                                horizontal: 'right',
+                            }}
+                            keepMounted
+                            transformOrigin={{
+                                vertical: 'top',
+                                horizontal: 'right',
+                            }}
+                            open={Boolean(anchorElUser)}
+                            onClose={handleCloseUserMenu}
+                        >
+                            <MenuItem key={1} onClick={() => console.log('click user')}>
+                                <Typography textAlign="center">
+                                    <CUserName />
+                                </Typography>
+                            </MenuItem>
+                            <MenuItem key={2} onClick={() => console.log('click logout')}>
+                                <Typography textAlign="center">
+                                    <span>Выйти</span>
+                                </Typography>
+                            </MenuItem>
+
+                        </Menu>
+                    </Box>
+                </Toolbar>
+            </Container>
+        </AppBar>
+    )
+}
+
+export default ResponsiveAppBar;
+
+
+
+
+
+
+

+ 8 - 0
js/Project/project/src/index.css

@@ -10,6 +10,14 @@ body {
   height: 100%;
 }
 
+.wrapper {
+  max-width: 60%;
+  margin: 0 auto;
+  display: flex;
+  min-height: 100vh;
+  flex-direction: column;
+}
+
 code {
   font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
     monospace;