Skip to content

Commit

Permalink
feat(plugins): 运行时 styled components 支持 function (#11304)
Browse files Browse the repository at this point in the history
* feat(plugins): 运行时 styled components 支持 function

* docs: 修改文档

* docs(SC): use object config

---------

Co-authored-by: fz6m <[email protected]>
  • Loading branch information
hualigushi and fz6m authored Nov 6, 2023
1 parent 56313d4 commit aac5ed8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/docs/docs/max/styled-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
比如:

```ts
import {createGlobalStyle} from "umi";
import { createGlobalStyle } from "umi";

export const styledComponents = {
GlobalStyle: createGlobalStyle`
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/src/styled-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export { styled, ThemeProvider, createGlobalStyle, css, keyframes, StyleSheetMan
content: `
${styledComponentsRuntimeCode}
export function rootContainer(container) {
const globalStyle = styledComponentsConfig.GlobalStyle ? <styledComponentsConfig.GlobalStyle /> : null;
const scConfig =
typeof styledComponentsConfig === 'function'
? styledComponentsConfig()
: styledComponentsConfig;
const globalStyle = scConfig.GlobalStyle ? <scConfig.GlobalStyle /> : null;
return (
<>
{globalStyle}
Expand Down

1 comment on commit aac5ed8

@vercel
Copy link

@vercel vercel bot commented on aac5ed8 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.