]> git.draconx.ca Git - homepage.git/blobdiff - content/style.scss
Attempt to improve focus ring styles in modern browsers.
[homepage.git] / content / style.scss
index 912fe4aa7796124d590af0929587a1dd08b8c594..d53717d9d0f692a02d356d0cb5c27574b981d1a8 100644 (file)
@@ -1,7 +1,7 @@
-/*
+/*!
  * Nick's web site: default stylesheet
  *
- * Copyright © 2018-2021 Nick Bowler
+ * Copyright © 2018-2022 Nick Bowler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +32,8 @@ $annotationcolour:  #708090;
 
 $tableshadecolour:  #f5f5f5;
 
+$focusringcolour: #628cb2;
+
 @mixin header_size($maxwidth, $fontsize) {
     font-size: $fontsize;
     max-width: 1em * ($maxwidth / $fontsize);
@@ -44,15 +46,56 @@ body {
     margin: 1em;
 }
 
-a:link { color: $linkdefaultcolour; }
-a:visited { color: $linkvisitedcolour; }
-a:active { color: $linkactivecolour; }
+a:link { color: $linkdefaultcolour; border-color: $linkdefaultcolour; }
+a:visited { color: $linkvisitedcolour; border-color: $linkvisitedcolour; }
+a:active { color: $linkactivecolour; border-color: $linkactivecolour; }
+
+@supports (outline-style: auto) {
+    a:link { border-width: 0; }
+    a:focus { outline: auto $focusringcolour; }
+    li, td, dt { &>a:link { border: solid 1px transparent; } }
+}
 
 h1 { @include header_size(60em, 2em); }
 h2 { @include header_size(60em, 1.5em); }
 h5 { @include header_size(60em, 1em); }
 
-p>img { max-width: 40em; width: 100%; height: auto; }
+@supports (display: grid) {
+    .gallery {
+        display: grid;
+        grid-column-gap: 1em;
+        grid-template-columns: repeat( auto-fill, minmax(18em, 1fr) );
+        align-items: center;
+
+        p.img { margin: 0.5em 0; }
+    }
+}
+
+p.img {
+    text-align: center;
+
+    img {
+        vertical-align: bottom;
+        max-width: 40em;
+        width: 100%;
+        height: auto;
+    }
+
+    a {
+        text-decoration: none;
+        display: inline-block;
+        border: solid 2px;
+    }
+
+    small {
+        color: $foregroundcolour;
+        text-align: justify;
+        @media (max-width: 24em) { text-align: left; }
+        padding: 0.5ex;
+        display: block;
+        font-size: 0.9em;
+    }
+}
 
 p, dt, dd, li {
     text-align: justify;
@@ -240,10 +283,6 @@ $clickynames: name, date, size;
             }
         }
 
-        &:focus ~ table th.clicky-#{$col}>label~label>span:first-child {
-            border-color: $foregroundcolour;
-        }
-
         // Unhide to allow keyboard navigation
         display: block !important;
         pointer-events: none;
@@ -264,50 +303,61 @@ $clickynames: name, date, size;
             }
         }
 
-        &:focus ~ table th.clicky-#{$col}>label~label .svg {
-            border-color: $foregroundcolour;
-        }
-
         pointer-events: none;
         position: absolute;
         opacity: 0;
         z-index: -2;
     }
 
-    th.clicky-#{$col}>label {
-        white-space: nowrap;
-        cursor: pointer;
-        line-height: 1.5em;
+    $focuslabel: ":focus ~ table th.clicky-#{$col}>label~label";
+    #{"input.clicky-#{$col+$focuslabel}"}>span:first-child
+    , #{"input.clicky-#{$col}-rev#{$focuslabel}"} .svg
+    {
+        border-color: $foregroundcolour;
+        @at-root { @supports (outline-style: auto) { & {
+            border-color: transparent;
+            outline: auto $focusringcolour;
+        }}}
+    }
+}
 
-        &>* {
-            display: -moz-inline-box;
-            display: inline-block;
-            border: 1px dotted transparent;
-            vertical-align: middle;
-        }
+thead.clicky label {
+    white-space: nowrap;
+    line-height: 1.5em;
+    cursor: pointer;
 
-        // Expand the first label a bit so the table (hopefully)
-        // does not reshape as columns are selected.
-        &:first-child {
-            margin-right: 1.75em;
-            padding-right: 2px;
-        }
+    &>* {
+        display: -moz-inline-box;
+        display: inline-block;
+        border: 1px dotted transparent;
+        vertical-align: middle;
+    }
 
-        &:active { color: $linkactivecolour; }
-        &:first-child:active>span, &~label:active>.svg {
-            border-color: $linkactivecolour;
-        }
+    // Expand the first label a bit so the table (hopefully)
+    // does not reshape as columns are selected.
+    &:first-child {
+        margin-right: 1.75em;
+        padding-right: 2px;
+    }
 
-        .svg {
-            margin-left: 0.25em;
-        }
+    &:active { color: $linkactivecolour; }
+    &:first-child:active>span, &~label:active>.svg {
+        border-color: $linkactivecolour;
+        @at-root { @supports (outline-style: auto) { & {
+            border-color: transparent;
+            outline: auto $focusringcolour;
+        }}}
+    }
 
-        .svg, svg, img.svgfallback {
-            height: 1.5em;
-            width: auto;
-        }
-        .svg svg { width: 1.5em; }
+    .svg {
+        margin-left: 0.25em;
+    }
+
+    .svg, svg, img.svgfallback {
+        height: 1.5em;
+        width: auto;
     }
+    .svg svg { width: 1.5em; }
 }
 
 table.filelist {
@@ -319,6 +369,7 @@ table.filelist {
 
     tbody {
         .svg, svg, img.svgfallback {
+            vertical-align: middle;
             height: 1.5em;
             width: auto;
         }
@@ -366,6 +417,8 @@ table.filelist {
 #footer p { color: $annotationcolour; }
 #article-info p { font-style: italic; }
 
+.wbr:after { content: "\200b"; }
+
 // "unordered" lists with explicit ordering in content
 ul.ordered > {
     li { list-style: none; }