@@ -2,18 +2,43 @@ import React from 'react'
22import { createRequire } from 'react-live-runner'
33import styled , { css , keyframes , createGlobalStyle } from 'styled-components'
44import * as Styled from 'styled-components'
5+ import * as EmotionCss from '@emotion/css'
6+ import * as EmotionReact from '@emotion/react'
7+ import * as EmotionSytled from '@emotion/styled'
8+ import * as EmotionIsPropValid from '@emotion/is-prop-valid'
59import { codeBlock } from 'common-tags'
610// @ts -ignore
711import hn from '!!raw-loader!./pages/examples/hacker-news.tsx'
812
9- const imports = { react : React , 'styled-components' : Styled }
13+ let counter = 0
14+ const emotionStyled = EmotionSytled . default
15+ Object . getOwnPropertyNames ( emotionStyled ) . forEach ( ( tag ) => {
16+ if ( tag === 'length' ) return
17+ Object . defineProperty ( emotionStyled , tag , {
18+ get ( ) {
19+ return emotionStyled ( tag as keyof JSX . IntrinsicElements , {
20+ target : `e${ tag } -${ counter ++ } ` ,
21+ } )
22+ } ,
23+ } )
24+ } )
25+
26+ const imports = {
27+ react : React ,
28+ 'styled-components' : Styled ,
29+ '@emotion/css' : EmotionCss ,
30+ '@emotion/react' : EmotionReact ,
31+ '@emotion/styled' : EmotionSytled ,
32+ '@emotion/is-prop-valid' : EmotionIsPropValid ,
33+ }
1034export const scope = {
1135 ...React ,
1236 styled,
1337 css,
1438 keyframes,
1539 createGlobalStyle,
1640 require : createRequire ( imports ) ,
41+ jsxPragma : EmotionReact . jsx ,
1742}
1843
1944export const examples = [
0 commit comments