forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackerButton.js
More file actions
78 lines (73 loc) · 1.84 KB
/
TrackerButton.js
File metadata and controls
78 lines (73 loc) · 1.84 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react'
import { PseudoBox, Stack } from '@chakra-ui/core'
import { string, any } from 'prop-types'
export const TrackerButton = React.forwardRef(
({ variant, children, ...props }, ref) => {
let color = 'black'
let bg = 'gray.100'
let hoverColor = 'gray.200'
let borderColor = null
let borderWidth = null
if (variant === 'primary') {
color = 'gray.50'
bg = 'primary'
hoverColor = 'primary2'
} else if (variant === 'outline') {
color = 'primary2'
bg = 'transparent'
borderColor = 'primary2'
borderWidth = '1px'
hoverColor = 'blue.50'
} else if (variant === 'danger') {
color = 'gray.50'
bg = 'red.700'
hoverColor = 'red.600'
} else if (variant === 'strong') {
color = 'white'
bg = 'strong'
hoverColor = 'green.400'
} else if (variant === 'info') {
color = 'white'
bg = 'info'
hoverColor = 'blue.300'
} else if (variant === 'weak') {
color = 'white'
bg = 'weak'
hoverColor = 'red.400'
}
return (
<PseudoBox
as="button"
fontWeight="semibold"
rounded="md"
transition="all 0.2s cubic-bezier(.08,.52,.52,1)"
overflow="hidden"
px="4"
py="2"
color={color}
bg={bg}
_hover={{ bg: hoverColor }}
_active={{
boxShadow: 'outline',
}}
_focus={{
boxShadow: 'outline',
}}
_disabled={{ opacity: 0.6 }}
borderColor={borderColor}
borderWidth={borderWidth}
ref={ref}
{...props}
>
<Stack isInline align="center" justifyContent="center">
{children}
</Stack>
</PseudoBox>
)
},
)
TrackerButton.displayName = 'TrackerButton'
TrackerButton.propTypes = {
variant: string,
children: any,
}