]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
docs(theming): display contrast ratios in color swatches
authorGaël Poupard <gael.poupard@orange.com>
Tue, 7 Apr 2020 13:59:51 +0000 (15:59 +0200)
committerGaël Poupard <ffoodd@users.noreply.github.com>
Wed, 20 May 2020 07:49:18 +0000 (09:49 +0200)
site/assets/scss/_colors.scss

index 911c44c7368b8d4d0b85b79abf9fcf125fbd1852..17c678365804b4688f87bcc98f78b75644590fad 100644 (file)
@@ -6,6 +6,37 @@
   .swatch-#{$color} {
     color: color-contrast($value);
     background-color: #{$value};
+
+    &::after {
+      $contrast-ratio: "#{contrast-ratio($value, color-contrast($value))}";
+      $against-white: "#{contrast-ratio($value, $white)}";
+      $against-black: "#{contrast-ratio($value, $black)}";
+      position: absolute;
+      top: 1rem;
+      right: 1rem;
+      padding-left: 1rem;
+      font-size: .75rem;
+      line-height: 1.35;
+      white-space: pre;
+      content:
+        str-slice($contrast-ratio, 1, 4) "\A"
+        str-slice($against-white, 1, 4) "\A"
+        str-slice($against-black, 1, 4);
+      background-color: $value;
+      background-image:
+        linear-gradient(
+          to bottom,
+          transparent .25rem,
+          color-contrast($value) .25rem .75rem,
+          transparent .75rem 1.25rem,
+          $white 1.25rem 1.75rem,
+          transparent 1.75rem 2.25rem,
+          $black 2.25rem 2.75rem,
+          transparent 2.75rem
+        );
+      background-repeat: no-repeat;
+      background-size: .5rem 100%;
+    }
   }
 }