From 3252dcd44e5db420f15b84a3a030b95e7f51800b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Pape=C5=BE?= Date: Wed, 14 Aug 2024 18:40:34 +0200 Subject: [PATCH] Fixed clickable links in additional information --- modules/PDFView/CVTemplates/CVTemplate.tsx | 1 - modules/PDFView/CVTemplates/Images/Earth.tsx | 16 +++--- modules/PDFView/CVTemplates/Images/Email.tsx | 10 +++- .../PDFView/CVTemplates/Images/Facebook.tsx | 16 +++--- modules/PDFView/CVTemplates/Images/Github.tsx | 16 +++--- .../PDFView/CVTemplates/Images/Linkedin.tsx | 16 +++--- modules/PDFView/CVTemplates/Images/Phone.tsx | 17 ++++--- modules/PDFView/CVTemplates/Images/Pin.tsx | 16 +++--- .../PDFView/CVTemplates/Images/Twitter.tsx | 16 +++--- .../AdditionalInformation.tsx | 51 ++++++++++++------- modules/PDFView/PDFDownload/PDFDownload.tsx | 18 +++++-- next.config.mjs | 34 ++++++------- package-lock.json | 14 ++--- package.json | 2 +- 14 files changed, 152 insertions(+), 91 deletions(-) diff --git a/modules/PDFView/CVTemplates/CVTemplate.tsx b/modules/PDFView/CVTemplates/CVTemplate.tsx index 6303075..0570e4c 100644 --- a/modules/PDFView/CVTemplates/CVTemplate.tsx +++ b/modules/PDFView/CVTemplates/CVTemplate.tsx @@ -26,7 +26,6 @@ interface Props { template: Template; skills: Skill[]; projects: Project[]; - isHtml?: boolean; } interface OptionType extends Props { diff --git a/modules/PDFView/CVTemplates/Images/Earth.tsx b/modules/PDFView/CVTemplates/Images/Earth.tsx index c31ba47..444d827 100644 --- a/modules/PDFView/CVTemplates/Images/Earth.tsx +++ b/modules/PDFView/CVTemplates/Images/Earth.tsx @@ -1,13 +1,17 @@ -import { - G, - Path, - Svg, -} from '@rawwee/react-pdf-html'; +import { G, Path, Svg } from '@rawwee/react-pdf-html'; export const Earth = (props: { width?: number; height?: number }) => { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + { const { width, height } = props; return ( - + = ({ return condition; }) .map(({ icon, text, link }, index) => { + let url = null; + + try { + if (link) url = new URL(link ?? '')?.toString(); + } catch (error) { + console.error(error); + } + const LinkDisplay = () => ( {icon({ width: 14 })} @@ -137,25 +146,23 @@ export const AdditionalInformation: FC = ({ ) : ( {icon({ width: 14 })} - {text && {text}} - {link && ( - - - {decodeURIComponent( + + + {link && + decodeURIComponent( link .replace(/(^\w+:|^)\/\//, '') .replace(/(^www\.)/, '') .replace(/(linkedin|github).com\//, '') - .replace(/(in)\//, '') ).replace(/\/$/, '')} - - - )} + {text} + + ); }); @@ -178,10 +185,16 @@ export const AdditionalInformation: FC = ({ backgroundColor, }} > - + {firstHalf} {secondHalf} diff --git a/modules/PDFView/PDFDownload/PDFDownload.tsx b/modules/PDFView/PDFDownload/PDFDownload.tsx index 8509a25..4684aed 100644 --- a/modules/PDFView/PDFDownload/PDFDownload.tsx +++ b/modules/PDFView/PDFDownload/PDFDownload.tsx @@ -1,14 +1,19 @@ -import { Dialog, DialogContent } from '@/components/ui/dialog'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogTitle, +} from '@/components/ui/dialog'; import { getCurrentTranslations } from '@/translations/hooks/getCurrentTranslations'; import { DEFAULT_LOCALE } from '@/translations/locales'; import { usePDFComponentsAreHTML } from '@rawwee/react-pdf-html'; -import ReactPDF, { PDFDownloadLink } from '@react-pdf/renderer'; +import { PDFDownloadLink, UsePDFInstance } from '@react-pdf/renderer'; import { NextIntlClientProvider, useLocale } from 'next-intl'; import { useEffect, useState } from 'react'; type Props = { PdfInstance?: () => JSX.Element; - pdfBlob?: ReactPDF.UsePDFInstance; + pdfBlob?: UsePDFInstance; closeModal(): void; show: boolean; }; @@ -39,11 +44,18 @@ export const PDFDownload = ({ setMessages(messages); }); } + + return () => { + setHtml(true); + setDownload(false); + }; }, [show]); return ( + +

Download CV

diff --git a/next.config.mjs b/next.config.mjs index f65187e..f6752fa 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -59,23 +59,23 @@ const nextConfig = { test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource', }); - config.plugins.push( - new CopyPlugin({ - patterns: [ - { - from: path.join('./', 'node_modules/pdfjs-dist/cmaps'), - to: path.join('./', 'public/cmaps'), - }, - { - from: path.join( - './', - 'node_modules/pdfjs-dist/build/pdf.worker.min.js' - ), - to: path.join('./', 'public'), - }, - ], - }) - ); + // config.plugins.push( + // new CopyPlugin({ + // patterns: [ + // { + // from: path.join('./', 'node_modules/pdfjs-dist/cmaps'), + // to: path.join('./', 'public/cmaps'), + // }, + // { + // from: path.join( + // './', + // 'node_modules/pdfjs-dist/build/pdf.worker.min.js' + // ), + // to: path.join('./', 'public'), + // }, + // ], + // }) + // ); return config; }, }; diff --git a/package-lock.json b/package-lock.json index 775c34c..0b8680a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "@types/js-cookie": "^3.0.6", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", - "@types/node": "^20.14.9", + "@types/node": "^22.3.0", "@types/react": "^18.3.3", "@types/react-custom-scroll": "^5.0.3", "@types/react-custom-scrollbars": "^4.0.13", @@ -7188,12 +7188,12 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", - "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "version": "22.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.3.0.tgz", + "integrity": "sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==", "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.18.2" } }, "node_modules/@types/parse-json": { @@ -22980,7 +22980,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", + "version": "6.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz", + "integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==", "license": "MIT" }, "node_modules/unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index 7cca1f5..5ee7cb5 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "@types/js-cookie": "^3.0.6", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", - "@types/node": "^20.14.9", + "@types/node": "^22.3.0", "@types/react": "^18.3.3", "@types/react-custom-scroll": "^5.0.3", "@types/react-custom-scrollbars": "^4.0.13",