diff --git a/client/package-lock.json b/client/package-lock.json index da29baa..eb016b0 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1844,6 +1844,16 @@ } } }, + "@mdi/js": { + "version": "6.1.95", + "resolved": "https://registry.npmjs.org/@mdi/js/-/js-6.1.95.tgz", + "integrity": "sha512-e6ZXoNB9uciA4smHHVkZWyYX/RRZsza8XfLvnOuvdLQttpzRKTqR26jG/COL0o4ES9vbAk9PX5mXTEstg0TCsg==" + }, + "@mdi/react": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@mdi/react/-/react-1.5.0.tgz", + "integrity": "sha512-NztRgUxSYD+ImaKN94Tg66VVVqXj4SmlDGzZoz48H9riJ+Awha56sfXH2fegw819NWo7KI3oeS1Es0lNQqwr0w==" + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/client/package.json b/client/package.json index 837d017..6d2c159 100644 --- a/client/package.json +++ b/client/package.json @@ -4,6 +4,8 @@ "private": true, "dependencies": { "@icons-pack/react-simple-icons": "^4.6.1", + "@mdi/js": "^6.1.95", + "@mdi/react": "^1.5.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", diff --git a/client/src/components/Snippets/SnippetCard.tsx b/client/src/components/Snippets/SnippetCard.tsx index 2aa0973..67f9c45 100644 --- a/client/src/components/Snippets/SnippetCard.tsx +++ b/client/src/components/Snippets/SnippetCard.tsx @@ -1,16 +1,19 @@ import { Link } from 'react-router-dom'; import { useContext } from 'react'; import { Snippet } from '../../typescript/interfaces'; -import { dateParser } from '../../utils'; +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'; interface Props { snippet: Snippet; } export const SnippetCard = (props: Props): JSX.Element => { - const { title, description, language, code, id, updatedAt } = props.snippet; + const { title, description, language, code, id, updatedAt, isPinned } = + props.snippet; const { setSnippet } = useContext(SnippetsContext); const copyHandler = () => { @@ -18,15 +21,28 @@ export const SnippetCard = (props: Props): JSX.Element => { }; return ( - + + {/* TITLE */} +
+ {title} + {isPinned ? : ''} +
+ + {/* UPDATE DATE */}
{dateParser(updatedAt).relative}
+ + {/* DESCRIPTION */}

{description ? description : 'No description'}

- + + {/* LANGUAGE */} +
+ + {/* ACTIONS */}
{ - const { title, language, createdAt, updatedAt, description, code, id } = - props.snippet; + const { + title, + language, + createdAt, + updatedAt, + description, + code, + id, + isPinned + } = props.snippet; - const { deleteSnippet } = useContext(SnippetsContext); + const { deleteSnippet, toggleSnippetPin, setSnippet } = + useContext(SnippetsContext); const creationDate = dateParser(createdAt); const updateDate = dateParser(updatedAt); @@ -23,7 +34,11 @@ export const SnippetDetails = (props: Props): JSX.Element => { }; return ( - + +
+ {title} + {isPinned ? : ''} +

{description}

{/* LANGUAGE */} @@ -54,14 +69,21 @@ export const SnippetDetails = (props: Props): JSX.Element => { state: { from: window.location.pathname } }} > -