0
0
mirror of https://github.com/yude-jp/yude.jp synced 2024-12-22 20:20:09 +09:00
yude.jp/pages/components/Profile/PublicKeys.js

91 lines
3.5 KiB
JavaScript
Raw Normal View History

2021-12-11 18:55:57 +09:00
// React
2021-05-30 11:13:23 +09:00
import React, { useState, useEffect } from 'react';
2021-12-11 18:55:57 +09:00
// i18n
import { useTranslation, useLanguageQuery } from 'next-export-i18n';
// Font Awesome
2021-05-30 11:13:23 +09:00
import { faKey, faEye, faDownload } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
2021-12-11 18:55:57 +09:00
// Next.js
2021-05-30 11:13:23 +09:00
import Link from 'next/link'
export default function Modal() {
const [showModal, setShowModal] = React.useState(false);
2021-12-11 18:55:57 +09:00
const { t } = useTranslation();
const [query] = useLanguageQuery();
2021-05-30 11:13:23 +09:00
return (
<>
<button
className="bg-pink-600 text-white active:bg-pink-600 font-bold text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button"
onClick={() => setShowModal(true)}
>
2021-12-11 18:55:57 +09:00
<FontAwesomeIcon icon={faKey} className="w-5 h-5 inline"/> {t('keys')}
2021-05-30 11:13:23 +09:00
</button>
{showModal ? (
<>
<div
className="justify-center items-center flex overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none"
>
<div className="relative mx-auto w-4/5 max-h-1/2 -mt-96 max-w-3xl">
{/* Modal content */}
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
{/* Modal body */}
<div className="relative p-2 flex-auto text-black text-left">
2021-12-11 18:55:57 +09:00
<p className="text-2xl"><FontAwesomeIcon icon={faKey} className="w-5 h-5 inline"/> {t('keys')}</p>
2021-05-30 11:13:23 +09:00
<ul className="list-disc my-2">
<li>
<span className="font-bold">PGP&nbsp;</span>
<Link href="/yudejp.gpg">
2021-05-30 11:13:23 +09:00
<a className="hover:underline">
<FontAwesomeIcon icon={faDownload} className="w-5 h-5 inline"/>&nbsp;
2021-12-11 18:55:57 +09:00
{t('download')}
2021-05-30 11:13:23 +09:00
</a>
</Link>
2021-12-11 18:55:57 +09:00
<p>{t('fingerprint')}:</p>
2021-05-30 11:13:23 +09:00
<div className="overflow-x-auto">
<div className="whitespace-nowrap">
<code>3745 F270 DB4E 8975 6B07 62BE EB0F E5D9 25C4 A968</code>
</div>
</div>
</li>
<li>
<span className="font-bold">SSH&nbsp;</span>
<Link href="https://github.com/yude.keys">
<a className="hover:underline">
<FontAwesomeIcon icon={faEye} className="w-5 h-5 inline"/>&nbsp;
2021-12-11 18:55:57 +09:00
{t('view')}
2021-05-30 11:13:23 +09:00
</a>
</Link>
2021-12-11 18:55:57 +09:00
<p>{t('fingerprint')}:</p>
2021-05-30 11:13:23 +09:00
<div className="overflow-x-auto">
<div className="whitespace-nowrap">
<code>2048 SHA256:xwSL4DORWmroWdC6P0GU1m1yZl/cXqjo9rCCWqqO+Dc</code>
</div>
</div>
</li>
</ul>
</div>
{/* Modal footer for close button */}
<div className="flex items-center justify-end p-6 border-t border-solid border-blueGray-200 rounded-b">
<button
className="text-red-500 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
type="button"
onClick={() => setShowModal(false)}
>
2021-12-11 18:55:57 +09:00
{t('close')}
2021-05-30 11:13:23 +09:00
</button>
</div>
</div>
</div>
</div>
</>
) : null}
</>
);
}