diff --git a/.prettierignore b/.prettierignore
index 2318862..12df85d 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1 +1,2 @@
-*.css
\ No newline at end of file
+*.css
+CHANGELOG.md
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..a172248
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,6 @@
+### v1.1 (2021-09-24)
+- Added pin icon directly to snippet card ([#4](https://github.com/pawelmalak/snippet-box/issues/4))
+- Fixed issue with copying snippets ([#6](https://github.com/pawelmalak/snippet-box/issues/6))
+
+### v1.0 (2021-09-23)
+Initial release
\ No newline at end of file
diff --git a/client/package-lock.json b/client/package-lock.json
index 256e2ac..31db5ed 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -4277,6 +4277,11 @@
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A=="
},
+ "clipboard-copy": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/clipboard-copy/-/clipboard-copy-4.0.1.tgz",
+ "integrity": "sha512-wOlqdqziE/NNTUJsfSgXmBMIrYmfd5V0HCGsR8uAKHcg+h9NENWINcfRjtWGU77wDHC8B8ijV4hMTGYbrKovng=="
+ },
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
diff --git a/client/package.json b/client/package.json
index 2b0b096..6f158dc 100644
--- a/client/package.json
+++ b/client/package.json
@@ -15,6 +15,7 @@
"@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.3.0",
"axios": "^0.21.4",
+ "clipboard-copy": "^4.0.1",
"dayjs": "^1.10.7",
"react": "^17.0.2",
"react-dom": "^17.0.2",
diff --git a/client/src/components/Snippets/SnippetCard.tsx b/client/src/components/Snippets/SnippetCard.tsx
index 3e8c873..d880a30 100644
--- a/client/src/components/Snippets/SnippetCard.tsx
+++ b/client/src/components/Snippets/SnippetCard.tsx
@@ -4,8 +4,8 @@ import { Snippet } from '../../typescript/interfaces';
import { dateParser, badgeColor } from '../../utils';
import { Badge, Button, Card } from '../UI';
import { SnippetsContext } from '../../store';
-import Icon from '@mdi/react';
-import { mdiPin } from '@mdi/js';
+import copy from 'clipboard-copy';
+import { SnippetPin } from './SnippetPin';
interface Props {
snippet: Snippet;
@@ -17,7 +17,7 @@ export const SnippetCard = (props: Props): JSX.Element => {
const { setSnippet } = useContext(SnippetsContext);
const copyHandler = () => {
- navigator.clipboard.writeText(code);
+ copy(code);
};
return (
@@ -25,7 +25,7 @@ export const SnippetCard = (props: Props): JSX.Element => {
{/* TITLE */}
{title}
- {isPinned ? : ''}
+
diff --git a/client/src/components/Snippets/SnippetDetails.tsx b/client/src/components/Snippets/SnippetDetails.tsx
index 9729189..9de585b 100644
--- a/client/src/components/Snippets/SnippetDetails.tsx
+++ b/client/src/components/Snippets/SnippetDetails.tsx
@@ -1,11 +1,11 @@
import { useContext } from 'react';
-import { Link } from 'react-router-dom';
+import { useHistory } from 'react-router-dom';
import { SnippetsContext } from '../../store';
import { Snippet } from '../../typescript/interfaces';
import { dateParser } from '../../utils';
import { Button, Card } from '../UI';
-import Icon from '@mdi/react';
-import { mdiPin } from '@mdi/js';
+import copy from 'clipboard-copy';
+import { SnippetPin } from './SnippetPin';
interface Props {
snippet: Snippet;
@@ -23,21 +23,22 @@ export const SnippetDetails = (props: Props): JSX.Element => {
isPinned
} = props.snippet;
- const { deleteSnippet, toggleSnippetPin, setSnippet } =
- useContext(SnippetsContext);
+ const history = useHistory();
+
+ const { deleteSnippet, setSnippet } = useContext(SnippetsContext);
const creationDate = dateParser(createdAt);
const updateDate = dateParser(updatedAt);
const copyHandler = () => {
- navigator.clipboard.writeText(code);
+ copy(code);
};
return (
{title}
- {isPinned ? : ''}
+
{description}
@@ -58,33 +59,22 @@ export const SnippetDetails = (props: Props): JSX.Element => {
Last updated
{updateDate.relative}
-
{/* ACTIONS */}
-
-
-