Skip to content

Commit

Permalink
feat: widget
Browse files Browse the repository at this point in the history
  • Loading branch information
a7v8x committed Dec 15, 2023
1 parent 3e53cd6 commit 2bb4124
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 0 deletions.
Binary file added widget-01/assets/analytics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added widget-01/assets/funds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added widget-01/assets/performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added widget-01/assets/reports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions widget-01/index-socials.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Widget</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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" type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<div class="tabs-container">
<ul class="tabs">
<li>
<a id="tab1" title="Analytics" href="#tab1">
<!-- svg icon -->
Analytics
</a>
</li>
<!-- more menu items -->
</ul>
<div class="tab-content-wrapper">
<article id="tab1-content" class="tab-content">
<h2>Analytics</h2>
<p>
Investment analytics involves the use of data, statistical techniques, and financial models to
evaluate and optimize investment decisions.
</p>
<img src="assets/analytics.png" alt="Analytics">
</article>
<!-- more content -->
</div>
</div>
<script src="script.js"></script>
</body>

</html>
123 changes: 123 additions & 0 deletions widget-01/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Widget</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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" type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<div class="tabs-container">
<ul class="tabs">
<li>
<a id="tab1" title="Analytics" href="#tab1">
<svg aria-hidden="true" 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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 3v18h18"></path>
<path d="M20 18v3"></path>
<path d="M16 16v5"></path>
<path d="M12 13v8"></path>
<path d="M8 16v5"></path>
<path d="M3 11c6 0 5 -5 9 -5s3 5 9 5"></path>
</svg>
Analytics
</a>
</li>
<li>
<a id="tab2" title="Reports" href="#tab2">
<svg aria-hidden="true" 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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M7 7m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0"></path>
<path d="M7 3v4h4"></path>
<path d="M9 17l0 4"></path>
<path d="M17 14l0 7"></path>
<path d="M13 13l0 8"></path>
<path d="M21 12l0 9"></path>
</svg>
Reports
</a>
</li>

<li>
<a id="tab3" title="Performance" href="#tab3">
<svg aria-hidden="true" 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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<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>
<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>
<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>
<path d="M4 20l14 0"></path>
</svg>
Performance
</a>
</li>
<li>
<a id="tab4" title="Funds" href="#tab4">
<svg aria-hidden="true" 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">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 21l18 0"></path>
<path d="M3 10l18 0"></path>
<path d="M5 6l7 -3l7 3"></path>
<path d="M4 10l0 11"></path>
<path d="M20 10l0 11"></path>
<path d="M8 14l0 3"></path>
<path d="M12 14l0 3"></path>
<path d="M16 14l0 3"></path>
</svg>
Funds
</a>
</li>
</ul>
<div class="tab-content-wrapper">
<article id="tab1-content" class="tab-content">
<h2>Analytics</h2>
<p>
Investment analytics involves the use of data, statistical techniques, and financial models to
evaluate and optimize investment decisions.
</p>
<img src="assets/analytics.png" alt="Analytics">
</article>
<article id="tab2-content" class="tab-content">
<h2>Reports</h2>
<p>
Investment reports provide detailed information about the status, performance, and other relevant
aspects of an investment or portfolio.
</p>
<img src="assets/reports.png" alt="Reports">

</article>
<article id="tab3-content" class="tab-content">
<h2>Performance</h2>
<p>
Investment performance refers to the returns generated on an investment relative to the amount of
money invested.
</p>
<img src="assets/performance.png" alt="Performance">
</article>
<article id="tab4-content" class="tab-content">
<h2>Funds</h2>
<p>
Investment funds are pooled collections of money from multiple investors that are managed
collectively by professionals or on behalf of the investors.
</p>
<img src="assets/funds.png" alt="Funds">

</article>
</div>
</div>
<script src="script.js"></script>
</body>

</html>
49 changes: 49 additions & 0 deletions widget-01/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const allLinks = document.querySelectorAll(".tabs a");
const allTabs = document.querySelectorAll(".tab-content");
const tabContentWrapper = document.querySelector(".tab-content-wrapper");

const shiftTabs = (linkId) => {
allTabs.forEach((tab, i) => {
if (tab.id.includes(linkId)) {
allTabs.forEach((tabItem) => {
tabItem.style = `transform: translateY(-${i * 300}px);`;
});
}
});
};

allLinks.forEach((elem) => {
elem.addEventListener("click", function () {
const linkId = elem.id;
const hrefLinkClick = elem.href;

allLinks.forEach((link, i) => {
if (link.href == hrefLinkClick) {
link.classList.add("active");
} else {
link.classList.remove("active");
}
});

shiftTabs(linkId);
});
});

//? handle proper selection for initial load
const currentHash = window.location.hash;

let activeLink = document.querySelector(`.tabs a`);

if (currentHash) {
const visibleHash = document.getElementById(
`${currentHash.replace("#", "")}`
);

if (visibleHash) {
activeLink = visibleHash;
}
}

activeLink.classList.toggle("active");

shiftTabs(activeLink.id);
127 changes: 127 additions & 0 deletions widget-01/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
:root {
--white: #FFF;
--gray: #363638;
--gray-mid: #9D9D9D;
--gray-dark: #3e3e3e;
--gray-hover: #F7F7F7;
--body-background: #1F192D;
--primary: #8543CC;
--primary-border: #42375d;
--text: #CEC0E0;
--widget-background: #3A2D54;
}

body {
font-family: 'Poppins';
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
padding: 16px;
background-color: var(--body-background);
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

.tabs-container {
padding: 16px;
width: 100%;
max-width: 480px;
min-width: 320px;
display: flex;
margin: 10px;
border-radius: 16px;
background-color: var(--widget-background);
border: 1px solid var(--primary-border);
}


.tab-content-wrapper {
overflow-y: hidden;
overflow-x: auto;
height: 300px;
transition: all 0.45s ease-in-out;
padding: 0 16px;
}

.tab-content h2 {
color: var(--white);
font-size: 1.2rem;
font-weight: 600;
margin-top: 0px;
margin-bottom: 8px;
}

.tab-content {
font-size: 0.8rem;
min-height: 300px;
min-width: 240px;

color: var(--white);
overflow-x: auto;
transition: all 0.45s ease-in-out;
}

.tab-content img {
width: 100%;
height: auto;
margin-top: 16px;
}

.tabs {
position: relative;
display: flex;
flex-direction: column;
border-right: 1px solid var(--gray);
list-style-type: none;
padding-right: 16px;
gap: 8px;
}

.tabs a {
position: relative;
display: flex;
text-decoration: none;
width: 100%;
font-size: 14px;
font-weight: 600;
text-align: left;
border-radius: 8px;
justify-content: start;
padding: 12px;
align-items: center;
gap: 8px;
color: white;
user-select: none;
border: 1px solid transparent;
transition: all 0.45s ease-in-out;
}

.tabs a img {
height: 20px;
width: 20px;
}

.tabs .active,
.tabs a:hover {
outline: none;
background-color: var(--primary);
border: 1px solid var(--primary-border);
}


.tabs a svg {
stroke: var(--white);
}

.tabs .active svg {
stroke: var(--white);
}

.tabs a:hover svg {
stroke: var(--white);
}

0 comments on commit 2bb4124

Please sign in to comment.