aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaël Poupard <[email protected]>2020-04-07 15:59:51 +0200
committerGaël Poupard <[email protected]>2020-05-20 09:49:18 +0200
commita0dd474bc6486ec573e7319aa9e95862f8ca923b (patch)
tree6d4a509103d1cf277eb7cedf02c37be1b478e888
parenta7e1b914ef43fee0d309b9463f7f5bc5442845ba (diff)
downloadbootstrap-a0dd474bc6486ec573e7319aa9e95862f8ca923b.tar.xz
bootstrap-a0dd474bc6486ec573e7319aa9e95862f8ca923b.zip
docs(theming): display contrast ratios in color swatches
-rw-r--r--site/assets/scss/_colors.scss31
1 files changed, 31 insertions, 0 deletions
diff --git a/site/assets/scss/_colors.scss b/site/assets/scss/_colors.scss
index 911c44c73..17c678365 100644
--- a/site/assets/scss/_colors.scss
+++ b/site/assets/scss/_colors.scss
@@ -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%;
+ }
}
}