From 27d9c6350a696bcc7e4b9c346f92172ac275824d Mon Sep 17 00:00:00 2001
From: Snazzah <7025343+Snazzah@users.noreply.github.com>
Date: Sun, 29 May 2022 20:56:47 +0000
Subject: [PATCH] feat: add Hex.pm card

---
 public/locales/en/translation.json       |  3 ++-
 src/components/Welcome.tsx               |  3 ++-
 src/components/cards/index.tsx           |  2 ++
 src/components/cards/providers/HexPm.tsx | 32 ++++++++++++++++++++++++
 src/util/i18n.ts                         |  2 +-
 5 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 src/components/cards/providers/HexPm.tsx

diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json
index 88fa8e1..c7c1d60 100644
--- a/public/locales/en/translation.json
+++ b/public/locales/en/translation.json
@@ -48,7 +48,8 @@
     "cloudflare": "Cloudflare Pages",
     "chromeWebStore": "Chrome Web Store",
     "firefoxAddons": "Firefox Add-ons",
-    "youtube": "YouTube"
+    "youtube": "YouTube",
+    "hexpm": "Hex"
   },
   "showMore": "show more",
   "try": "How about this?",
diff --git a/src/components/Welcome.tsx b/src/components/Welcome.tsx
index fbbd170..76ed94c 100644
--- a/src/components/Welcome.tsx
+++ b/src/components/Welcome.tsx
@@ -19,7 +19,7 @@ import {
 import { IoIosBeer, IoMdAppstore } from 'react-icons/io';
 import { MdDomain } from 'react-icons/md';
 import { RiBuilding2Fill, RiChromeFill, RiNpmjsFill } from 'react-icons/ri';
-import { SiDeno } from 'react-icons/si';
+import { SiDeno, SiElixir } from 'react-icons/si';
 import {
   SiAppstore,
   SiArchlinux,
@@ -46,6 +46,7 @@ const supportedProviders: Record<string, React.ReactNode> = {
   rust: <SiRust />,
   pypi: <FaPython />,
   rubygems: <SiRubygems />,
+  hexpm: <SiElixir />,
   ocaml: <OcamlIcon />,
   archlinux: <SiArchlinux />,
   ubuntu: <SiUbuntu />,
diff --git a/src/components/cards/index.tsx b/src/components/cards/index.tsx
index bc812a2..5312b71 100644
--- a/src/components/cards/index.tsx
+++ b/src/components/cards/index.tsx
@@ -13,6 +13,7 @@ import GithubCard from './providers/GitHubOrganization';
 import GithubSearchCard from './providers/GitHubSearch';
 import GitLabCard from './providers/GitLab';
 import HerokuCard from './providers/Heroku';
+import HexPmCard from './providers/HexPm';
 import HomebrewCard from './providers/Homebrew';
 // import InstagramCard from './providers/Instagram';
 import JsOrgCard from './providers/JsOrg';
@@ -50,6 +51,7 @@ const Index: React.FC<{ query: string }> = ({ query }) => {
         <PypiCard query={query} />
         <CratesioCard query={query} />
         <RubyGemsCard query={query} />
+        <HexPmCard query={query} />
         <LinuxCard query={query} />
         <OcamlCard query={query} />
         <VercelCard query={query} />
diff --git a/src/components/cards/providers/HexPm.tsx b/src/components/cards/providers/HexPm.tsx
new file mode 100644
index 0000000..bd6add2
--- /dev/null
+++ b/src/components/cards/providers/HexPm.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+import { SiElixir } from 'react-icons/si';
+import { normalize } from '../../../util/text';
+import { Card, DedicatedAvailability, Repeater } from '../core';
+
+const HexPmCard: React.FC<{ query: string }> = ({ query }) => {
+  const { t } = useTranslation();
+  const normalizedQuery = normalize(query);
+  const lowerCase = normalizedQuery.toLowerCase();
+  const names = [normalizedQuery];
+  const moreNames = [`${lowerCase}-ex`];
+
+  return (
+    <Card title={t('providers.hexpm')}>
+      <Repeater items={names} moreItems={moreNames}>
+        {(name) => (
+          <DedicatedAvailability
+            name={name}
+            query={`hex.pm/packages/${name}`}
+            service="existence"
+            message="Go to Hex"
+            link={`https://hex.pm/packages/${name}`}
+            icon={<SiElixir />}
+          />
+        )}
+      </Repeater>
+    </Card>
+  );
+};
+
+export default HexPmCard;
diff --git a/src/util/i18n.ts b/src/util/i18n.ts
index 4ef054b..62f46dd 100644
--- a/src/util/i18n.ts
+++ b/src/util/i18n.ts
@@ -5,7 +5,7 @@ import XHR from 'i18next-xhr-backend';
 import LanguageDetector from 'i18next-browser-languagedetector';
 import { initReactI18next } from 'react-i18next';
 
-const TRANSLATION_VERSION = '14';
+const TRANSLATION_VERSION = '15';
 
 i18n
   .use(Backend)