Skip to content

Commit 3bb588c

Browse files
committed
refactor: separate Button component
1 parent 01ef77b commit 3bb588c

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/styled-components/src/components/App.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import styled from 'styled-components'
33
import { color } from '../styles'
44
import { Header } from './Header'
5+
import { Button } from './Button'
56

67
const CustomButton: React.FC = ({ children }) => <button onClick={() => alert('CustomButton')}>{children}</button>
78

@@ -24,13 +25,6 @@ const Container = styled.div({
2425
justifyContent: 'center',
2526
})
2627

27-
const Button = styled.button`
28-
border: solid 1px ${color.primary};
29-
width: 100px;
30-
height: 30px;
31-
margin: 0 20px;
32-
`
33-
3428
type StyleMap = {
3529
[key: string]: () => string
3630
}
@@ -60,4 +54,3 @@ const StyleObjectsStyledButton = styled(Button)<StyleButtonProps>(
6054
},
6155
(props) => (props.styleType ? styleMap[props.styleType]() : styleMap.default())
6256
)
63-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import styled from 'styled-components'
2+
import { color } from '../styles'
3+
4+
export const Button = styled.button`
5+
border: solid 1px ${color.primary};
6+
width: 100px;
7+
height: 30px;
8+
margin: 0 20px;
9+
`
10+
11+
// Style Objects
12+
const StyleObjectsButton = styled.button({
13+
border: `solid 1px ${color.primary}`,
14+
width: 100,
15+
height: 30,
16+
margin: '0 20px',
17+
})
18+

0 commit comments

Comments
 (0)