From 1821c724fd0d4a3ebee4d2580c0cf82931e6fe0d Mon Sep 17 00:00:00 2001 From: Martin Giger Date: Tue, 17 Oct 2023 11:02:28 +0100 Subject: [PATCH] Bug 1858656 - Update storybook color documentation. r=aleca Differential Revision: https://phabricator.services.mozilla.com/D190786 --HG-- extra : amend_source : 8bf75ee4eabe073c8fc48ca839f9957749c89a19 extra : histedit_source : bc4116b2e2ea0c81bf748b4aa124a2a93298f496 --- .../storybook/stories/colors.stories.mjs | 79 +++++++++++++++---- 1 file changed, 64 insertions(+), 15 deletions(-) diff --git a/mail/components/storybook/stories/colors.stories.mjs b/mail/components/storybook/stories/colors.stories.mjs index a61c49a560..2abf390237 100644 --- a/mail/components/storybook/stories/colors.stories.mjs +++ b/mail/components/storybook/stories/colors.stories.mjs @@ -14,18 +14,19 @@ const FORMATTER = new Intl.NumberFormat("en", { const VARIANT_RANGE = { white: [], - gray: [10, 90], - red: [30, 90], - orange: [30, 90], - amber: [30, 90], + black: [], + gray: [5, 10, 90], + red: [10, 90], + orange: [10, 90], + amber: [10, 90], yellow: [30, 90], - green: [30, 90], - teal: [30, 90], - blue: [0, 90], - purple: [0, 90], - magenta: [30, 90], - brown: [30, 90], - ink: [30, 90], + green: [10, 90], + teal: [10, 90], + blue: [10, 90], + purple: [10, 90], + magenta: [10, 90], + brown: [10, 90], + ink: [10, 90], }; const ALL_COLORS = Object.entries(VARIANT_RANGE).flatMap(([color, range]) => { @@ -33,7 +34,12 @@ const ALL_COLORS = Object.entries(VARIANT_RANGE).flatMap(([color, range]) => { return [color]; } const colors = []; - for (let variant = range[0]; variant <= range[1]; variant += 10) { + let start = 0; + while (range[start] < 10) { + colors.push(`${color}-${FORMATTER.format(range[start])}`); + ++start; + } + for (let variant = range[start]; variant <= range[start + 1]; variant += 10) { colors.push(`${color}-${FORMATTER.format(variant)}`); } return colors; @@ -61,7 +67,7 @@ function createColor(colorName) { preview.style.width = "200px"; preview.style.height = "50px"; preview.style.background = `var(${cssVariableName})`; - const legend = document.createElement("span"); + const legend = document.createElement("code"); legend.textContent = cssVariableName; color.append(preview, legend); return color; @@ -70,20 +76,63 @@ function createColor(colorName) { export const Colors = { render: () => { const container = document.createElement("div"); + container.insertAdjacentHTML( + "afterbegin", + "

Color variables provided by chrome://messenger/skin/colors.css:

" + ); container.append(...ALL_COLORS.map(createColor)); return container; }, }; -const Template = ({ color1, color2 }) => html` +const CompareTemplate = ({ color1, color2 }) => html`
`; -export const CompareColors = Template.bind({}); +export const CompareColors = CompareTemplate.bind({}); CompareColors.args = { color1: "white", color2: "ink-90", }; + +const TextContrastTemplate = ({ color1, color2 }) => html` +
+

+ Consectetur voluptatem voluptatibus nihil nobis dignissimos suscipit et + odio. Ipsa sequi ad aperiam officia aut maxime. Voluptas qui et + repellendus corrupti. Libero nihil in corrupti non dolorem. +

+

+ Eligendi eligendi deleniti necessitatibus. Tempore ipsam illum cumque. + Excepturi ex explicabo et. +

+

+ Aut sequi consequuntur asperiores non. Corporis quos reprehenderit + consequuntur sint. Ipsa numquam sint id non tempore doloremque. Nam + quibusdam blanditiis nostrum. Ducimus autem nesciunt quam officia sunt et. +

+

+ Recusandae facere laudantium ad quas tenetur non vel ullam. Voluptas hic + dicta itaque doloribus repellendus impedit laborum. Illum velit + dignissimos voluptatem dolorem quo sit hic. Sequi occaecati exercitationem + non veniam sed suscipit blanditiis consequatur. Facere eum eaque fugiat + esse quisquam qui dolor et. +

+

+ Ut et perspiciatis recusandae recusandae. Voluptate temporibus quia + voluptas cumque. Sint ut qui mollitia fugiat omnis qui distinctio. Numquam + expedita amet quas velit consequatur laborum. Eius officiis modi unde + earum voluptas est sed. +

+
+`; +export const TextContrast = TextContrastTemplate.bind({}); +TextContrast.args = { + color1: "white", + color2: "ink-90", +};