Skip to content

Commit 7133c69

Browse files
committed
feat: copy repo button
1 parent cfc260d commit 7133c69

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/routes/plugins/index.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
import Layout from "@components/Layout";
22
import Page from "@components/Page";
33
import { useTheme } from "@hooks/useTheme";
4-
import { Box, Button, Divider, Typography } from "@mui/material";
4+
import { Box, Button, Divider, IconButton, Typography } from "@mui/material";
5+
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
6+
import { useState } from "react";
7+
import DoneIcon from "@mui/icons-material/Done";
58

69
const lnreaderPluginsRepo =
710
"https://raw.githubusercontent.com/LNReader/lnreader-plugins/plugins/v3.0.0/.dist/plugins.min.json";
811

912
export default function Plugins() {
1013
const theme = useTheme();
1114

15+
const [copied, setCopied] = useState(false);
16+
17+
const onCopy = () => {
18+
navigator.clipboard.writeText(lnreaderPluginsRepo).then(() => {
19+
setCopied(true);
20+
setTimeout(() => setCopied(false), 2000);
21+
});
22+
};
23+
1224
return (
1325
<Layout>
1426
<Page
1527
title="Plugins"
1628
content={
17-
<Box>
29+
<Box sx={{ position: "relative" }}>
1830
<Typography sx={{ mt: 2 }}>
1931
By default, <b>LNReader</b> comes without any plugins. You can
2032
choose to read local content or include an external repository.
@@ -23,14 +35,15 @@ export default function Plugins() {
2335
<b>LNReader</b> maintains only one official repository; any other
2436
repositories are unofficial and have no affiliation with us.
2537
</Typography>
26-
<Box sx={{ my: 2, textAlign: "center" }}>
38+
<Box sx={{ my: 2, textAlign: "center", position: "relative" }}>
2739
<Button
2840
variant="contained"
2941
sx={{
3042
borderRadius: 12,
3143
background: theme.primaryContainer,
3244
color: theme.onPrimaryContainer,
3345
textTransform: "none",
46+
mr: 1,
3447
}}
3548
href={
3649
"lnreader://repo/add?url=" +
@@ -39,6 +52,11 @@ export default function Plugins() {
3952
>
4053
Add repository
4154
</Button>
55+
56+
<IconButton disabled={copied} onClick={onCopy} color="primary">
57+
{copied ? <DoneIcon /> : <ContentCopyIcon />}
58+
</IconButton>
59+
4260
<Typography sx={{ mt: 2 }}>
4361
Requires <b>LNReader 2.0.0</b> or newer.
4462
</Typography>

0 commit comments

Comments
 (0)