From 793095820081a658ca6b68933ab4ec8f3e7640d7 Mon Sep 17 00:00:00 2001 From: Dave Snider Date: Mon, 12 Mar 2018 10:41:48 -0700 Subject: [PATCH] code cleanup --- src-docs/src/components/guide_components.scss | 2 + src-docs/src/views/guidelines/colors.js | 51 +++++++++++-------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src-docs/src/components/guide_components.scss b/src-docs/src/components/guide_components.scss index b22c9facc9ae..e35b7bd7de03 100644 --- a/src-docs/src/components/guide_components.scss +++ b/src-docs/src/components/guide_components.scss @@ -150,6 +150,8 @@ $guideZLevelHighest: $euiZLevel9 + 1000; } } + +@import "../views/guidelines/index"; @import "guide_section/index"; @import "guide_rule/index"; diff --git a/src-docs/src/views/guidelines/colors.js b/src-docs/src/views/guidelines/colors.js index 78318a4416b4..ca162a3ee99b 100644 --- a/src-docs/src/views/guidelines/colors.js +++ b/src-docs/src/views/guidelines/colors.js @@ -45,6 +45,27 @@ const allowedColors = [ 'euiColorAccent', ] +const ratingAAA = AAA; + +const ratingAA = AA; + +const ratingAA18 = AA18; + +function renderPaletteColor(color, index) { + return ( + +
+
+

{color}

+ +

RGB {lightColors[color].r}, {lightColors[color].g}, {lightColors[color].b}

+ +

HEX {rgbToHex(lightColors[color].rgba).toUpperCase()}

+
+ + ); +} + export default() => ( @@ -61,16 +82,7 @@ export default() => ( {allowedColors.map(function(color, index) { - -
-
-

{color}

- -

RGB {lightColors[color].r}, {lightColors[color].g}, {lightColors[color].b}

- -

HEX {rgbToHex(lightColors[color].rgba).toUpperCase()}

-
- + return renderPaletteColor(color, index); })} @@ -90,16 +102,15 @@ export default() => (

Rating definitions

  • - AAA{' '} - Passes with a contrast of 7+ + {ratingAAA} Passes with a contrast of 7+
  • AA{' '} - Passes with a contrast of 4.5+ + {ratingAA} Passes with a contrast of 4.5+
  • AA18{' '} - Passes with a contrast of 3+, but only if the text displayed is 18px or larger + {ratingAA18} Passes with a contrast of 3+, but only if the text displayed is 18px or larger
@@ -124,21 +135,21 @@ export default() => ( contrastRating = (
- AAA + {ratingAAA}
); } else if (contrast > 4.4) { contrastRating = (
- AA + {ratingAA}
); } else if (contrast >= 2.9) { contrastRating = (
- AA18 + {ratingAA18}
); } @@ -155,7 +166,7 @@ export default() => ( -
+
{color2} @@ -168,7 +179,7 @@ export default() => ( -
+
{color} @@ -179,7 +190,7 @@ export default() => ( } >
-
+
Text
{contrastRating}