From 73b887ff93345add292cb35a79612ffd2f8b74fe Mon Sep 17 00:00:00 2001 From: "Liujie (Jacky) Hao" Date: Fri, 14 Jul 2023 18:45:55 -0500 Subject: [PATCH 1/3] add additional colors --- src/content/Text.tsx | 14 +++- src/content/types.ts | 5 +- src/provider/GlobalStyles.tsx | 2 + src/types/core.ts | 2 + src/utils/styleProps.ts | 2 +- stories/Text.stories.tsx | 147 ++++++++++++++++++---------------- 6 files changed, 94 insertions(+), 78 deletions(-) diff --git a/src/content/Text.tsx b/src/content/Text.tsx index 124ab1d7..0ae1b066 100644 --- a/src/content/Text.tsx +++ b/src/content/Text.tsx @@ -2,18 +2,18 @@ import React, { ElementType, ReactNode, forwardRef, - HTMLProps, CSSProperties, } from 'react'; import { css } from '@emotion/react'; -import { DOMRef } from '../types'; +import { ColorValue, DOMProps, DOMRef, StyleProps } from '../types'; import { useDOMRef } from '../utils/useDOMRef'; import theme, { designationColors } from '../theme'; import { TextColor, Size, TextElementType, Weight } from './types'; import { textSizeCSS, textWeightCSS } from './styles'; import { filterDOMProps } from '@react-aria/utils'; +import { colorValue, useStyleProps } from '../utils'; -export interface TextProps extends HTMLProps { +export interface TextProps extends DOMProps, StyleProps { /** * Sets text size * @default 'medium' @@ -58,7 +58,11 @@ const getTextColor = (color: TextColor) => { // Return the designation color (e.x. the main primary / reference colors) return designationColors[color]; } - return theme.textColors[color]; + const textColor = theme.textColors[color]; + if (textColor) { + return textColor; + } + return colorValue(color as ColorValue); }; const textCSS = (color: TextColor) => css` /* default to no margin */ @@ -82,11 +86,13 @@ function Text(props: TextProps, ref: DOMRef) { } = props; const TextTag = elementType as ElementType; const domRef = useDOMRef(ref); + const styleProps = useStyleProps(otherProps); return ( { return ( -
-

+

- {sizes.map(size => { - return ( - - {`I will not waste chalk`} - - ); - })} -

-

- {sizes.map(size => { - return ( - - {`I will not waste chalk`} - - ); - })} -

-

- {colors.map(color => { - return ( - - {`I will not waste chalk`} - - ); - })} -

-

- {colors.map(color => { - return ( - - {`I will not waste chalk`} - - ); - })} -

-
+

+ {sizes.map(size => { + return ( + + {`I will not waste chalk`} + + ); + })} +

+

+ {sizes.map(size => { + return ( + + {`I will not waste chalk`} + + ); + })} +

+

+ {colors.map(color => { + return ( + + {`I will not waste chalk`} + + ); + })} +

+

+ {colors.map(color => { + return ( + + {`I will not waste chalk`} + + ); + })} +

+
+ ); }; From a138d6a38ab4600006f8772dda37e09cc87f244b Mon Sep 17 00:00:00 2001 From: "Liujie (Jacky) Hao" Date: Fri, 14 Jul 2023 19:01:37 -0500 Subject: [PATCH 2/3] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a463750d..ea74afc1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.12.3", + "version": "0.12.4", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", From 2dce3963b8aecfd8525e8a5dc20535b7de0f92b7 Mon Sep 17 00:00:00 2001 From: "Liujie (Jacky) Hao" Date: Fri, 14 Jul 2023 19:02:22 -0500 Subject: [PATCH 3/3] v0.12.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea74afc1..e98b27d2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.12.4", + "version": "0.12.5", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts",