Skip to content

Commit

Permalink
Basic Mobile Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
steffest committed Apr 11, 2023
1 parent d5cc91d commit d115a31
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 4 deletions.
2 changes: 2 additions & 0 deletions _img/hamburger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions _script/ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ let Menu = function(){
}

me.close = function(){
if (container) container.classList.remove("active");
me.deActivateMenu();
}

function generate(){
$div("hamburger menuitem","",container,()=>{
container.classList.toggle("active");
})
items.forEach((item,index)=>{
item.element = $link("menuitem main handle",item.label,container,(e) =>{
me.activateMenu(index);
Expand Down
6 changes: 6 additions & 0 deletions _script/ui/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ var Modal = function(){
if (dialog){
let width = data.width || dialog.width || 440;
let height = data.height || dialog.height || 260;

let maxWidth = window.innerWidth - 20;
let maxHeight = window.innerHeight - 20;
if (width > maxWidth) width = maxWidth;
if (height > maxHeight) height = maxHeight;

modalWindow.style.width = width + "px";
modalWindow.style.height = height + "px";
let top = 'calc(50vh - ' + (height>>1) + 'px)';
Expand Down
6 changes: 5 additions & 1 deletion _style/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
height: 25px;
background-color: $panel-background-color;
color: $menu-text-color;
z-index: 10;
z-index: 1000;
user-select: none;
white-space: nowrap;

.hamburger{
display: none;
}

a.main{
position: relative;
display: inline-block;
Expand Down
62 changes: 62 additions & 0 deletions _style/_mobile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@media only screen and (max-width: 800px) {
.menu{
width: 100px;
height: auto;
top: 27px;
border: none;

.hamburger{
display: block;
background-image: url("../_img/hamburger.svg");
width: 32px;
height: 27px;
background-size: 24px 24px;
background-repeat: no-repeat;
background-position: center center;
position: absolute;
top: -27px;
}

a.main{
display: none;
font-size: 13px;
border: 1px solid black;
border-bottom: none;
padding: 2px 10px;

&:last-child{
border-bottom: 1px solid black;
}

.sub{
left: 100px;
top: 0;

a{
font-size: 13px;
border-bottom: 1px solid rgba(0, 0, 0, 0.4);
padding: 2px 20px 2px 10px;

&:last-child{
border-bottom: none;
}

&.wide{
padding: 2px 80px 2px 10px;
}

&.ultrawide{
padding: 2px 100px 2px 10px
}
}
}
}


&.active{
a.main{
display: block;
}
}
}
}
56 changes: 55 additions & 1 deletion _style/main.css

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

2 changes: 1 addition & 1 deletion _style/main.css.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion _style/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ h1.error{
@import "cursor";
@import "modal";
@import "fileBrowser";
@import "uae";
@import "uae";
@import "mobile";

0 comments on commit d115a31

Please sign in to comment.