From 1287eabff9d66fccd2bbc9fc7ddc0f69307345d7 Mon Sep 17 00:00:00 2001 From: hualigushi Date: Wed, 21 Jun 2023 09:36:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(plugins):=20=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=20styled=20components=20=E6=94=AF=E6=8C=81=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugins/src/styled-components.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugins/src/styled-components.ts b/packages/plugins/src/styled-components.ts index fbcacfe3a046..f9b7d96d07b9 100644 --- a/packages/plugins/src/styled-components.ts +++ b/packages/plugins/src/styled-components.ts @@ -55,7 +55,11 @@ export { styled, ThemeProvider, createGlobalStyle, css, keyframes, StyleSheetMan content: ` ${styledComponentsRuntimeCode} export function rootContainer(container) { - const globalStyle = styledComponentsConfig.GlobalStyle ? : null; + const scConfig = + typeof styledComponentsConfig === 'function' + ? styledComponentsConfig() + : styledComponentsConfig; + const globalStyle = scConfig.GlobalStyle ? : null; return ( <> {globalStyle} From 95863d5f9b72629b374eebf9fe1cf6aeac30215e Mon Sep 17 00:00:00 2001 From: hualigushi Date: Tue, 27 Jun 2023 15:45:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/max/styled-components.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/max/styled-components.md b/docs/docs/max/styled-components.md index c7c8eff1148d..be9e1750f405 100644 --- a/docs/docs/max/styled-components.md +++ b/docs/docs/max/styled-components.md @@ -60,14 +60,14 @@ export default { 比如: ```ts -import {createGlobalStyle} from "umi"; +import { createGlobalStyle } from "umi"; -export const styledComponents = { +export const styledComponents = () => ({ GlobalStyle: createGlobalStyle` h1 { background: #ccc; } ` -} +}) ``` From 8de7e30bffcbb3f6ddee61c00946d6ba56dd6cc9 Mon Sep 17 00:00:00 2001 From: fz6m <59400654+fz6m@users.noreply.github.com> Date: Tue, 7 Nov 2023 06:16:25 +0800 Subject: [PATCH 3/3] docs(SC): use object config --- docs/docs/docs/max/styled-components.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/docs/max/styled-components.md b/docs/docs/docs/max/styled-components.md index 2547dd1c8218..a37cb5dda7af 100644 --- a/docs/docs/docs/max/styled-components.md +++ b/docs/docs/docs/max/styled-components.md @@ -66,12 +66,12 @@ export default { ```ts import { createGlobalStyle } from "umi"; -export const styledComponents = () => ({ +export const styledComponents = { GlobalStyle: createGlobalStyle` h1 { background: #ccc; } ` -}) +} ```