inline svg and add mastodon

This commit is contained in:
Timothy Lin
2023-07-22 18:16:06 +08:00
parent d9f6f367fa
commit 1e19247ae1
11 changed files with 73 additions and 21 deletions
+10 -10
View File
@@ -1,11 +1,4 @@
import Mail from './mail.svg'
import Github from './github.svg'
import Facebook from './facebook.svg'
import Youtube from './youtube.svg'
import Linkedin from './linkedin.svg'
import Twitter from './twitter.svg'
// Icons taken from: https://simpleicons.org/
import { Mail, Github, Facebook, Youtube, Linkedin, Twitter, Mastodon } from './icons'
const components = {
mail: Mail,
@@ -14,9 +7,16 @@ const components = {
youtube: Youtube,
linkedin: Linkedin,
twitter: Twitter,
mastodon: Mastodon,
}
const SocialIcon = ({ kind, href, size = 8 }) => {
type SocialIconProps = {
kind: keyof typeof components
href: string | undefined
size?: number
}
const SocialIcon = ({ kind, href, size = 8 }: SocialIconProps) => {
if (!href || (kind === 'mail' && !/^mailto:\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/.test(href)))
return null
@@ -31,7 +31,7 @@ const SocialIcon = ({ kind, href, size = 8 }) => {
>
<span className="sr-only">{kind}</span>
<SocialSvg
className={`fill-current text-gray-700 hover:text-blue-500 dark:text-gray-200 dark:hover:text-blue-400 h-${size} w-${size}`}
className={`fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-${size} w-${size}`}
/>
</a>
)