Skip to content

Commit a09934c

Browse files
authored
Merge pull request #87 from liqueflies/master
[+] Support for IE11, added more examples
2 parents cd488f3 + 740b840 commit a09934c

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

example/index.html

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h1>Basic Example</h1>
99
<div id="container"></div>
1010
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
11-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script>
11+
<script src="https://unpkg.com/babel-standalone@6.26.0/babel.min.js"></script>
1212
<script src="/vue-styled-components.js"></script>
1313
<script type="text/babel">
1414

@@ -32,19 +32,45 @@ <h1>Basic Example</h1>
3232
// Create a <CustomTitle> vue component that renders an <h1> which is
3333
// centered, palevioletred and sized at 1.5em
3434
const CustomTitle = styled.default.h1`
35-
font-size: 1.5em;
35+
font-size: 2em;
3636
text-align: center;
3737
color: ${props => props.theme.primary};
3838
animation: ${animation} 2s linear infinite;
39+
40+
@supports (-webkit-text-stroke: 1px) {
41+
-webkit-text-stroke: 2px ${props => props.theme.primary};
42+
color: transparent
43+
}
3944
`;
4045

46+
const H2 = CustomTitle.withComponent('h2')
47+
4148
// Create a <Wrapper> vue component that renders a <section> with
4249
// some padding and a papayawhip background
4350
const Wrapper = styled.default.section`
4451
padding: 4em;
4552
background: ${props => props.theme.secondary};
4653
`;
4754

55+
const W2 = styled.default(Wrapper)`
56+
color: red;
57+
`;
58+
59+
const W3 = styled.default(W2)`
60+
&:hover {
61+
background: ${props => props.theme.primary};
62+
}
63+
`
64+
65+
const Btn = styled.default('button', { visible: Boolean })`
66+
background-color: red;
67+
opacity: ${props => props.visible ? 1: 0};
68+
`
69+
70+
const SuperBtn = styled.default(Btn, { visible: Boolean, big: Boolean })`
71+
font-size: ${props => props.big ? 22 : 18}px;
72+
`
73+
4874
new Vue({
4975
el: '#container',
5076
template: `
@@ -53,12 +79,14 @@ <h1>Basic Example</h1>
5379
secondary: 'papayawhip'
5480
}">
5581
<wrapper>
56-
<custom-title> Hello World, this is my first styled component! </custom-title>
82+
<custom-title> Hello World, this is my first styled component! </custom-title>
83+
<btn visible> Button </btn>
5784
</wrapper>
5885
</theme-provider>`,
5986
components: {
60-
'custom-title': CustomTitle,
61-
wrapper: Wrapper,
87+
'custom-title': H2,
88+
wrapper: W3,
89+
btn: SuperBtn,
6290
'theme-provider': styled.ThemeProvider
6391
},
6492
});

src/models/StyledComponent.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ export default (ComponentStyle) => {
33
const prevProps = target && typeof target !== 'string'
44
? (typeof target === 'object' ? target.props : (typeof target === 'function' ? target.options.props : {}))
55
: {}
6-
const mergedProps = Object.assign({}, prevProps, props)
6+
7+
const mergedProps = { ...prevProps, ...props }
78

89
const componentStyle = new ComponentStyle(rules)
910

@@ -26,6 +27,8 @@ export default (ComponentStyle) => {
2627
}
2728
}
2829

30+
console.log()
31+
2932
return createElement(
3033
target,
3134
{
@@ -47,7 +50,7 @@ export default (ComponentStyle) => {
4750
},
4851
computed: {
4952
generatedClassName () {
50-
const componentProps = Object.assign({ theme: this.theme }, this.$props)
53+
const componentProps = { theme: this.theme, ...this.$props }
5154
return this.generateAndInjectStyles(componentProps)
5255
},
5356
theme () {

src/utils/isValidElementType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function isValidElementType (tag) {
55
return false
66
}
77
if (typeof tag === 'string') {
8-
return domElements.includes(tag)
8+
return domElements.indexOf(tag) !== -1
99
}
1010
if (typeof tag === 'object') {
1111
return !!tag.template || !!tag.withComponent

0 commit comments

Comments
 (0)