Browse Source

Fix HTML examples template tabs

Tab labels now follow their drawer again. Also, to avoid tabs covering
up code or debugging logs, the tab label that's on top (and therefore
not automatically hidden behind the other drawer when that drawer
opens) will now automatically hide itself when the other drawer is
opened.
Semphris 7 months ago
parent
commit
dcc645e413
1 changed files with 16 additions and 4 deletions
  1. 16 4
      examples/template.html

+ 16 - 4
examples/template.html

@@ -76,8 +76,8 @@
       }
       }
 
 
       #output-container::before {
       #output-container::before {
-        position: fixed;
-        bottom: 0;
+        position: absolute;
+        bottom: 100%;
         right: 1rem;
         right: 1rem;
 
 
         content: 'Console';
         content: 'Console';
@@ -134,8 +134,8 @@
       }
       }
 
 
       #source-code::before {
       #source-code::before {
-        position: fixed;
-        bottom: 0;
+        position: absolute;
+        bottom: 100%;
         left: 1rem;
         left: 1rem;
 
 
         content: 'Source code';
         content: 'Source code';
@@ -143,6 +143,10 @@
         background: linear-gradient(to bottom, #789, #e0eaee);
         background: linear-gradient(to bottom, #789, #e0eaee);
         padding: 0.75rem 1.5rem;
         padding: 0.75rem 1.5rem;
         border-radius: 0.5rem 0.5rem 0 0;
         border-radius: 0.5rem 0.5rem 0 0;
+
+        /* Used for a hack to avoid tab labels showing on top of tabs; see
+           comment below for details. */
+        transition: bottom 0.25s;
       }
       }
 
 
       #source-code:hover,
       #source-code:hover,
@@ -164,6 +168,14 @@
         overflow: scroll;
         overflow: scroll;
       }
       }
 
 
+      /* Hack: Sinze z-index only goes one way, and both tab labels should be
+         behind each other's tab, put the former on top (higher z-index) and
+         make the latter one disappear when the former is hovered. */
+      #output-container:hover ~ #source-code::before,
+      #output-container:focus-within ~ #source-code::before {
+        bottom: -100%;
+      }
+
       @media (prefers-color-scheme: dark) {
       @media (prefers-color-scheme: dark) {
         main > #sidebar {
         main > #sidebar {
           border-color: rgba(48, 54, 61, 0.7);
           border-color: rgba(48, 54, 61, 0.7);