65 lines
4.4 KiB
TypeScript
65 lines
4.4 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
|
|
/* eslint-disable-next-line */
|
|
export interface PluginCardProps {
|
|
name: string;
|
|
description: string;
|
|
url: string;
|
|
}
|
|
|
|
export function PluginCard({ name, description, url }: PluginCardProps) {
|
|
const [copied, setCopied] = useState(false);
|
|
useEffect(() => {
|
|
let t: NodeJS.Timeout;
|
|
if (copied) {
|
|
t = setTimeout(() => {
|
|
setCopied(false);
|
|
}, 3000);
|
|
}
|
|
return () => {
|
|
t && clearTimeout(t);
|
|
};
|
|
}, [copied]);
|
|
return (
|
|
<div className="w-full flex flex-col place-content-between py-8 px-6 border border-gray-100 rounded-md">
|
|
<h3 className="text-lg font-semibold leading-tight mb-4">{name}</h3>
|
|
<p className="sm:text-lg mb-6">{description}</p>
|
|
<div className="grid grid-cols-3 justify-items-center">
|
|
<a href={url} target="_blank" rel="nofollow" title="Github repository">
|
|
<svg className="w-6 h-6 text-gray-800">
|
|
<path
|
|
id="github"
|
|
d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"
|
|
/>
|
|
</svg>
|
|
</a>
|
|
<CopyToClipboard
|
|
text={'yarn add -D ' + name}
|
|
onCopy={() => setCopied(true)}
|
|
>
|
|
<svg className="w-6 h-6 fill-current text-blue-500 cursor-pointer">
|
|
<path
|
|
id="yarn"
|
|
d="M12 0C5.375 0 0 5.375 0 12s5.375 12 12 12 12-5.375 12-12S18.625 0 12 0zm.768 4.105c.183 0 .363.053.525.157.125.083.287.185.755 1.154.31-.088.468-.042.551-.019.204.056.366.19.463.375.477.917.542 2.553.334 3.605-.241 1.232-.755 2.029-1.131 2.576.324.329.778.899 1.117 1.825.278.774.31 1.478.273 2.015a5.51 5.51 0 0 0 .602-.329c.593-.366 1.487-.917 2.553-.931.714-.009 1.269.445 1.353 1.103a1.23 1.23 0 0 1-.945 1.362c-.649.158-.95.278-1.821.843-1.232.797-2.539 1.242-3.012 1.39a1.686 1.686 0 0 1-.704.343c-.737.181-3.266.315-3.466.315h-.046c-.783 0-1.214-.241-1.45-.491-.658.329-1.51.19-2.122-.134a1.078 1.078 0 0 1-.58-1.153 1.243 1.243 0 0 1-.153-.195c-.162-.25-.528-.936-.454-1.946.056-.723.556-1.367.88-1.71a5.522 5.522 0 0 1 .408-2.256c.306-.727.885-1.348 1.32-1.737-.32-.537-.644-1.367-.329-2.21.227-.602.412-.936.82-1.08h-.005c.199-.074.389-.153.486-.259a3.418 3.418 0 0 1 2.298-1.103c.037-.093.079-.185.125-.283.31-.658.639-1.029 1.024-1.168a.94.94 0 0 1 .328-.06zm.006.7c-.507.016-1.001 1.519-1.001 1.519s-1.27-.204-2.266.871c-.199.218-.468.334-.746.44-.079.028-.176.023-.417.672-.371.991.625 2.094.625 2.094s-1.186.839-1.626 1.881c-.486 1.144-.338 2.261-.338 2.261s-.843.732-.899 1.487c-.051.663.139 1.2.343 1.515.227.343.51.176.51.176s-.561.653-.037.931c.477.25 1.283.394 1.71-.037.31-.31.371-1.001.486-1.283.028-.065.12.111.209.199.097.093.264.195.264.195s-.755.324-.445 1.066c.102.246.468.403 1.066.398.222-.005 2.664-.139 3.313-.296.375-.088.505-.283.505-.283s1.566-.431 2.998-1.357c.917-.598 1.293-.76 2.034-.936.612-.148.57-1.098-.241-1.084-.839.009-1.575.44-2.196.825-1.163.718-1.742.672-1.742.672l-.018-.032c-.079-.13.371-1.293-.134-2.678-.547-1.515-1.413-1.881-1.344-1.997.297-.5 1.038-1.297 1.334-2.78.176-.899.13-2.377-.269-3.151-.074-.144-.732.241-.732.241s-.616-1.371-.788-1.483a.271.271 0 0 0-.157-.046z"
|
|
/>
|
|
</svg>
|
|
</CopyToClipboard>
|
|
<CopyToClipboard
|
|
text={'yarn add -D ' + name}
|
|
onCopy={() => setCopied(true)}
|
|
>
|
|
<svg className="w-6 h-6 fill-current text-red-500 cursor-pointer">
|
|
<path
|
|
id="npm"
|
|
d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z"
|
|
/>
|
|
</svg>
|
|
</CopyToClipboard>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default PluginCard;
|