Skip to content

Commit 7552412

Browse files
committed
styled-component
1 parent c200b13 commit 7552412

File tree

3 files changed

+53
-16
lines changed

3 files changed

+53
-16
lines changed

src/App.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
2-
import Welcome from './components/Welcome'
2+
import Component from './components/Component'
33

4-
5-
const App = () => <div className="App"><Welcome /></div>;
4+
const App = () => <div className="App"><Component theme={theme}/></div>;
65
export default App;

src/components/Component.jsx

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
11
import React from "react";
2+
import styled from "styled-components";
3+
4+
const Wrapper = styled.div`
5+
padding: 40px;
6+
text-align: left;
7+
background: #f7df1e;
8+
color: #3c3a2d;
9+
`;
10+
11+
const Title = styled.h1`
12+
font-size: 30px;
13+
font-weight: 900;
14+
`;
15+
const Paragraph = styled.p`
16+
font-size: 15px;
17+
font-weight: 300;
18+
`;
19+
const Button = styled.button`
20+
font-size: 14px;
21+
font-weight: 400;
22+
background-color: #4a430b;
23+
border: none;
24+
cursor: pointer;
25+
color: #ffffff;
26+
padding: 10px 20px;
27+
border-radius: 4px;
28+
&:hover {
29+
background-color: #342f08;
30+
}
31+
`;
32+
const Link = styled.a`
33+
font-size: 14px;
34+
font-weight: 400;
35+
background-color: transparent;
36+
border: none;
37+
cursor: pointer;
38+
color: #3c3a2d;
39+
padding: 10px 20px;
40+
border-radius: 4px;
41+
`;
242

343
const Component = props => {
444
return (
5-
<div>
6-
<h1>Example component CSS</h1>
7-
<p>
45+
<Wrapper>
46+
<Title>Example component CSS</Title>
47+
<Paragraph>
848
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ducimus,
949
temporibus labore voluptatibus aspernatur illo ad id sit nulla, a atque
1050
doloribus itaque ab? Soluta, exercitationem illum provident quod iure
1151
numquam?
12-
</p>
13-
<button>I'm a button</button>
14-
<a href="/#" onClick={e => e.preventDefault()}>
52+
</Paragraph>
53+
<Button>I'm a button</Button>
54+
<Link href="/#" onClick={e => e.preventDefault()}>
1555
I'm a link
16-
</a>
17-
</div>
56+
</Link>
57+
</Wrapper>
1858
);
1959
};
2060

src/components/Welcome.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ const Button = styled.button`
1010
color: #ffffff;
1111
padding: 10px 20px;
1212
border-radius: 4px;
13-
`;
1413
15-
const Link = styled(Button)`
16-
color: #4a430b;
17-
background-color: transparent;
14+
&:hover {
15+
background-color: #342f08;
16+
}
1817
`;
1918

2019
const Welcome = () => {
2120
return (
2221
<Fragment>
2322
<Button>Click me!!</Button>
24-
<Link as="a">Give me click too!!</Link>
2523
</Fragment>
2624
);
2725
};

0 commit comments

Comments
 (0)