Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,54 @@
<title>Title</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./public/styles/main.css" />
<link
href="https://cdn.jsdelivr.net/npm/@vetixy/circular-std@1.0.0/dist/index.min.css"
rel="stylesheet"
/>
<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=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
rel="stylesheet"
/>
</head>
<body>
<header class="container">
<button
class="container__hamburger"
aria-label="Menu Closed"
type="button"
aria-expanded="false"
>
<i class="icon-menu"></i>
</button>
<div class="container__logo">
<img src="/assets/images/logo.webp" alt="Brand Logo" />
</div>
<div class="container__nav-link"></div>
<!--data fetched from context.json-->
<div class="container__nav-box">
<!--data fetched from context.json-->
<div class="container__nav-box-btn">
<button
class="button button--primary"
type="button"
></button>
<button
class="button button--secondary"
type="button"
></button>
</div>
</div>
<div class="container__btn">
<!--data fetched from context.json-->
<button class="button button--primary" type="button"></button>
<button class="button button--secondary" type="button"></button>
</div>
<div class="orangeHue">
<img src="/assets/images/Ellipse 23.webp" alt="Coloured hue" />
</div>
Comment on lines +51 to +53

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class organgeHue?

</header>
Comment thread
manasgulatiJoshTech marked this conversation as resolved.
<script type="module" src="./src/script/index.js"></script>
</body>
</html>
120 changes: 16 additions & 104 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/content.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"header": {
"nav": ["home", "discover", "special deals", "contact"],
"nav": ["contact", "special deals", "discover", "home"],
"buttons": ["log in", "sign up"]
},
"section-1": {
Expand Down
65 changes: 65 additions & 0 deletions src/script/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import '../styles/main.scss';

//get data from context.json
let data;
try {
const response = await fetch('./content.json');
data = await response.json();
} catch {
alert('Error while fetching data from backend');
}

const navLinks = data.header.nav;
const navBox = document.querySelector('.container__nav-box');
const navLink = document.querySelector('.container__nav-link');
const buttonLinksPrimary = data.header.buttons[0];
const buttonLinksSecondary = data.header.buttons[1];
const btnPrimary = document.querySelectorAll('.button--primary');
const btnSecondary = document.querySelectorAll('.button--secondary');
Comment thread
manasgulatiJoshTech marked this conversation as resolved.

/** fetch required data and append it to necessary container
*
* @param {Array} arr
* @param {HTMLElement} element
* @param {Container} container
*/
Comment thread
manasgulatiJoshTech marked this conversation as resolved.
function append(arr, element, container) {
arr.forEach((link) => {
let a = document.createElement(element);
a.setAttribute('tabindex', '1');
a.innerHTML = link;
Comment thread
manasgulatiJoshTech marked this conversation as resolved.
container.prepend(a);
Comment thread
manasgulatiJoshTech marked this conversation as resolved.
});
}

//using append() to create nav links
append(navLinks, 'a', navLink);
append(navLinks, 'a', navBox);

//adding button text
btnPrimary.forEach((btnBox) => {
btnBox.innerHTML = buttonLinksPrimary;
});
btnSecondary.forEach((btnBox) => {
btnBox.innerHTML = buttonLinksSecondary;
});

//making navBox and Button appear upon clicking on menu
const menu = document.querySelector('.container__hamburger');
const btnBox = document.querySelector('.container__nav-box-btn');
menu.addEventListener('click', () => {
navBox.classList.toggle('container__nav-box--active');
btnBox.classList.toggle('container__nav-box-btn--active');
let expand = menu.getAttribute('aria-expanded');
let ans;
let ariaLabel;
if (expand == 'true') {
ans = false;
ariaLabel = 'Menu Closed';
} else {
ans = true;
ariaLabel = 'Menu Opened';
}
menu.setAttribute('aria-expanded', ans);
menu.setAttribute('aria-label', ariaLabel);
Comment thread
manasgulatiJoshTech marked this conversation as resolved.
});
6 changes: 6 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@use './scss/abstract' as abs;
@use './scss/base';
@use './scss/components' as comp;
@use './scss/layouts';
@use './scss/themes';
@use './scss/vendors';
4 changes: 4 additions & 0 deletions src/styles/scss/abstract/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@forward './breakpoint';
@forward './function';
@forward './mixin';
@forward './color';
2 changes: 2 additions & 0 deletions src/styles/scss/base/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@forward './reset';
@forward './typography';
15 changes: 14 additions & 1 deletion src/styles/scss/components/_button.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
@use '../base/typography' as typo;
@use '../abstract/mixin' as mix;
@use '../abstract/color' as c;
@use '../themes/light' as th;
@use '../abstract/function' as f;

.button {
@include mix.flex($gap: 0.5rem, $space: center);
border-radius: 6.25rem;
border-radius: f.px-to-rem(100);
padding: 0.5rem 1rem;
max-width: f.px-to-rem(115);
@include mix.use-typo(typo.$nav-link-2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a empty line above this

&--primary {
background-color: th.$bg-primary;
color: c.$black-900;
}
&--secondary {
background-color: th.$bg-secondary;
color: c.$white-200;
}
}
2 changes: 1 addition & 1 deletion src/styles/scss/components/_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.icon {
width: 2.05rem;
height: 2.05rem;
@include mix.flex($gap: 0.25rem, $align-items: flex-start);
@include mix.flex($gap: 0.25rem, $align-item: flex-start);
padding: 0.5rem;
border-radius: 3.2rem;
&__primary {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/scss/components/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@forward './button';
@forward './cards';
@forward './chip';
@forward './icon';
Loading
Loading