๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT/Java - Spring Boot

[Spring Boot] ํŽ˜์ด์ง€์— ์‚ฌ์ด๋“œ ๋ฐ” ์ฝ”๋”ฉํ•˜๊ธฐ

by ITyranno 2023. 11. 1.
728x90
๋ฐ˜์‘ํ˜•

 

ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์„ธ๊ณ„๋ฅผ ํƒ๊ตฌํ•ฉ์‹œ๋‹ค.

 

 

Spring Boot๋ฅผ ํ™œ์šฉํ•˜์—ฌ ํŽ˜์ด์ง€์— ์‚ฌ์ด๋“œ ๋ฐ”๋ฅผ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์˜ค๋ฅธ์ชฝ์— ๋ฒˆ๊ฐœ ๋ชจ์–‘ ์ด๋ชจํ‹ฐ์ฝ˜์„ ๋ˆ„๋ฅด๋ฉด ์‚ฌ์ด๋“œ๋ฐ”๊ฐ€ ์Šฌ๋ผ์ด๋“œ ํ˜•์‹์œผ๋กœ ์—ด๋ฆฝ๋‹ˆ๋‹ค. ๋กœ๊ทธ์ธ ์ „, ํ›„์— ์ƒ์„ฑ๋˜๋Š” ํ•ญ๋ชฉ์ด ๋‹ค๋ฅด๋ฉฐ ํ•˜์œ„ ์š”์†Œ๊ฐ€ ์žˆ๋Š” ๋ชฉ๋ก์€ ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ธ์„ ๋•Œ ์‚ฌ์ด๋“œ๋ฐ”๊ฐ€ ํ•˜๋‚˜ ๋” ์—ด๋ฆฌ๋ฉด์„œ ํ•˜์œ„ ํ•ญ๋ชฉ์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์‚ฌ์ด๋“œ ๋ฐ”์˜ ์›€์ง์ž„์— ๋”ฐ๋ผ ๋ฒˆ๊ฐœ ๋ชจ์–‘ ์ด๋ชจํ‹ฐ์ฝ˜๋„ ํ•จ๊ป˜ ์›€์ง์ž…๋‹ˆ๋‹ค.

 

 

๊ตฌํ˜„ ํ™”๋ฉด

 

 

 

 

 

 

์ž‘์„ฑ ์ฝ”๋“œ

 

nav.html

 

<!DOCTYPE html>
<html>

<head>
</head>

<style>
  body {
    z-index: 100;
  }
  .menubar a {
    text-decoration: none;
  }

  .container {
    background: none;
  }

  .button {
    font-size: 50px;
    position: relative;
    right: 80px;
    top: 0px;
    width: 40px;
    height: 40px;
    z-index: 99;
    transition: 0.8s ease;
    background: none;
    border: none;
  }

  /* .x {
    align-items: center;
    color: black;
    margin: auto;
  } */

  .content {
    padding: 100px 20px 0 40px;
    position: relative;
    width: 200%;
  }

  .nav-1 {
    display: flex;
  }

  .nav-2 {
    height: 80%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
  }

  .home {
    display: flex;
    align-items: center;
    height: 22px;
  }

  .my_account {
    margin-top: -15px;
    display: flex;
    align-items: center;
    height: 32px;
    border-radius: 100%;
  }

  @font-face {
    font-family: 'Cafe24Ssurround';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/Cafe24Ssurround.woff') format('woff');
    font-weight: normal;
    font-style: normal;
  }

  .word {
    margin-left: 15px;
    margin-top: -12px;
    font-size: 25px;
    font-family: 'Cafe24Ssurround';
    color: black;
    cursor: pointer;
  }

  @media (max-width: 768px) {
    .sidebar {
      right: -300px;
      /* Move sidebar to the right */
    }

    .button {
      right: 10px;
      /* Move button to the right */
    }

    .content {
      padding-right: 20px;
      /* Adjust padding */
    }
  }

  .menubar .submenu {
    display: none;
  }

  .menubar {
    position: relative;
  }

  .submenu {
    display: none;
    position: fixed;
    top: 0;
    right: 300px;
    width: 300px;
    height: 100%;
    background-color: rgb(249, 227, 128);
    padding-top: 11rem;
  }

  .sidebar {
    background-color: rgb(237, 208, 77);
    border-left: 2px solid rgb(237, 208, 77);
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    transition: 0.4s ease;
    color: #202020;
    height: 100%;
    z-index: 99;
  }
</style>

<body>
  <div class="container">
    <div class="sidebar" style="width: 300px; height: 100%;">
      <button class="button">โšก
      </button>
      <div class="content">
        <!-- <nav class="nav">
          <div class="nav-1">
            <div class="head_logo">
              <a href="/">
                <img class="logo_text" src="car.png" alt="๋กœ๊ณ " />
              </a>
            </div>
          </div> -->
        <div class="nav-2">
          <div class="menubar">
            <a class="word" th:href="@{/}">ํ™ˆ</a>
          </div>
          <div class="menubar">
            <a class="word" th:href="@{/map}">์ถฉ์ „์†Œ ์ฐพ๊ธฐ</a>
            <!-- <div class="submenu">
              <a class="word" th:href="@{/map}">์ง€๋„</a>
              <a class="word" th:href="@{/map}">๋ชฉ๋ก ์ถ”๊ฐ€</a>
            </div> -->
          </div>
          <div class="menubar">
            <a class="word">๊ฒŒ์‹œํŒ</a>
            <div class="submenu">
              <a class="word" th:href="@{/board/list}">๊ณต์ง€์‚ฌํ•ญ</a>
              <a class="word" th:href="@{/qna/list}">Q&A</a>
            </div>
          </div>
          <div class="menubar">
            <a class="word">์ •๋ณด๋งˆ๋‹น</a>
            <div class="submenu">
              <a class="word" th:href="@{/statistic/chargerStatus}">ํ†ต๊ณ„์ •๋ณด</a>
              <a class="word" th:href="@{/statistic/ChargerExpense}">์„œ๋น„์Šค์•ˆ๋‚ด</a>
            </div>
          </div>
          <div class="menubar">
            <a class="word">๋ฏธ๋””์–ด</a>
            <div class="submenu">
              <a class="word" th:href="@{/media/news?searchText=์ „๊ธฐ์ฐจ}">์ „๊ธฐ์ฐจ ๋‰ด์Šค</a>
              <a class="word" th:href="@{/media/reels}">์ „๊ธฐ์ฐจ ์˜์ƒ</a>
              <a class="word" th:href="@{/media/gamepage}">์ „๊ธฐ์ฐจ ๊ฒŒ์ž„</a>
            </div>
          </div>
          <div class="menubar">
            <a class="word">๋ฉค๋ฒ„์‹ญ</a>
            <div class="submenu">
              <a class="word" th:href="@{/exchange}">์ฝ”์ธ๊ตํ™˜</a>
              <a class="word" th:href="@{/coupon}">์ฟ ํฐํ•จ</a>
              <br>
              <a class="word" th:href="@{/membership}">๊ฐ€์ž…ํ•˜๊ธฐ</a>
              <a th:if="${session != null and session.user_info != null and session.has_membership}" class="word" th:href="@{/mymembership}">๋‚˜์˜ ๋ฉค๋ฒ„์‹ญ</a>
            </div>
          </div>
        </div>
        <br>
        <br>
        <div th:if="${session.user_info == null}" class="menubar">
          <a th:href="@{/signin}" class="word">๋กœ๊ทธ์ธ</a>
          <a th:href="@{/signup}" class="word">ํšŒ์›๊ฐ€์ž…</a>
        </div>
          <div th:unless="${session.user_info == null}" class="menubar">
            <span class="word">[[ ${session.user_info.name} + '๋‹˜ ๋ฐ˜๊ฐ‘์Šต๋‹ˆ๋‹ค.' ]]</span>
            <br>
              <a class="word" th:href="@{/exchange}">๋‚˜์˜ ์ฐŒ๋ฆฌ๋ฆฟ: <span th:text="${userCoin}"></span>๊ฐœ</a>
            <br>
            <a th:href="@{/mypage(email=${session.user_info.email})}" class="word">Mypage</a>
            <br>
            <!-- <a th:href="${session.user_info != null and session.user_info.role == 'ADMIN'}"></a> -->
            <a th:if="${session != null and session.user_info != null and session.user_info.role == 'ADMIN'}" th:href="@{/admin}" class="word">
              Admin
            </a>
            <br>
            <a th:href="@{/signout}" class="word">๋กœ๊ทธ์•„์›ƒ</a>
          </div>
        </div>
      </div>
    </div>

  </div>
  </nav>
  </div>
  </div>
  </div>

  <script>
    const button = document.querySelector(".button");
    const sidebar = document.querySelector(".sidebar");
    let isSidebarOpen = false;
    let timeoutId;

    sidebar.style.width = "0";

    button.addEventListener("click", () => {
      if (!isSidebarOpen) {
        sidebar.style.width = "300px";
        isSidebarOpen = true;
      } else {
        sidebar.style.width = "0";
        button.style.right = "80px";
        closeSubmenus();
        isSidebarOpen = false;
      }
    });

    function closeSubmenus() {
      const submenus = document.querySelectorAll(".submenu");
      submenus.forEach((submenu) => {
        submenu.style.display = "none";
      });

      // If there's no submenu open, move the button back to right.
      if (!document.querySelector('.submenu[style*="block"]')) {
        button.style.right = "80px";
      }
    }

    const menuItems = document.querySelectorAll(".menubar");

    menuItems.forEach((menuItem) => {

      menuItem.addEventListener("mouseover", () => {

        if (isSidebarOpen) {
          closeSubmenus();
          const submenu = menuItem.querySelector(".submenu");

          if (submenu) {
            submenu.style.display = "block";
            button.style.right = "310px"; // If a submenu opens, move the button right.
          }
        }
      });

      menuItem.addEventListener("mouseout", () => {

        if (isSidebarOpen) {
          const submenu = menuItem.querySelector(".submenu");

          if (submenu && submenu.style.display === "block") {
            timeoutId = setTimeout(() => {
              submenu.style.display = "none";
              if (!document.querySelector('.submenu[style*="block"]')) { // check if there's no other opened sub-menu
                button.style.right = "80px"; // If a submenu closes, move the button back to right.
              }
            }, 1000); // wait for one second before closing the submenu
          }
        }
      });

      menuItem.addEventListener("mouseover", () => clearTimeout(timeoutId)); // if mouse comes back on item before timeout ends, clear the timeout

    });
  </script>
</body>

</html>

 

 

 

์œ„์™€ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์‚ฌ์ด๋“œ ๋ฐ”๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•

loading