File tree 14 files changed +68
-21
lines changed
14 files changed +68
-21
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Learn React with TypeScript
13
13
- [ Base] ( https://github.com/locol23/learn-react-ts/tree/master/packages/function-components-base )
14
14
- [ Goal] ( https://github.com/locol23/learn-react-ts/tree/master/packages/function-components-goal )
15
15
- Styled Components
16
- - [ Base] ( https://github.com/locol23/learn-react-ts/tree/master/packages/styled-components-base )
16
+ - [ Base & Goal ] ( https://github.com/locol23/learn-react-ts/tree/master/packages/styled-components )
17
17
- Recompose
18
18
- State(withStateHandlers)
19
19
- [ Base] ( https://github.com/locol23/learn-react-ts/tree/master/packages/recompose-state-base )
Load Diff This file was deleted.
Load Diff This file was deleted.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ # styled-components-base
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import React , { Children } from 'react'
2
+ import styled from 'styled-components'
3
+ import { Color , Size } from '../const'
4
+
5
+ interface LayoutProps {
6
+ children : React . ReactNode
7
+ }
8
+
9
+ const Container = styled . div `
10
+ display: flex;
11
+ justify-content: center;
12
+ `
13
+
14
+ const Layout = ( props : LayoutProps ) => < Container > { props . children } </ Container >
15
+
16
+ const Header = ( ) => (
17
+ < Layout >
18
+ < h1 > Function Components</ h1 >
19
+ </ Layout >
20
+ )
21
+
22
+ const Button = styled . button `
23
+ border: solid 1px ${ Color . PRIMARY } ;
24
+ width: 100px;
25
+ height: 30px;
26
+ margin: 0 20px;
27
+ `
28
+
29
+ const StyledButton = styled ( Button ) `
30
+ color: ${ Color . SECONDARY } ;
31
+ border: solid 1px ${ Color . SECONDARY } ;
32
+ border-radius: 5px;
33
+ `
34
+
35
+ interface CustomButtonProps {
36
+ children : React . ReactNode
37
+ }
38
+
39
+ const CustomButton = ( props : CustomButtonProps ) => (
40
+ < button onClick = { ( ) => alert ( 'CustomButton' ) } { ...props } >
41
+ { props . children }
42
+ </ button >
43
+ )
44
+
45
+ export const App = ( ) => (
46
+ < React . Fragment >
47
+ < Header />
48
+ < Layout >
49
+ < Button onClick = { ( ) => alert ( 'Button' ) } > Nomal Button</ Button >
50
+ < StyledButton onClick = { ( ) => alert ( 'Styled Button' ) } >
51
+ Styled Button
52
+ </ StyledButton >
53
+ < StyledButton as = { CustomButton } > Custome Button</ StyledButton >
54
+ </ Layout >
55
+ </ React . Fragment >
56
+ )
Original file line number Diff line number Diff line change
1
+ export const Size = {
2
+ SMALL : 10 ,
3
+ NORMAL : 15 ,
4
+ LARGE : 20 ,
5
+ }
6
+
7
+ export const Color = {
8
+ PRIMARY : '#000' ,
9
+ SECONDARY : '#ff8600' ,
10
+ }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments