forked from emotion-js/emotion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
42 lines (37 loc) · 999 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Theme } from '@emotion/react'
import baseStyled from './base'
import { ReactJSXIntrinsicElements } from './jsx-namespace'
import { tags } from './tags'
import {
CreateStyledComponent,
CreateStyled as BaseCreateStyled
} from './types'
export type {
ArrayInterpolation,
ComponentSelector,
CSSObject,
FunctionInterpolation,
Interpolation
} from '@emotion/serialize'
export type {
CreateStyledComponent,
FilteringStyledOptions,
StyledComponent,
StyledOptions
} from './types'
export type StyledTags = {
[Tag in keyof ReactJSXIntrinsicElements]: CreateStyledComponent<
{
theme?: Theme
as?: React.ElementType
},
ReactJSXIntrinsicElements[Tag]
>
}
export interface CreateStyled extends BaseCreateStyled, StyledTags {}
// bind it to avoid mutating the original function
const styled = baseStyled.bind(null) as CreateStyled
tags.forEach(tagName => {
;(styled as any)[tagName] = styled(tagName as keyof typeof styled)
})
export default styled