From 87e310cfca4e122e2fd210bae0ea934889df8200 Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 25 Aug 2018 11:03:05 +0800 Subject: [PATCH 1/2] Update styled-jsx/css typings, add type definitions for methods css.global and css.resolve --- types/styled-jsx/css.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/styled-jsx/css.d.ts b/types/styled-jsx/css.d.ts index 588956c57e..bb50756afc 100644 --- a/types/styled-jsx/css.d.ts +++ b/types/styled-jsx/css.d.ts @@ -1,4 +1,8 @@ -type Tag = (chunks: TemplateStringsArray, ...args: any[]) => string; +type Tag = { + (chunks: TemplateStringsArray, ...args: any[]): string; + global: (chunks: TemplateStringsArray, ...args: any[]) => string; + resolve: (chunks: TemplateStringsArray, ...args: any[]) => { className: string; styles: string }; +}; declare let css: Tag; export = css; From 1a092b0b221986a65fedecdcb501e4e34ebc8aab Mon Sep 17 00:00:00 2001 From: okampfer Date: Sat, 25 Aug 2018 11:30:55 +0800 Subject: [PATCH 2/2] Update styled-jsx/css typings, add tests for methods css.global and css.resolve --- types/styled-jsx/styled-jsx-tests.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/types/styled-jsx/styled-jsx-tests.tsx b/types/styled-jsx/styled-jsx-tests.tsx index 09883d8df6..d1b9033966 100644 --- a/types/styled-jsx/styled-jsx-tests.tsx +++ b/types/styled-jsx/styled-jsx-tests.tsx @@ -26,6 +26,29 @@ const withSeparatedCSS = ( ); +const globalCSS = css.global`body { margin: 0; }`; +const withGlobalCSS = ( +
+ +
+); + +const resolvedCSS = css.resolve`a { color: green; }`; +const withResolvedCSS = ( +
+ + {resolvedCSS.styles} +
+); + +const dynamicResolvedCSS = css.resolve`a { color: ${buttonColor}; }`; +const withDynamicResolvedCSS = ( +
+ + {dynamicResolvedCSS.styles} +
+); + const stylesChildren = flushToReact(); const jsxToRender = ( { stylesChildren }