Skip to content

Commit 0e45a63

Browse files
committed
Fix naming
1 parent 682aee9 commit 0e45a63

1 file changed

Lines changed: 14 additions & 21 deletions

File tree

src/index.jsx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import React, {PureComponent} from 'react'
22

3-
import {create as createJSS, getDynamicStyles} from 'jss'
3+
import {create as createJss, getDynamicStyles} from 'jss'
44
import preset from 'jss-preset-default'
55

66
import filterProps from './utils/filter-props'
77

88

9-
const JSS = createJSS(preset())
9+
const jssDefault = createJss(preset())
1010

11-
type StyledElementAttrsT = { Tag: string, styles: Object }
11+
type StyledElementAttrsT = { tag: string, styles: Object }
1212
type StyledElementT = Function & StyledElementAttrsT
13-
type TagOrStyledElementT = string | StyledElementT
13+
type tagOrStyledElementT = string | StyledElementT
1414
type StyledElementPropsT = {
1515
classes: Object,
1616
children: ?any,
1717
className: ?string,
1818
}
1919

2020

21-
export const createStyled = (jss?: Function = JSS) => (baseStyles: Object = {}) => {
21+
export const createStyled = (jss?: Function = jssDefault) => (baseStyles: Object = {}) => {
2222
let sheet
2323
let dynamicSheet
2424

25-
let currentId = 0
25+
let counter = 0
2626

27-
return (TagOrStyledElement: TagOrStyledElementT, ownStyles: Object): StyledElementT => {
28-
const {Tag, styles}: StyledElementAttrsT = typeof TagOrStyledElement === 'string'
29-
? {Tag: TagOrStyledElement, styles: {}}
30-
: TagOrStyledElement
27+
return (tagOrStyledElement: tagOrStyledElementT, ownStyles: Object): StyledElementT => {
28+
const {tag, styles}: StyledElementAttrsT = typeof tagOrStyledElement === 'string'
29+
? {tag: tagOrStyledElement, styles: {}}
30+
: tagOrStyledElement
3131

3232
const elementStyles = {...styles, ...ownStyles}
3333
const dynamicStyles = getDynamicStyles(elementStyles)
@@ -46,20 +46,20 @@ export const createStyled = (jss?: Function = JSS) => (baseStyles: Object = {})
4646
}
4747
}
4848

49-
const StaticTag = `${Tag}-${++currentId}`
49+
const StaticTag = `${tag}-${++counter}`
5050

5151
return class StyledElement extends PureComponent {
5252
props: StyledElementPropsT
5353

54-
static Tag = Tag
54+
static tag = tag
5555
static styles = elementStyles
5656

5757
tagScoped = ''
5858

5959
constructor(props) {
6060
super(props)
6161

62-
this.tagScoped = `${Tag}-${++currentId}`
62+
this.tagScoped = `${tag}-${++counter}`
6363
}
6464

6565
componentWillMount() {
@@ -109,14 +109,7 @@ export const createStyled = (jss?: Function = JSS) => (baseStyles: Object = {})
109109
.filter(Boolean)
110110
.join(' ')
111111

112-
return (
113-
<Tag
114-
className={tagClass}
115-
{...props}
116-
>
117-
{children}
118-
</Tag>
119-
)
112+
return React.createElement(tag, {...props, className: tagClass}, children)
120113
}
121114
}
122115
}

0 commit comments

Comments
 (0)