(defwidget HoveredSign [var]
  (box :space-evenly false
    (revealer :reveal {!var}
      :duration "100ms"
      :transition "slideleft"
      (children :nth 0))
    (revealer :reveal {var}
      :duration "100ms"
      :transition "slideleft"
      (children :nth 1))))

(defwidget RevealOnHover [var varname ?icon ?class ?duration ?transition ?visible]
  (eventbox
    :onhover `${EWW_CMD} update ${varname}=true`
    :onhoverlost `${EWW_CMD} update ${varname}=false`
    :visible {visible}
    
    (box
      :space-evenly false
      :orientation "v"
      
      (box (label :class "icon" :text icon))
      
      (revealer
        :reveal var
        :transition {transition ?:"slidedown"}
        :duration animation-duration-fast
        (box :class "reveal-on-hover" (children :nth 0))))
  ))

(defwidget RevealOnClick [var varname direction ?class ?duration ?transition]
  (box
    :orientation "v"
    :class "widget"
    :space-evenly false
    :class "reveal-on-click"
    
    (eventbox
      :cursor "pointer"
      :visible {direction == "up"}
      :onclick `${EWW_CMD} update ${varname}=${!var}`
      
      (label :angle {direction == "up" ? (var ? 270 : 90) : (var ? 90 : 270)} :tooltip "touch control" :text ""))
    
    (revealer
      :reveal var
      :transition {direction == "up" ? "slideup" : "slidedown"}
      :duration animation-duration-fast
      
      (box :style "padding: 6px 0px" (children :nth 0)))
    
    (eventbox
      :cursor "pointer"
      :visible {direction == "down"}
      :onclick `${EWW_CMD} update ${varname}=${!var}`
      
      (label :angle {direction == "up" ? (var ? 270 : 90) : (var ? 90 : 270)} :tooltip "touch control" :text ""))
    
  ))
