Skip to content

Commit de92700

Browse files
[UI] Display/allow user to copy alternate Epic login URL (#2504)
* feat: copy epic login url * fix: accent color button
1 parent d12520a commit de92700

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

public/locales/en/login.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"button": {
3-
"login": "Log in"
3+
"login": "Log in",
4+
"open":"Open Link",
5+
"copy":"Copy",
6+
"copied":"Copied!"
47
},
58
"message": {
69
"part1": "In order to log in and install your games, you first need to follow the steps below:",

src/frontend/screens/Login/components/SIDLogin/index.css

+32
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@
5454
color: var(--link-highlight);
5555
}
5656

57+
.loginInstructions .login-link {
58+
display: flex;
59+
background-color: var(--background-darker);
60+
border-color: var(--accent);
61+
color: var(--text-default);
62+
padding: var(--space-2xs);
63+
margin: var(--space-lg);
64+
width: inherit;
65+
justify-content: space-between;
66+
user-select: text;
67+
}
68+
69+
.loginInstructions .icon-button {
70+
color: var(--accent);
71+
border-color: var(--accent);
72+
}
73+
74+
.loginInstructions .icon-button:hover {
75+
color: var(--accent-overlay);
76+
border-color: var(--accent-overlay);
77+
}
78+
79+
.loginInstructions .icon-button-success {
80+
color: var(--success);
81+
border-color: var(--success);
82+
}
83+
84+
.loginInstructions .icon-button-success:hover {
85+
color: var(--success-hover);
86+
border-color: var(--success-hover);
87+
}
88+
5789
.loginInstructions li {
5890
text-align: left;
5991
}

src/frontend/screens/Login/components/SIDLogin/index.tsx

+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React, { useContext, useState } from 'react'
22
import Info from '@mui/icons-material/Info'
3+
import LinkIcon from '@mui/icons-material/Link'
4+
import PublicIcon from '@mui/icons-material/Public'
5+
import { Button, Paper, Stack, Typography } from '@mui/material'
36
import { useTranslation } from 'react-i18next'
47
import { loginPage, sidInfoPage } from 'frontend/helpers'
58
import './index.css'
@@ -11,16 +14,24 @@ interface Props {
1114
}
1215

1316
export default function SIDLogin({ backdropClick }: Props) {
17+
const epicLoginUrl = 'https://legendary.gl/epiclogin'
18+
1419
const { epic } = useContext(ContextProvider)
1520
const { t } = useTranslation('login')
1621
const [input, setInput] = useState('')
1722
const [status, setStatus] = useState({
1823
loading: false,
1924
message: ''
2025
})
26+
const [linkCopied, setLinkCopied] = useState(false)
2127

2228
const { loading, message } = status
2329

30+
const handleCopyLink = () => {
31+
window.api.clipboardWriteText(epicLoginUrl)
32+
setLinkCopied(true)
33+
}
34+
2435
const handleLogin = async (sid: string) => {
2536
await epic.login(sid).then(async (res) => {
2637
setStatus({
@@ -67,6 +78,33 @@ export default function SIDLogin({ backdropClick }: Props) {
6778
className="material-icons"
6879
/>
6980
</span>
81+
<Paper variant="outlined" className="login-link">
82+
<Typography variant="subtitle1" paddingLeft={2}>
83+
{epicLoginUrl}
84+
</Typography>
85+
<Stack direction="row" spacing={1}>
86+
<Button
87+
className={
88+
linkCopied ? 'icon-button-success' : 'icon-button'
89+
}
90+
onClick={handleCopyLink}
91+
endIcon={<LinkIcon fontSize="small" />}
92+
variant="outlined"
93+
size="small"
94+
>
95+
{linkCopied ? t('button.copied') : t('button.copy')}
96+
</Button>
97+
<Button
98+
className="icon-button"
99+
endIcon={<PublicIcon fontSize="small" />}
100+
onClick={() => loginPage()}
101+
size="small"
102+
variant="outlined"
103+
>
104+
{t('button.open')}
105+
</Button>
106+
</Stack>
107+
</Paper>
70108
</li>
71109
<li>
72110
{`${t('message.part6')} `}

0 commit comments

Comments
 (0)