1
- import React from "react" ;
1
+ import React , { useContext } from "react" ;
2
+ import ThemeContext from "../contexts/theme" ;
2
3
import styled from "styled-components" ;
3
4
4
5
const Wrapper = styled . div `
5
6
padding: 40px;
6
7
text-align: left;
7
- background: #f7df1e ;
8
- color: #3c3a2d ;
8
+ background-color: ${ ( { theme } ) => theme . colors . background } ;
9
+ color: ${ ( { theme } ) => theme . colors . primaryVariant } ;
9
10
` ;
10
11
11
12
const Title = styled . h1 `
@@ -19,14 +20,14 @@ const Paragraph = styled.p`
19
20
const Button = styled . button `
20
21
font-size: 14px;
21
22
font-weight: 400;
22
- background-color: #4a430b ;
23
+ background-color: ${ ( { theme } ) => theme . colors . primary } ;
23
24
border: none;
24
25
cursor: pointer;
25
- color: #ffffff ;
26
+ color: ${ ( { theme } ) => theme . colors . secondaryVariant } ;
26
27
padding: 10px 20px;
27
28
border-radius: 4px;
28
29
&:hover {
29
- background-color: #342f08 ;
30
+ background-color: ${ ( { theme } ) => theme . colors . primaryVariant } ;
30
31
}
31
32
` ;
32
33
const Link = styled . a `
@@ -35,23 +36,25 @@ const Link = styled.a`
35
36
background-color: transparent;
36
37
border: none;
37
38
cursor: pointer;
38
- color: #3c3a2d ;
39
+ color: ${ ( { theme } ) => theme . colors . primaryVariant } ;
39
40
padding: 10px 20px;
40
41
border-radius: 4px;
41
42
` ;
42
43
43
44
const Component = props => {
45
+ const { theme } = useContext ( ThemeContext ) ;
46
+
44
47
return (
45
- < Wrapper >
48
+ < Wrapper theme = { theme } >
46
49
< Title > Example component CSS</ Title >
47
50
< Paragraph >
48
51
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ducimus,
49
52
temporibus labore voluptatibus aspernatur illo ad id sit nulla, a atque
50
53
doloribus itaque ab? Soluta, exercitationem illum provident quod iure
51
54
numquam?
52
55
</ Paragraph >
53
- < Button > I'm a button</ Button >
54
- < Link href = "/#" onClick = { e => e . preventDefault ( ) } >
56
+ < Button theme = { theme } > I'm a button</ Button >
57
+ < Link href = "/#" onClick = { e => e . preventDefault ( ) } theme = { theme } >
55
58
I'm a link
56
59
</ Link >
57
60
</ Wrapper >
0 commit comments