Skip to content

Commit

Permalink
Merge pull request #18 from silentsoft/dev
Browse files Browse the repository at this point in the history
Bugfix - clipboard copy issue
  • Loading branch information
silentsoft authored Jul 30, 2024
2 parents e2f0cdb + 4a2d7d3 commit 0fd92d9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 44 deletions.
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.4.1 (31 Jul 2024)

## Bugfixes
- Fix clipboard copy issue

# 1.4.0 (18 Mar 2022)

## Enhancements
Expand Down
4 changes: 0 additions & 4 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2717,10 +2717,6 @@ __make-dir 3.1.0__
* sindresorhus.com
* MIT License

__copy-text-to-clipboard 3.0.1__
* https://sindresorhus.com
* MIT License

__watchpack 2.3.1__
* https://github.com/webpack/watchpack
* MIT License
Expand Down
17 changes: 0 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "hits",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"dependencies": {
"@nivo/calendar": "^0.79.1",
"@nivo/colors": "^0.79.1",
"@nivo/core": "^0.79.0",
"axios": "^0.26.0",
"copy-text-to-clipboard": "^3.0.1",
"env-cmd": "^10.1.0",
"react": "^17.0.2",
"react-color": "^2.19.3",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.silentsoft</groupId>
<artifactId>hits</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>

<name>Hits</name>
<description>Hit Counter for Your GitHub or Any Kind of Websites You Want</description>
Expand Down
23 changes: 15 additions & 8 deletions src/main/react/components/BadgeCard.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import {useRef, useState} from "react";
import copy from "copy-text-to-clipboard";

export default function BadgeCard(props) {
const valueRef = useRef(null);
const [copied, setCopied] = useState(false);
const copyToClipboard = () => {
try {
copy(valueRef.current.textContent);
if (navigator.clipboard) {
navigator.clipboard.writeText(valueRef.current.textContent).then(() => {
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 1500);
})
} else {
const textarea = document.createElement('textarea');
textarea.value = valueRef.current.textContent;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 1500);
} catch (e) {
console.error(e);
setTimeout(() => setCopied(false), 1500);
document.body.removeChild(textarea);
}
};
return (
Expand Down

0 comments on commit 0fd92d9

Please sign in to comment.