Skip to content

Commit

Permalink
feat: dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
a7v8x committed Jan 20, 2024
1 parent 99783de commit 6aa09d0
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 68 deletions.
65 changes: 65 additions & 0 deletions dropdown-menu-06/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dropdown Menu 06</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Poppins&display=swap"
rel="stylesheet"
>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav class="dropdown">
<button class="main-item">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" aria-labelledby="market-insights-icon" aria-hidden="true" role="img"
stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<title id="market-insights-icon">Market Insight Icon</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 12m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" /><path d="M9 8m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" /><path d="M15 4m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" /><path d="M4 20l14 0" />
</svg>
Market Insights
<svg
xmlns="http://www.w3.org/2000/svg"
class="expand-icon"
aria-labelledby="exp-icon"
role="img"
aria-hidden="true"
width="44"
height="44"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<title id="exp-icon">Expand/Collapse Menu</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M9 6l6 6l-6 6" />
</svg>
</button>
<ul>
<li>
<a href="#market-trends">
Market Trends
</a>
</li>
<li>
<a href="#expert-analysis">
Expert Analysis
</a>
</li>
<li>
<a href="#event-calendar">
Event Calendar
</a>
</li>
</ul>
</nav>
<script src="script.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions dropdown-menu-06/index_socials.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dropdown Menu 06</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Poppins&display=swap"
rel="stylesheet"
>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav class="dropdown">
<button class="main-item">
<!-- svg market -->
Market Insights
<!-- svg down icon -->
</button>
<ul>
<li>
<a href="#market-trends">
Market Trends
</a>
</li>
<li>
<a href="#expert-analysis">
Expert Analysis
</a>
</li>
<li>
<a href="#event-calendar">
Event Calendar
</a>
</li>
</ul>
</nav>
<script src="script.js"></script>
</body>
</html>

14 changes: 14 additions & 0 deletions dropdown-menu-06/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mainItems = document.querySelectorAll(
'.main-item'
);

mainItems.forEach((mainItem) => {
mainItem.addEventListener('click', () => {
mainItem.classList.toggle(
'main-item--open'
);
})
});



158 changes: 158 additions & 0 deletions dropdown-menu-06/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@


:root {
--background: #121826;
--primary-item: #FEFEFE;
--background-item: #121826;
--background-item-hover: #292F3B;
--item-non-hover: #FEFEFE;
--text-link: #C9CDD2;
--text-link-accent: #DADBDE;
--line-color: #222836;
}

html {
font-size: 16px;
font-family: "Poppins", sans-serif;
}

body {
background: var(--background);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}

* {
box-sizing: border-box;
}

.dropdown {
min-width: 10rem;
width: 100%;
max-width: 16rem;
padding: 1rem;
border-radius: 1rem;
overflow: hidden;
background-color: var(
--background-item
);
}

.main-item {
padding: 0.5rem;
display: flex;
cursor: pointer;
align-items: center;
justify-content: start;
border-radius: 0.5rem;
user-select: none;
font-size: 1rem;
font-family: 'Poppins', sans-serif;
gap: 1rem;
border: none;
width: 100%;
background: var(--background-item);
transition: all ease-in-out 0.25s;
color: var(--item-non-hover);
}

.main-item:hover {
background-color: var(
--background-item-hover
);
color: var(--item-non-hover);
}

.main-item svg {
stroke: var(--item-non-hover);
transition: all ease-in-out 0.25s;
}

.main-item:hover svg {
stroke: var(--primary-item);
}

.main-item--open {
border-radius: 8px;
transition: all 200ms;
color: var(--primary-item);
}

.main-item--open:hover {
color: var(--primary-item);
border-radius: 8px;
background-color: var(
--background-item-hover);
}

.main-item--open svg {
stroke: var(--primary-item);
}

.dropdown > ul {
max-height: 0px;
list-style-type: none;
margin: 0px;
padding-left: 14px;
opacity: 0;
font-size: smaller;
visibility: hidden;
transition: all ease-in-out 0.2s;
}

.main-item--open + ul {
visibility: visible;
max-height: 400px;
padding-left: 22px;
opacity: 1;
display: flex;
align-items: center;
flex-direction: column;
}

.dropdown > ul > li {
height: 48px;
display: flex;
width: 100%;
font-size: 0.9rem;
align-items: center;
border-left: 2px solid var(--line-color);
}

.dropdown > ul > li > a {
color: var(--item-non-hover);
padding: 1rem 0.75rem;
height: 2.4rem;
line-height: 2.4rem;
display: flex;
align-items: center;
text-decoration: none;
border-radius: 0.5rem;
margin-left: 1rem;
width: 100%;
}

.dropdown > ul > li:hover {
color: var(--primary-item);
cursor: pointer;
}

.dropdown > ul > li:hover > a {
color: var(--primary-item);
background: var(--background-item-hover);
width: 100%;
}

.expand-icon {
width: 1.5rem;
height: 1.5rem;
margin-left: auto;
transform: rotate(90deg);
}

.main-item--open > .expand-icon {
transform: rotate(-90deg);
}

25 changes: 14 additions & 11 deletions sidebar-07/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,29 @@
</a>
</div>
<button class="expand-btn" type="button">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-labelledby="exp-btn" role="img">
<title id="exp-btn">Expand/Collapse Menu</title>
<path d="M6.00979 2.72L10.3565 7.06667C10.8698 7.58 10.8698 8.42 10.3565 8.93333L6.00979 13.28"
stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
<div class="search__wrapper">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" aria-labelledby="search-icon" role="img">
<title id="search-icon">Search</title>
<path
d="M9 9L13 13M5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333Z"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<input type="text">
<input type="text" aria-labelledby="search-icon">
</div>
<div class="sidebar-links">
<ul>
<li>
<a href="#dashboard" title="Dashboard" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-layout-dashboard" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M4 4h6v8h-6z" />
<path d="M4 16h6v4h-6z" />
Expand All @@ -57,7 +59,7 @@
<a href="#market-overview" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-chart-bar" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M3 12m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" />
<path d="M9 8m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" />
Expand All @@ -72,7 +74,7 @@
<a href="#analytics" title="Analytics" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-chart-pie" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M10 3.2a9 9 0 1 0 10.8 10.8a1 1 0 0 0 -1 -1h-6.8a2 2 0 0 1 -2 -2v-7a.9 .9 0 0 0 -1 -.8" />
<path d="M15 3.5a9 9 0 0 1 5.5 5.5h-4.5a1 1 0 0 1 -1 -1v-4.5" />
Expand All @@ -86,7 +88,7 @@
<a href="#reports" title="Reports" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-report-analytics" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2" />
<path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" />
Expand All @@ -102,7 +104,7 @@
<a href="#industries" title="Industries" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-building-factory-2" width="24"
height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M3 21h18" />
<path d="M5 21v-12l5 4v-4l5 4h4" />
Expand All @@ -117,7 +119,7 @@
<li>
<a href="#settings" title="Settings" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path
d="M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z">
Expand All @@ -132,7 +134,7 @@
<a href="#notifications" title="Notifications" class="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-bell" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-hidden="true">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6" />
<path d="M9 17v1a3 3 0 0 0 6 0v-1" />
Expand All @@ -155,7 +157,8 @@
<a href="#logout" class="logout hide">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-logout" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
stroke-linejoin="round" aria-labelledby="logout-icon" role="img">
<title id="logout-icon">log out</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"></path>
<path d="M9 12h12l-3 -3"></path>
Expand Down
Loading

0 comments on commit 6aa09d0

Please sign in to comment.