-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from kacper-cyra/km38/ui/main-menu-settings#28
Add MainMenu Component
- Loading branch information
Showing
7 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,3 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
"presets": ["@parcel/babel-preset-env"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,51 @@ | ||
import * as classes from './style.module.scss'; | ||
|
||
export const MAIN_MENU_COMPONENT_NAME = 'main-menu-component'; | ||
|
||
const optionsNames = ['People', 'Vehicles', 'Starships']; | ||
|
||
class MainMenu extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this._contents = new DocumentFragment(); | ||
|
||
this.options = optionsNames.map((optionName) => { | ||
return MainMenu.addOptions(optionName); | ||
}); | ||
this.options[0].classList.add(classes.active); | ||
|
||
this.nav = MainMenu.addNavBar(); | ||
this.options.forEach((element) => { | ||
this.nav.appendChild(element); | ||
}); | ||
|
||
this._contents.appendChild(this.nav); | ||
} | ||
|
||
connectedCallback() { | ||
this.appendChild(this._contents); | ||
} | ||
|
||
static addNavBar() { | ||
const nav = document.createElement('nav'); | ||
nav.id = classes.mainMenu; | ||
return nav; | ||
} | ||
|
||
static addOptions(text) { | ||
const option = document.createElement('div'); | ||
option.className = classes.options; | ||
option.textContent = text; | ||
option.addEventListener('click', (e) => { | ||
const lastActiveElement = e.target.parentNode.querySelector( | ||
`.${classes.active}`, | ||
); | ||
lastActiveElement.classList.remove(classes.active); | ||
e.target.classList.add(classes.active); | ||
}); | ||
return option; | ||
} | ||
} | ||
|
||
customElements.get(MAIN_MENU_COMPONENT_NAME) || | ||
customElements.define(MAIN_MENU_COMPONENT_NAME, MainMenu); |
This file contains 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,48 @@ | ||
@use '../../themes/theme.scss' as *; | ||
|
||
#mainMenu { | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
height: 8rem; | ||
box-shadow: $red-box-shadow; | ||
border-radius: $border-radius; | ||
} | ||
|
||
div .active { | ||
color: #202020; | ||
&::after { | ||
content: ''; | ||
border-radius: 4px; | ||
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25), | ||
4px 4px 40px rgba(255, 0, 0, 0.9); | ||
background-color: #df4b4b; | ||
clip-path: inset(0 0 0 0); | ||
} | ||
} | ||
|
||
.options { | ||
position: relative; | ||
color: #979797; | ||
font-size: 2em; | ||
font-weight: bold; | ||
transition: all 0.3s ease-in-out; | ||
user-select: none; | ||
&:hover { | ||
color: $red-color; | ||
cursor: pointer; | ||
} | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
bottom: -8px; | ||
left: 0; | ||
z-index: 2; | ||
display: block; | ||
width: 100%; | ||
height: 0.5rem; | ||
background-color: #fe6666; | ||
clip-path: inset(0 100% 0 0); | ||
transition: all 0.5s ease-in-out; | ||
} | ||
} |
This file contains 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 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,3 +1,5 @@ | ||
$red-box-shadow: 4px 4px 40px 0px #ff0000e5, 0px 4px 4px 0px #00000040; | ||
$red-color: #ff0000e5; | ||
|
||
$red-box-shadow: 4px 4px 40px 0px $red-color, 0px 4px 4px 0px #00000040; | ||
|
||
$border-radius: 16px; |