Skip to content

Commit

Permalink
feat: footer
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc-resourcify committed Jul 5, 2023
1 parent 04d085d commit 4547d5f
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-headroom": "^3.2.1",
"react-icons": "^4.8.0",
"react-icons": "^4.10.1",
"react-tippy": "^1.4.0",
"tailwind-merge": "^1.12.0"
},
"devDependencies": {
Expand Down
135 changes: 133 additions & 2 deletions src/components/layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,142 @@
import { useTheme } from 'next-themes';
import { IconType } from 'react-icons';
import { FiMail } from 'react-icons/fi';
import {
SiGithub,
SiGoodreads,
SiInstagram,
SiLinkedin,
SiTwitter,
} from 'react-icons/si';

import UnstyledLink from '@/components/links/UnstyledLink';

export default function Footer() {
const { theme } = useTheme();

return (
<footer className='mt-4 pb-2'>
<main className='layout flex flex-col items-center border-t pt-6 dark:border-blue-600'>
<footer
className={`${
theme === 'dark'
? 'to-dark bg-gradient-to-r from-sky-950'
: 'bg-gradient-to-r from-blue-300 to-sky-100'
}`}
>
<main className='layout flex flex-col items-center py-6'>
<FooterLinks />

<p className='mt-12 font-medium text-blue-600 dark:text-blue-300'>
Reach out to me
</p>

<SocialLinks />
</main>
</footer>
);
}

function FooterLinks() {
return (
<div className='flex flex-wrap justify-center gap-x-8 gap-y-4'>
{footerLinks.map(({ href, label }) => (
<UnstyledLink
key={label}
className='animated-underline focus-visible:ring-primary-300 rounded-sm text-sm font-medium text-blue-950 focus:outline-none focus-visible:ring dark:text-gray-200'
href={href}
>
{label}
</UnstyledLink>
))}
</div>
);
}

function SocialLinks() {
const emailAddress = 'info@martacodes.it';

return (
<div className='mt-2 flex space-x-4'>
<div className='flex items-center justify-center'>
<a
href={'mailto:' + emailAddress}
className='focus-visible:ring-primary-300 rounded-sm align-middle focus:outline-none focus-visible:ring'
>
<FiMail className='hover:text-primary-500 dark:hover:text-primary-300 h-7 w-7 align-middle text-blue-900 dark:text-gray-300' />
</a>
</div>
{socialLinks.map((socialLink) => (
<UnstyledLink
key={socialLink.id}
className='focus-visible:ring-primary-300 inline-flex items-center justify-center rounded-sm focus:outline-none focus-visible:ring'
href={socialLink.href}
>
<socialLink.icon className='hover:text-primary-500 dark:hover:text-primary-300 my-auto h-6 w-6 align-middle text-blue-900 transition-colors dark:text-gray-300' />
</UnstyledLink>
))}
</div>
);
}

type FooterLink = {
href: string;
label: string;
};
const footerLinks: FooterLink[] = [
{
href: 'https://github.com/martapanc/martacodes.it',
label: 'Source Code',
},
{
href: 'https://martapancaldi.hashnode.dev/',
label: 'Blog',
},
{
href: 'https://www.polywork.com/marta_pancaldi',
label: 'Updates',
},
{
href: '/',
label: 'Analytics',
},
{
href: '/',
label: 'Guestbook',
},
{
href: '/',
label: 'Feedback',
},
];

type SocialLink = {
href: string;
icon: IconType;
id: string;
};
const socialLinks: SocialLink[] = [
{
href: 'https://github.com/martapanc',
icon: SiGithub,
id: 'Github',
},
{
href: 'https://www.linkedin.com/in/martapancaldi',
icon: SiLinkedin,
id: 'Linkedin',
},
{
href: 'https://www.instagram.com/pancakemarta',
icon: SiInstagram,
id: 'Instagram',
},
{
href: 'https://www.goodreads.com/topolinamarta',
icon: SiGoodreads,
id: 'Goodreads',
},
{
href: 'https://twitter.com/_pancakem_',
icon: SiTwitter,
id: 'Twitter',
},
];
31 changes: 31 additions & 0 deletions src/hooks/useCopyToClipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';

type CopiedValue = string | null;
type CopyFn = (text: string) => Promise<boolean>; // Return success

/** @see https://usehooks-ts.com/react-hook/use-copy-to-clipboard */
export default function useCopyToClipboard(): [CopyFn, CopiedValue] {
const [copiedText, setCopiedText] = React.useState<CopiedValue>(null);

const copy: CopyFn = async (text) => {
if (!navigator?.clipboard) {
// eslint-disable-next-line no-console
console.warn('Clipboard not supported');
return false;
}

// Try to save to clipboard then save it in the state if worked
try {
await navigator.clipboard.writeText(text);
setCopiedText(text);
return true;
} catch (error) {
// eslint-disable-next-line no-console
console.warn('Copy failed', error);
setCopiedText(null);
return false;
}
};

return [copy, copiedText];
}
20 changes: 16 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10930,6 +10930,11 @@ polished@^4.2.2:
dependencies:
"@babel/runtime" "^7.17.8"

popper.js@^1.11.1:
version "1.16.1"
resolved "https://verdaccio.mein-recycling.de/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==

postcss-import@^15.1.0:
version "15.1.0"
resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-15.1.0.tgz#41c64ed8cc0e23735a9698b3249ffdbf704adc70"
Expand Down Expand Up @@ -11336,10 +11341,10 @@ react-headroom@^3.2.1:
raf "^3.3.0"
shallowequal "^1.1.0"

react-icons@^4.8.0:
version "4.8.0"
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.8.0.tgz#621e900caa23b912f737e41be57f27f6b2bff445"
integrity sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==
react-icons@^4.10.1:
version "4.10.1"
resolved "https://verdaccio.mein-recycling.de/react-icons/-/react-icons-4.10.1.tgz#3f3b5eec1f63c1796f6a26174a1091ca6437a500"
integrity sha512-/ngzDP/77tlCfqthiiGNZeYFACw85fUjZtLbedmJ5DTlNDIwETxhwBzdOJ21zj4iJdvc0J3y7yOsX3PpxAJzrw==

react-inspector@^6.0.0:
version "6.0.2"
Expand Down Expand Up @@ -11371,6 +11376,13 @@ react-refresh@^0.11.0:
resolved "https://verdaccio.mein-recycling.de/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==

react-tippy@^1.4.0:
version "1.4.0"
resolved "https://verdaccio.mein-recycling.de/react-tippy/-/react-tippy-1.4.0.tgz#e8a8b4085ec985e5c94fe128918b733b588a1465"
integrity sha512-r/hM5XK9Ztr2ZY7IWKuRmISTlUPS/R6ddz6PO2EuxCgW+4JBcGZRPU06XcVPRDCOIiio8ryBQFrXMhFMhsuaHA==
dependencies:
popper.js "^1.11.1"

react-transition-group@^4.4.5:
version "4.4.5"
resolved "https://verdaccio.mein-recycling.de/react-transition-group/-/react-transition-group-4.4.5.tgz#e53d4e3f3344da8521489fbef8f2581d42becdd1"
Expand Down

0 comments on commit 4547d5f

Please sign in to comment.