diff --git a/lost-pixel/baseline/components-button-examples--growth-cta.png b/lost-pixel/baseline/components-button-examples--growth-cta.png index 0cd205b5e..2eaf7ae66 100644 Binary files a/lost-pixel/baseline/components-button-examples--growth-cta.png and b/lost-pixel/baseline/components-button-examples--growth-cta.png differ diff --git a/lost-pixel/baseline/components-button-props--color.png b/lost-pixel/baseline/components-button-props--color.png index 1b8f4e677..b56c167cb 100644 Binary files a/lost-pixel/baseline/components-button-props--color.png and b/lost-pixel/baseline/components-button-props--color.png differ diff --git a/lost-pixel/baseline/labs-pronouns--auto-complete.png b/lost-pixel/baseline/labs-pronouns--auto-complete.png index df82f2745..1eaec0c43 100644 Binary files a/lost-pixel/baseline/labs-pronouns--auto-complete.png and b/lost-pixel/baseline/labs-pronouns--auto-complete.png differ diff --git a/lost-pixel/baseline/labs-pronouns--comments.png b/lost-pixel/baseline/labs-pronouns--comments.png index 7f665da67..7f219711f 100644 Binary files a/lost-pixel/baseline/labs-pronouns--comments.png and b/lost-pixel/baseline/labs-pronouns--comments.png differ diff --git a/lost-pixel/baseline/labs-pronouns--user-settings.png b/lost-pixel/baseline/labs-pronouns--user-settings.png index 1b77694e2..cde7db00a 100644 Binary files a/lost-pixel/baseline/labs-pronouns--user-settings.png and b/lost-pixel/baseline/labs-pronouns--user-settings.png differ diff --git a/src/components/Button/Button.props.story.tsx b/src/components/Button/Button.props.story.tsx index 2ac28e9d0..9f9c8afa7 100644 --- a/src/components/Button/Button.props.story.tsx +++ b/src/components/Button/Button.props.story.tsx @@ -231,12 +231,14 @@ TextShift.storyName = 'textShift'; export function CustomColor({ args }) { return (
- - +
color="#aa91e5"
+ +
color: '#ffffff', hover: '#e7c03f', active: '#e7c03f'
+
+        color: '#000000', hover: '#e7c03f', active: '#e7c03f',
+      
+
+        color: '#ff00d4', hover: '#e72626', active: '#700d2b',
+      
+
+        color: '#ff00d4', hover: '#e72626', active: '#700d2b',
+        textColor: '#ffffff',
+      
+
); } diff --git a/src/components/Button/Button.style.ts b/src/components/Button/Button.style.ts index 3e97737e7..fd8f7565a 100755 --- a/src/components/Button/Button.style.ts +++ b/src/components/Button/Button.style.ts @@ -1,5 +1,5 @@ import styled, { css } from 'styled-components'; -import { rgba, rem, tint, shade, em } from 'polished'; +import { rgba, rem, tint, shade, em, readableColor } from 'polished'; import { borderRadii } from './Button.config'; import { FeaturedIcon } from './FeaturedIcon'; @@ -202,12 +202,14 @@ function deriveButtonColor(customColor, format, theme) { let color: string; let hoverColor: string; let activeColor: string; + let textColor: string; if (customColor) { if (typeof customColor === 'string') { color = customColor; hoverColor = tint(0.15, color); activeColor = shade(0.15, color); + textColor = readableColor(color); } else if (customColor.color) { color = customColor.color; hoverColor = customColor.hover @@ -216,14 +218,18 @@ function deriveButtonColor(customColor, format, theme) { activeColor = customColor.active ? customColor.active : shade(0.15, color); + textColor = customColor.textColor + ? customColor.textColor + : readableColor(customColor.color); } } else { color = theme.formats[format]; hoverColor = tint(0.15, color); activeColor = shade(0.15, color); + textColor = null; } - return { color, hoverColor, activeColor }; + return { color, hoverColor, activeColor, textColor }; } // const buttonVariants = memoize(buttonVariantsFn); @@ -239,21 +245,15 @@ function buttonVariants({ // style logic is rewritten. if (format.includes('upsell')) return; - const { color, hoverColor, activeColor } = deriveButtonColor( - customColor, - format, - theme - ); - - // const { saturation } = parseToHsl(color); - // const saturateAmount = saturation > 0.33 ? 0.2 : 0; + const { color, hoverColor, activeColor, textColor } = + deriveButtonColor(customColor, format, theme); const borderWidth = '1px'; const borderColor = color; - const contrastText = a11yColor(color); - const contrastTextHover = a11yColor(hoverColor); - const contrastTextActive = a11yColor(activeColor); + const contrastText = textColor || a11yColor(color); + const contrastTextHover = textColor || a11yColor(hoverColor); + const contrastTextActive = textColor || a11yColor(activeColor); switch (variant) { case 'outline': @@ -386,17 +386,6 @@ function buttonVariants({ } } -// function fluidity(sizes: number | number[]) { -// const min = rem(Math.min(...sizes)); -// const max = rem(Math.max(...sizes)); - -// return css` -// ${mediaQuery({ min, max })} { -// width: 100%; -// } -// `; -// } - const mediaQuery = ({ min = 0, max, type = 'only screen' }) => !max || min === max ? `@media ${type} and (min-width: ${em(min)})` diff --git a/src/components/Button/Button.types.ts b/src/components/Button/Button.types.ts index e73321290..7b4cb9ec0 100755 --- a/src/components/Button/Button.types.ts +++ b/src/components/Button/Button.types.ts @@ -34,7 +34,12 @@ export type Props = IrisProps< */ color?: | string - | { color: string; hover?: string; active?: string }; + | { + color: string; + hover?: string; + active?: string; + textColor?: string; + }; element?: ButtonElements; floating?: boolean; /** diff --git a/src/components/Button/examples/Growth.story.tsx b/src/components/Button/examples/Growth.story.tsx index 3fdbf4a1a..a462aa15e 100644 --- a/src/components/Button/examples/Growth.story.tsx +++ b/src/components/Button/examples/Growth.story.tsx @@ -16,7 +16,11 @@ export function GrowthCTA({ args }) { -