-
-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathButton.tsx
More file actions
31 lines (27 loc) · 705 Bytes
/
Button.tsx
File metadata and controls
31 lines (27 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { useState } from 'react'
import styled, { css } from 'styled-components'
// Ensure HMR of styled component alongside other components
export const StyledCode = styled.code`
color: palevioletred;
`
const Button = styled.button`
border-radius: 3px;
padding: 0.5rem 1rem;
color: white;
background: transparent;
border: 2px solid white;
${(props: { primary?: boolean }) =>
props.primary &&
css`
background: white;
color: black;
`}
`
export const Counter = ({ primary }: { primary?: boolean }) => {
const [count, setCount] = useState(0)
return (
<Button primary={primary} onClick={() => setCount(count + 1)}>
count is {count}
</Button>
)
}