[ToyProject-Todomate] ํˆฌ๋‘๋ฉ”์ดํŠธ ํด๋ก  ํ”„๋กœ์ ํŠธ 13

2021. 12. 19. 22:10ใ†WEB Dev/ToyProject

728x90


๐Ÿ”ท CloneTodo โ˜‘ - Todomate Clone Project  |  Team CloneMate

 

CloneTodo : ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์‚ฌ๋ž‘ํ•˜๋Š” ํˆฌ๋‘๋ฉ”์ดํŠธ๋ฅผ ํด๋ก ํ•˜์—ฌ ์›น ์„œ๋น„์Šค๋ฅผ ๋ฐฐํฌํ•ด๋ณด๋Š” ํ”„๋กœ์ ํŠธ

 


์ด์ œ ๋‘ ๊ฐœ ๋ฟŒ์‹ฌ...

 

์˜ค๋Š˜์˜ todo

 

โ˜‘ ๊ฐ€์ž…ํ•˜๊ธฐ ์ปดํฌ๋„ŒํŠธ

โ˜‘ ๊ธฐ๋ณธ NavBar ์ปดํฌ๋„ŒํŠธ

โ–ก ๋ฉ”์ธ NavBar ์ปดํฌ๋„ŒํŠธ

โ–ก ๋ฉ”์ธ Feed ์ปดํฌ๋„ŒํŠธ

 

โž• ๊ฐ€๋Šฅํ•˜๋ฉด ๊นƒํ—™ ํ˜ธ์ŠคํŒ…์œผ๋กœ ๋ฐฐํฌ๊นŒ์ง€

 

 

3. ๋ฉ”์ธ NavBar ์ปดํฌ๋„ŒํŠธ

 

๋ฉ”์ธ์€ ๊ธฐ๋ณธ๋ณด๋‹ค ์กฐ๊ธˆ ๋” ๋ณต์žกํ•œ๋ฐ ํ–„๋ฒ„๊ฑฐ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด Drawer ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋‚˜ํƒ€๋‚˜์•ผ ํ•œ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๋ฉ”์ธํŽ˜์ด์ง€์—์„œ๋Š” ๋ฉ”์ธ NavBar๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ณ  ๋‚˜๋จธ์ง€ ํŽ˜์ด์ง€์—์„œ๋Š” ์•„๊นŒ ๋งŒ๋“  BasicNavBar ๊ฐ€ ๋‚˜ํƒ€๋‚˜์•ผ ํ•œ๋‹ค.

 

- Route ๋งˆ๋‹ค NavBar ์ ์šฉํ•˜๊ธฐ

 

์‚ผํ•ญ์—ฐ์‚ฐ์ž๋ฅผ ์“ธ๊นŒ ํ–ˆ๋Š”๋ฐ, ๊ทธ๋ƒฅ Route ๋ณ„๋กœ ์ ์šฉํ•ด๋„ ๋˜๊ฒ ๋‹ค ์‹ถ์—ˆ์Œ (๊ฐœ๋ณ„ ์ปดํฌ๋„ŒํŠธ์— ๋”ฐ๋กœ ๋„ฃ์–ด๋„ ๋˜๊ณ ..)

ํ™”๋ฉด ์ƒ Main ํŽ˜์ด์ง€๋ฅผ ๋ณ„๋„๋กœ ๋งŒ๋“ค์–ด์•ผ ํ•˜๋Š”๋ฐ (์„ธ์…˜์ด ์—†๋Š” ์ƒํƒœ์—์„œ์˜ ์ฒซ ํ™”๋ฉด์ด ์•„๋‹Œ ์บ˜๋ฆฐ๋”์™€ ํ”ผ๋“œ๊ฐ€ ์žˆ๋Š” ํ™”๋ฉด)

์•„์ง Main์„ ์งœ์ง€ ๋ชปํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— App.js ์ƒ๋‹จ์— ๋ถ™์—ฌ๋‘”๋‹ค.

 

 

import React from "react";
import "../stylesheets/App.css";
import { Button  } from "@mui/material";
import { ThemeProvider, createTheme } from "@mui/material/styles";
import { Switch, Route, useHistory } from "react-router-dom";
import Signin from "./Signin";
import Join from "./Join";
import BasicNavBar from "./BasicNavBar";
import MainNavBar from "./MainNavBar";


const theme = createTheme({
  components: {
    MuiTypography: {
      defaultProps: {
        variantMapping: {
          h1: 'h2',
          h2: 'h2',
          h3: 'h2',
          h4: 'h2',
          h5: 'h2',
          h6: 'h2',
          subtitle1: 'h2',
          subtitle2: 'h2',
          body1: 'span',
          body2: 'span',
        },
      },
    },
  },
  typography: {
    Link: {
      color: '#222',
    },
    bolder: {
      fontWeight: 600,
    },
    button: {

    },
  },
  palette: {
    btn: {
      main: "#f2f2f2",
      contrastText: "#111",
    },
    nav: {
      main: "#fefefe",
      contrastText: "#111",
    },
  },
});

function App() {
  let history = useHistory();

  return (
    <ThemeProvider theme={theme}>
      <Switch>
        <Route exact path="/">
        <MainNavBar/>
          <div className="App">
            <div className="header">
              <img className="main_img" src="images/todomate.jpg" />
              <h1>todo mate</h1>
              <h3>ํ•  ์ผ์„ ์ž‘์„ฑ, ๊ณ„ํš, ๊ด€๋ฆฌํ•˜์„ธ์š”.</h3>
            </div>
            <div className="start_btn">
              <Button 
                className="join_btn" 
                color="btn"
                variant="contained" 
                onClick={() => {
                  history.push("/join");
                }}
              >
                ๊ฐ€์ž…ํ•˜๊ธฐ
              </Button>
              <Button
                className="signin_btn"
                color="btn"
                variant="contained"
                onClick={() => {
                  history.push("/signin");
                }}
              >
                ๋กœ๊ทธ์ธ
              </Button>
            </div>
          </div>
        </Route>
        <Route exact path="/join">
        <BasicNavBar/>
          <Join />
        </Route>
        <Route exact path="/signin">
        <BasicNavBar/>
          <Signin />
        </Route>
        </Switch>
    </ThemeProvider>
  );
}

export default App;

 

 

์ ์  ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ธธ์–ด์ง€๊ณ  ์žˆ๋Š” ๋Š๋‚Œ์ด์ง€๋งŒ...

 

 

MainNavBar์—์„œ๋Š” ์•„์ด์ฝ˜์ด 2๊ฐœ ํ•„์š”ํ•œ๋ฐ, ์šฐ์ธก์— ๋ณด๊ด€ํ•จ ์•„์ด์ฝ˜๊ณผ ํ–„๋ฒ„๊ฑฐ ์•„์ด์ฝ˜์ด๋‹ค.

(ํ–„๋ฒ„๊ฑฐ๋Š” ≡ ์™€ ๊ฐ™์€ ์•„์ด์ฝ˜์„ ๋งํ•œ๋‹ค.)

ํ–„๋ฒ„๊ฑฐ ์•„์ด์ฝ˜์€ ๊ธฐ๋ณธ AppBar ์ปดํฌ๋„ŒํŠธ์— MenuIcon ์ด๋ผ๋Š” ํŒจํ‚ค์ง€๋กœ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ๋‚ด ๋ฆฌ์•กํŠธ์™€๋Š” ๋ฒ„์ „์ด ๋งž์ง€ ์•Š์•„ v4์˜ Dehaze๋ผ๋Š” ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. (๋ฆฌ์•กํŠธ ๋ผ์šฐํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ฒ„์ „์„ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ ํ•จ)

 

๊ทธ๋ฆฌ๊ณ  ์šฐ๋ฆฌ๋Š” ๋ณด๊ด€ํ•จ์€ ๋งŒ๋“ค์ง€ ์•Š๊ธฐ๋กœ ํ–ˆ์œผ๋‹ˆ ์•„์ด์ฝ˜์€ ํ–„๋ฒ„๊ฑฐ ํ•˜๋‚˜๋งŒ ํ•„์š”ํ•˜๋‹ค.

 

 

MainNavBar.js ์— BasicNavBar.js ์—์„œ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ด์ฃผ๊ณ ,

 

import DehazeIcon from '@material-ui/icons/Dehaze';

 

 

์œ„์˜ ํŒจํ‚ค์ง€๋ฅผ import ํ•ด์ค€๋‹ค.

๊ทธ๋ฆฌ๊ณ  Main์—์„œ๋Š” ์“ฐ์ง€ ์•Š๋Š” <NavigationBeforeIcon /> ์™€ <Typography /> ์ปดํฌ๋„ŒํŠธ๋Š” ๋นผ์ค€๋‹ค.

 

๊ทธ๋Ÿผ ์•„๋ž˜์™€ ๊ฐ™์ด ์‹ฌํ”Œํ•œ MainNavBar ์ฝ”๋“œ๊ฐ€ ์™„์„ฑ๋œ๋‹ค.

 

 

import React 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 DehazeIcon from '@material-ui/icons/Dehaze';

export default function MainNavBar () {
  return (
    <Box sx={{ flexGrow: 1 }}>
      <AppBar position="static" color="nav" sx={{ boxShadow:"none" }}>
        <Toolbar>
        <IconButton
            size="large"
            edge="start"
            color="inherit"
            aria-label="back"
            sx={{ mr: 2 }}
          >
         <DehazeIcon />
          </IconButton>
        </Toolbar>
      </AppBar>
    </Box>
  );
}

 

 

ํ–„๋ฒ„๊ฑฐ ์•„์ด์ฝ˜์€ ์šฐ์ธก์œผ๋กœ ๊ฐ€์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ฝ”๋“œ ์ˆ˜์ •์ด ํ•„์š”ํ•˜๋‹ค.

flex ์ˆœ์„œ๋ฅผ ๋ฐ”๊ฟ”์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— flexDirection : row-reverse๋ฅผ ์ค˜์•ผ ํ•˜๋Š”๋ฐ ๊ฐœ๋ฐœ์ž๋„๊ตฌ๋กœ ๋ณด๋‹ˆ AppBar ์ปดํฌ๋„ŒํŠธ์— flex-direction์„ ์ฃผ๋ฉด ๋˜์–ด์„œ AppBar ์ปดํฌ๋„ŒํŠธ์˜ sx์— flexDirection: row-reverse๋ฅผ ์ค€๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๋ฐฐ๊ฒฝ์ƒ‰์ƒ๊ฐ’๊ณผ height ๊ฐ’์„ ์›๋ณธ๊ณผ ์œ ์‚ฌํ•˜๊ฒŒ ์กฐ์ ˆํ•ด์ค€๋‹ค.

 

 
import React 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 DehazeIcon from '@material-ui/icons/Dehaze';

export default function MainNavBar () {
  return (
    <Box>
      <AppBar position="static" color="mainnav" sx={{ boxShadow:"none", flexDirection:"row-reverse", height: '90px', borderTop: '1px solid #CCCDCD', boxSizing:'border-box' }}>
        <Toolbar>
        <IconButton
            size="large"
            edge="start"
            color="inherit"
            aria-label="back"
            sx={{ mr: 2 }}
          >
         <DehazeIcon />
          </IconButton>
        </Toolbar>
      </AppBar>
    </Box>
  );
}

 

 

์ด๋ ‡๊ฒŒ ์ž…๋ ฅํ•ด์ฃผ๋ฉด

 

 

 

์ด๋ ‡๊ฒŒ ์˜ˆ์œโฃ NavBar๋ฅผ ๋งŒ๋‚  ์ˆ˜ ์žˆ๋‹ค.

 

๋‚˜๋จธ์ง€๋Š” ๋‚ด์ผ ๐Ÿ˜“๐Ÿ˜“๐Ÿ˜“๐Ÿ˜“

728x90