Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

60
LINES

< > BotCompany Repo | #1032364 // HHamburgerIcon

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3449L/19K).

sclass HHamburgerIcon {
  S moreContent = "";
  
  S css() {
    ret [[
      .hamburger-menu {
        cursor: pointer;
        position: absolute;
        right: 10px;
        top: 10px;
      }
      
      .hamburger-menu .bar1, .hamburger-menu .bar2, .hamburger-menu .bar3 {
        width: 35px;
        height: 5px;
        background-color: #333;
        margin: 6px 0;
        transition: 0.4s;
        
        /* glowing outline? */
        border: 2px solid #dadada;
        border-radius: 5px;
      }
      
      .hamburger-menu-open .bar1 {
        -webkit-transform: rotate(-45deg) translate(-9px, 6px);
        transform: rotate(-45deg) translate(-9px, 6px);
      }
      
      .hamburger-menu-open .bar2 {opacity: 0;}
      
      .hamburger-menu-open .bar3 {
        -webkit-transform: rotate(45deg) translate(-13px, -13px);
        transform: rotate(45deg) translate(-13px, -13px);
      }
    ]];
  }
  
  S html() {
    ret hcss(css()) + htmlOnly();
  }
  
  S htmlOnly() {
    ret div(
      inner(),
      class := "hamburger-menu",
      onclick := onclick());
  }
  
  swappable S inner() {
    ret emptydiv(class := "bar1")
      + emptydiv(class := "bar2")
      + emptydiv(class := "bar3")
      + moreContent;
  }
  
  swappable S onclick() {
    ret [[this.classList.toggle("hamburger-menu-open");]];
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032364
Snippet name: HHamburgerIcon
Eternal ID of this version: #1032364/14
Text MD5: 697aee01b937eca68a8db1ef189fb21e
Transpilation MD5: 9709ed37d445493aae16d34fbf1bfea1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-01 16:44:18
Source code size: 1400 bytes / 60 lines
Pitched / IR pitched: No / No
Views / Downloads: 179 / 324
Version history: 13 change(s)
Referenced in: [show references]