-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathUpgradeButton.tsx
More file actions
84 lines (74 loc) · 1.78 KB
/
UpgradeButton.tsx
File metadata and controls
84 lines (74 loc) · 1.78 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
79
80
81
82
83
84
import React from 'react'
import styled from '@emotion/styled'
import { Button as AntdButton, ButtonProps } from 'antd'
import { CopyOutlined } from '@ant-design/icons'
import { deviceSizes } from '../../utils/device-sizes'
export const testIDs = {
upgradeButton: 'upgradeButton',
aiPromptButton: 'aiPromptButton',
}
const Container = styled.div`
display: flex;
align-items: center;
gap: 12px;
justify-content: center;
height: auto;
overflow: hidden;
margin-top: 28px;
@media ${deviceSizes.mobile} {
flex-direction: column;
}
`
const Button = styled(AntdButton)`
border-radius: 5px;
`
const AiPromptButton = styled(Button)`
&& {
background: linear-gradient(135deg, #ff6fb5 0%, #59c4ff 100%) !important;
border: 0;
box-shadow: 0 2px 0 rgba(89, 196, 255, 0.24);
color: #fff;
}
&&:hover {
opacity: 0.8;
}
`
interface UpgradeButtonProps extends React.PropsWithRef<ButtonProps> {
onShowDiff: () => void
showAiPromptButton?: boolean
onAiPromptClick?: () => Promise<void>
}
const UpgradeButton = React.forwardRef<
HTMLElement,
UpgradeButtonProps & React.RefAttributes<HTMLElement>
>(
(
{ onShowDiff, showAiPromptButton = false, onAiPromptClick, ...props },
ref
) => (
<Container>
<Button
{...props}
ref={ref}
type="primary"
size="large"
data-testid={testIDs.upgradeButton}
onClick={onShowDiff}
>
Show me how to upgrade!
</Button>
{showAiPromptButton && (
<AiPromptButton
type="primary"
size="large"
data-testid={testIDs.aiPromptButton}
onClick={onAiPromptClick}
>
Copy for AI
<CopyOutlined />
</AiPromptButton>
)}
</Container>
)
)
export default UpgradeButton