-
Notifications
You must be signed in to change notification settings - Fork 0
[MG_A1_01]: Add header layout #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | ||
|
manasgulatiJoshTech marked this conversation as resolved.
|
||
|
|
||
| /** fetch required data and append it to necessary container | ||
| * | ||
| * @param {Array} arr | ||
| * @param {HTMLElement} element | ||
| * @param {Container} container | ||
| */ | ||
|
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; | ||
|
manasgulatiJoshTech marked this conversation as resolved.
|
||
| container.prepend(a); | ||
|
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); | ||
|
manasgulatiJoshTech marked this conversation as resolved.
|
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @forward './breakpoint'; | ||
| @forward './function'; | ||
| @forward './mixin'; | ||
| @forward './color'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @forward './reset'; | ||
| @forward './typography'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @forward './button'; | ||
| @forward './cards'; | ||
| @forward './chip'; | ||
| @forward './icon'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class organgeHue?