Skip to content

Commit fd55276

Browse files
committed
[+] added example with ThemeProvider component
1 parent 3efdd0b commit fd55276

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

example/index.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<body>
88
<h1>Basic Example</h1>
99
<div id="container"></div>
10-
<script src="https://unpkg.com/vue@2.2.4"></script>
10+
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
1111
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script>
1212
<script src="/vue-styled-components.js"></script>
1313
<script type="text/babel">
14+
1415
// Create a global style
1516
styled.injectGlobal`
1617
body {
1718
background-color: #fefefe;
1819
}
1920
`;
2021

21-
2222
const animation = styled.keyframes`
2323
from {
2424
transform: rotate(0deg);
@@ -34,23 +34,32 @@ <h1>Basic Example</h1>
3434
const CustomTitle = styled.default.h1`
3535
font-size: 1.5em;
3636
text-align: center;
37-
color: palevioletred;
37+
color: ${props => props.theme.primary};
3838
animation: ${animation} 2s linear infinite;
3939
`;
4040

4141
// Create a <Wrapper> vue component that renders a <section> with
4242
// some padding and a papayawhip background
4343
const Wrapper = styled.default.section`
4444
padding: 4em;
45-
background: papayawhip;
45+
background: ${props => props.theme.secondary};
4646
`;
4747

4848
new Vue({
4949
el: '#container',
50-
template: '<wrapper><custom-title> Hello World, this is my first styled component! </custom-title></wrapper>',
50+
template: `
51+
<theme-provider :theme="{
52+
primary: 'palevioletred',
53+
secondary: 'papayawhip'
54+
}">
55+
<wrapper>
56+
<custom-title> Hello World, this is my first styled component! </custom-title>
57+
</wrapper>
58+
</theme-provider>`,
5159
components: {
5260
'custom-title': CustomTitle,
5361
wrapper: Wrapper,
62+
'theme-provider': styled.ThemeProvider
5463
},
5564
});
5665
</script>

0 commit comments

Comments
 (0)