From: VladImpaler Date: Wed, 12 Apr 2023 17:25:04 +0000 (-0600) Subject: Versión del botón que abre el aside en la versión móvil X-Git-Url: https://git.josue.xyz/?p=salamandradevs.site%2F.git;a=commitdiff_plain;h=506456761bf0a6751b207751d28da1a8c40ffd67 Versión del botón que abre el aside en la versión móvil --- diff --git a/themes/droda/assets/css/main.css b/themes/droda/assets/css/main.css index 5201461..1576bc9 100644 --- a/themes/droda/assets/css/main.css +++ b/themes/droda/assets/css/main.css @@ -79,19 +79,21 @@ body { } aside { + position: absolute; + inset: 0 50%; grid-area: aside; display: none; flex-flow: column nowrap; align-items: flex-start; justify-content: flex-start; - width: 100%; + width: 50%; padding: 0 1rem; background-color: var(--bgColorDark); } aside .item { display: flex; - flex-flow: row nowrap; + flex-flow: column nowrap; align-items: center; justify-content: space-between; font-size: 1.5rem; @@ -122,7 +124,7 @@ nav div img:first-child { } nav ul { - display: flex; + display: none; flex-flow: row nowrap; align-items: center; justify-content: flex-end; @@ -164,6 +166,29 @@ nav a { text-decoration: none; } +nav button { + display: flex; + position: absolute; + width: 4rem; + height: 4rem; + right: 0.4rem; + + background-image: url('../images/menu.png'); + background-color: transparent; /* Cuando usamos background-image se pone el background-color en blanco por default por eso le indicamos que sea transparente para que se pueda ver la imagen. */ + background-position: top left; + background-repeat: no-repeat; + background-size: cover; + + border: none; + + transition: background-image ease 0.2s; + +} + +nav button[data-visible="true"] { + background-image: url('../images/menu-abierto.png'); +} + main { grid-area: main; padding: 2rem; @@ -236,29 +261,6 @@ footer { margin: 0 auto; } -.boton-movil { - display: flex; - position: relative; - width: 4rem; - height: 4rem; - right: 0.4rem; - - background-image: url('../images/menu.png'); - background-color: transparent; /* Cuando usamos background-image se pone el background-color en blanco por default por eso le indicamos que sea transparente para que se pueda ver la imagen. */ - background-position: top left; - background-repeat: no-repeat; - background-size: cover; - - border: none; - - transition: background-image ease 0.2s; - -} - -.boton-movil[data-visible="true"] { - background-image: url('../images/menu-abierto.png'); -} - @media screen and (min-width: 780px) { :root { --globalScale: 1.5; @@ -272,11 +274,18 @@ footer { "footer footer"; } - aside { + nav ul { display: flex; } - .boton-movil { + aside { + display: flex; + position: relative; + width: 100%; + inset: 0; + } + + nav button, aside li a { display: none; } diff --git a/themes/droda/assets/js/main.js b/themes/droda/assets/js/main.js index 1315b0c..37ebccc 100644 --- a/themes/droda/assets/js/main.js +++ b/themes/droda/assets/js/main.js @@ -1,4 +1,16 @@ // CODE SECTION: greetings const title = document.querySelector("title"); +const hamButton = document.querySelector("nav button"); +const aside = document.querySelector("aside"); console.log("Gracias por visitar a " + title.innerHTML); + +hamButton.addEventListener("click", (e)=>{ + if(e.target.attributes[0].nodeValue === 'true'){ + e.target.attributes[0].nodeValue = false; + aside.setAttribute("style", "display: none"); + } else { + e.target.attributes[0].nodeValue = true; + aside.setAttribute("style", "display: flex"); + } +}); diff --git a/themes/droda/layouts/_default/baseof.html b/themes/droda/layouts/_default/baseof.html index cbd82f8..87d2040 100644 --- a/themes/droda/layouts/_default/baseof.html +++ b/themes/droda/layouts/_default/baseof.html @@ -12,7 +12,7 @@ {{ "" | safeHTML }} {{ $mainScript := resources.Get "js/main.js" }} - + {{ "" | safeHTML }} {{ range .Site.Params.plugins.js }} diff --git a/themes/droda/layouts/partials/aside.html b/themes/droda/layouts/partials/aside.html index 6708725..c084298 100644 --- a/themes/droda/layouts/partials/aside.html +++ b/themes/droda/layouts/partials/aside.html @@ -5,4 +5,7 @@ {{ .Pre }}{{ .Name }} {{ end }} + {{ range .Site.Sections }} +
  • {{ .Title }}
  • + {{ end }} diff --git a/themes/droda/layouts/partials/boton.html b/themes/droda/layouts/partials/boton.html deleted file mode 100644 index 4606e06..0000000 --- a/themes/droda/layouts/partials/boton.html +++ /dev/null @@ -1,8 +0,0 @@ -{{ "" | safeHTML }} - \ No newline at end of file diff --git a/themes/droda/layouts/partials/navbar.html b/themes/droda/layouts/partials/navbar.html index fd8dced..1bfa934 100644 --- a/themes/droda/layouts/partials/navbar.html +++ b/themes/droda/layouts/partials/navbar.html @@ -7,6 +7,6 @@ {{ range .Site.Sections }}
  • {{ .Title }}
  • {{ end }} - {{ partial "boton.html" . }} +