1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-07 00:16:00 +09:00

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-08-31 08:41:53 +09:00
import React from 'react';
import { useTranslation } from 'react-i18next';
2020-08-31 09:45:16 +09:00
import { RiNpmjsFill, RiNpmjsLine } from 'react-icons/ri';
2021-02-25 15:13:15 +09:00
import { normalize } from '../../../util/text';
2020-08-31 09:45:16 +09:00
import { Card, DedicatedAvailability, Repeater } from '../core';
2019-07-31 13:11:00 +09:00
2020-08-20 00:57:33 +09:00
const NpmCard: React.FC<{ query: string }> = ({ query }) => {
2020-08-31 08:41:53 +09:00
const { t } = useTranslation();
2021-02-25 15:13:15 +09:00
const normalizedQuery = normalize(query, {
allowUnderscore: false,
});
const lowerCase = normalizedQuery.toLowerCase();
2019-07-31 13:11:00 +09:00
2021-02-25 15:44:36 +09:00
const names = [lowerCase];
const moreNames = [`${lowerCase}-js`, `${lowerCase}js`];
2019-08-06 00:45:18 +09:00
2019-07-31 13:11:00 +09:00
return (
2019-08-06 00:45:18 +09:00
<Card title={t('providers.npm')}>
<Repeater items={names} moreItems={moreNames}>
{(name) => (
<>
<DedicatedAvailability
name={name}
service="npm"
2020-06-11 22:00:16 +09:00
message={`See ${name}`}
link={`https://www.npmjs.com/package/${name}`}
2019-08-07 22:25:51 +09:00
messageIfTaken={`See ${name}`}
linkIfTaken={`https://www.npmjs.com/package/${name}`}
2020-08-31 09:45:16 +09:00
icon={<RiNpmjsFill />}
2019-08-06 00:45:18 +09:00
/>
<DedicatedAvailability
name={name}
service="npm-org"
2019-08-07 22:25:51 +09:00
message="Create Org"
link="https://www.npmjs.com/org/create"
messageIfTaken={`See @${name}`}
linkIfTaken={`https://www.npmjs.com/org/${name}`}
2019-08-06 00:45:18 +09:00
prefix="@"
suffix=" (Organization)"
2020-08-31 09:45:16 +09:00
icon={<RiNpmjsLine />}
2019-08-06 00:45:18 +09:00
/>
</>
)}
</Repeater>
2019-07-31 13:11:00 +09:00
</Card>
2020-08-31 08:41:53 +09:00
);
};
2019-09-01 01:28:24 +09:00
2020-08-31 08:41:53 +09:00
export default NpmCard;