Skip to content

Commit

Permalink
Fixing EMFILE issue by removing react-simple-icons (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
naps62 authored Feb 13, 2025
1 parent 20e1554 commit 00f5bc8
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 7,339 deletions.
6 changes: 5 additions & 1 deletion app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import tsConfigPaths from "vite-tsconfig-paths";
export default defineConfig({
server: { preset: "vercel" },
vite: {
plugins: [tsConfigPaths()],
plugins: [
tsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
},
});
4 changes: 2 additions & 2 deletions app/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
createStartAPIHandler,
defaultAPIFileRouteHandler,
} from '@tanstack/start/api'
} from "@tanstack/start/api";

export default createStartAPIHandler(defaultAPIFileRouteHandler)
export default createStartAPIHandler(defaultAPIFileRouteHandler);
10 changes: 5 additions & 5 deletions app/client.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StartClient } from "@tanstack/start";
/// <reference types="vinxi/types/client" />
import { hydrateRoot } from 'react-dom/client'
import { StartClient } from '@tanstack/start'
import { createRouter } from './router'
import { hydrateRoot } from "react-dom/client";
import { createRouter } from "./router";

const router = createRouter()
const router = createRouter();

hydrateRoot(document, <StartClient router={router} />)
hydrateRoot(document, <StartClient router={router} />);
11 changes: 6 additions & 5 deletions app/components/DefaultCatchBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
console.error("DefaultCatchBoundary Error:", error);

return (
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
<div className="flex min-w-0 flex-1 flex-col items-center justify-center gap-6 p-4">
<ErrorComponent error={error} />
<div className="flex gap-2 items-center flex-wrap">
<div className="flex flex-wrap items-center gap-2">
<button
type="button"
onClick={() => {
router.invalidate();
}}
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
className="rounded bg-gray-600 px-2 py-1 font-extrabold text-white uppercase dark:bg-gray-700"
>
Try Again
</button>
{isRoot ? (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
className="rounded bg-gray-600 px-2 py-1 font-extrabold text-white uppercase dark:bg-gray-700"
>
Home
</Link>
) : (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
className="rounded bg-gray-600 px-2 py-1 font-extrabold text-white uppercase dark:bg-gray-700"
onClick={(e) => {
e.preventDefault();
window.history.back();
Expand Down
11 changes: 6 additions & 5 deletions app/components/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { Link } from '@tanstack/react-router'
import { Link } from "@tanstack/react-router";

export function NotFound({ children }: { children?: any }) {
return (
<div className="space-y-2 p-2">
<div className="text-gray-600 dark:text-gray-400">
{children || <p>The page you are looking for does not exist.</p>}
</div>
<p className="flex items-center gap-2 flex-wrap">
<p className="flex flex-wrap items-center gap-2">
<button
type="button"
onClick={() => window.history.back()}
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
className="rounded bg-emerald-500 px-2 py-1 font-black text-sm text-white uppercase"
>
Go back
</button>
<Link
to="/"
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
className="rounded bg-cyan-600 px-2 py-1 font-black text-sm text-white uppercase"
>
Start Over
</Link>
</p>
</div>
)
);
}
4 changes: 2 additions & 2 deletions app/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SiGithub } from "@icons-pack/react-simple-icons";
import { GithubIcon } from "#/components/icons";
import { Link } from "@tanstack/react-router";

export function Header() {
Expand All @@ -18,7 +18,7 @@ export function Header() {
className="font-medium text-sm underline-offset-4 hover:underline"
to="https://github.com/ethui/ethui"
>
<SiGithub className="inline h-6 w-6" />
<GithubIcon className="inline h-6 w-6" />
</Link>
</nav>
</header>
Expand Down
34 changes: 34 additions & 0 deletions app/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { type ComponentPropsWithoutRef, forwardRef } from "react";
import {
siApple,
siFirefoxbrowser,
siGithub,
siGooglechrome,
siLinux,
type SimpleIcon,
} from "simple-icons";

function generateIcon(icon: SimpleIcon) {
return forwardRef<SVGSVGElement, ComponentPropsWithoutRef<"svg">>(
(props, ref) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
ref={ref}
fill="currentColor"
{...props}
>
<title>{icon.title}</title>
<path d={icon.path} />
</svg>
);
},
);
}

export const GithubIcon = generateIcon(siGithub);
export const AppleIcon = generateIcon(siApple);
export const LinuxIcon = generateIcon(siLinux);
export const FirefoxIcon = generateIcon(siFirefoxbrowser);
export const GoogleChromeIcon = generateIcon(siGooglechrome);
18 changes: 9 additions & 9 deletions app/router.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { createRouter as createTanStackRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'
import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
import { NotFound } from './components/NotFound'
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
import { DefaultCatchBoundary } from "./components/DefaultCatchBoundary";
import { NotFound } from "./components/NotFound";
import { routeTree } from "./routeTree.gen";

export function createRouter() {
const router = createTanStackRouter({
routeTree,
defaultPreload: 'intent',
defaultPreload: "intent",
defaultErrorComponent: DefaultCatchBoundary,
defaultNotFoundComponent: () => <NotFound />,
scrollRestoration: true,
})
});

return router
return router;
}

declare module '@tanstack/react-router' {
declare module "@tanstack/react-router" {
interface Register {
router: ReturnType<typeof createRouter>
router: ReturnType<typeof createRouter>;
}
}
6 changes: 3 additions & 3 deletions app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Header } from "#/components/header";
import appCss from "@ethui/ui/tailwind.css?url";
import rainbowkiwCss from "@rainbow-me/rainbowkit/styles.css?url";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Outlet, createRootRoute } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
import { Meta, Scripts } from "@tanstack/start";
import { DefaultCatchBoundary } from "#/components/DefaultCatchBoundary";
import { NotFound } from "#/components/NotFound";
import appCss from "@ethui/ui/tailwind.css?url";
import rainbowkiwCss from "@rainbow-me/rainbowkit/styles.css?url";
import { Header } from "#/components/header";
import { seo } from "#/utils/seo";

export const Route = createRootRoute({
Expand Down
8 changes: 4 additions & 4 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppleIcon, LinuxIcon } from "#/components/icons";
import { Button } from "@ethui/ui/components/shadcn/button";
import { SiApple, SiLinux } from "@icons-pack/react-simple-icons";
import { createFileRoute, Link } from "@tanstack/react-router";
import { Link, createFileRoute } from "@tanstack/react-router";
import { useEffect, useState } from "react";

export const Route = createFileRoute("/")({
Expand Down Expand Up @@ -61,7 +61,7 @@ function Home() {
rel="noreferrer"
download={data?.osx?.name}
>
<SiApple className="mr-1" />
<AppleIcon className="mr-1" />
Download
</a>
</Button>
Expand All @@ -72,7 +72,7 @@ function Home() {
rel="noreferrer"
download={data?.linux?.name}
>
<SiLinux className="mr-1" />
<LinuxIcon className="mr-1" />
Download
</Link>
</Button>
Expand Down
14 changes: 5 additions & 9 deletions app/routes/onboarding/extension/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Button } from "@ethui/ui/components/shadcn/button";
import {
SiFirefoxbrowser,
SiGithub,
SiGooglechrome,
} from "@icons-pack/react-simple-icons";
import { FirefoxIcon, GithubIcon, GoogleChromeIcon } from "#/components/icons";
import {
ConnectButton,
RainbowKitProvider,
Expand Down Expand Up @@ -75,19 +71,19 @@ const DownloadLinks = () => {
<div className="flex gap-2">
<Button asChild>
<a href={CHROME_EXTENSION} rel="noreferrer" target="_blank">
<SiGooglechrome className="text-4xl" />
<GoogleChromeIcon className="text-4xl" />
<span className="pl-2">Chrome</span>
</a>
</Button>
<Button asChild>
<a href={FIREFOX_EXTENSION} rel="noreferrer" target="_blank">
<SiFirefoxbrowser className="text-4xl" />
<FirefoxIcon className="text-4xl" />
<span className="pl-2">Firefox</span>
</a>
</Button>
<Button asChild>
<a href={GITHUB_LATEST_RELEASE} rel="noreferrer" target="_blank">
<SiGithub className="text-4xl" />
<GithubIcon className="text-4xl" />
<span className="pl-2">From Github</span>
</a>
</Button>
Expand All @@ -99,7 +95,7 @@ const Refresh = () => {
return (
<div className="flex gap-2">
<Button asChild>
<Link to="/onboarding/extension?refresh=true">
<Link to="/onboarding/extension" search={{ refresh: true }}>
<span>Refresh now</span>
</Link>
</Button>
Expand Down
8 changes: 4 additions & 4 deletions app/ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getRouterManifest } from "@tanstack/start/router-manifest";
/// <reference types="vinxi/types/server" />
import {
createStartHandler,
defaultStreamHandler,
} from '@tanstack/start/server'
import { getRouterManifest } from '@tanstack/start/router-manifest'
} from "@tanstack/start/server";

import { createRouter } from './router'
import { createRouter } from "./router";

export default createStartHandler({
createRouter,
getRouterManifest,
})(defaultStreamHandler)
})(defaultStreamHandler);
20 changes: 10 additions & 10 deletions app/utils/loggingMiddleware.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createMiddleware } from '@tanstack/start'
import { createMiddleware } from "@tanstack/start";

export const logMiddleware = createMiddleware()
.client(async (ctx) => {
const clientTime = new Date()
const clientTime = new Date();

return ctx.next({
context: {
Expand All @@ -11,27 +11,27 @@ export const logMiddleware = createMiddleware()
sendContext: {
clientTime,
},
})
});
})
.server(async (ctx) => {
const serverTime = new Date()
const serverTime = new Date();

return ctx.next({
sendContext: {
serverTime,
durationToServer:
serverTime.getTime() - ctx.context.clientTime.getTime(),
},
})
});
})
.clientAfter(async (ctx) => {
const now = new Date()
const now = new Date();

console.log('Client Req/Res:', {
console.log("Client Req/Res:", {
duration: ctx.context.clientTime.getTime() - now.getTime(),
durationToServer: ctx.context.durationToServer,
durationFromServer: now.getTime() - ctx.context.serverTime.getTime(),
})
});

return ctx.next()
})
return ctx.next();
});
38 changes: 19 additions & 19 deletions app/utils/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ export const seo = ({
keywords,
image,
}: {
title: string
description?: string
image?: string
keywords?: string
title: string;
description?: string;
image?: string;
keywords?: string;
}) => {
const tags = [
{ title },
{ name: 'description', content: description },
{ name: 'keywords', content: keywords },
{ name: 'twitter:title', content: title },
{ name: 'twitter:description', content: description },
{ name: 'twitter:creator', content: '@tannerlinsley' },
{ name: 'twitter:site', content: '@tannerlinsley' },
{ name: 'og:type', content: 'website' },
{ name: 'og:title', content: title },
{ name: 'og:description', content: description },
{ name: "description", content: description },
{ name: "keywords", content: keywords },
{ name: "twitter:title", content: title },
{ name: "twitter:description", content: description },
{ name: "twitter:creator", content: "@tannerlinsley" },
{ name: "twitter:site", content: "@tannerlinsley" },
{ name: "og:type", content: "website" },
{ name: "og:title", content: title },
{ name: "og:description", content: description },
...(image
? [
{ name: 'twitter:image', content: image },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'og:image', content: image },
{ name: "twitter:image", content: image },
{ name: "twitter:card", content: "summary_large_image" },
{ name: "og:image", content: image },
]
: []),
]
];

return tags
}
return tags;
};
Loading

0 comments on commit 00f5bc8

Please sign in to comment.