From 5b76a0e89083c57188a70931ca4735250b6fb3a9 Mon Sep 17 00:00:00 2001 From: Andrew Marcuse Date: Thu, 10 Oct 2024 14:27:51 -0400 Subject: [PATCH] Support loading from local file system --- app/components/Footer.tsx | 4 ++-- app/routes/_index.tsx | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/components/Footer.tsx b/app/components/Footer.tsx index 0c79a4e..04964a4 100644 --- a/app/components/Footer.tsx +++ b/app/components/Footer.tsx @@ -49,10 +49,10 @@ export const Footer = () => { {link.label} - {link.label} + {link.label} ))} diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 237b9e4..a40b46b 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -15,6 +15,7 @@ import { FullPage } from "~/components/FullPage"; import { t } from "~/utils/i18n"; import { LinksFunction } from "@remix-run/node"; +import React from "react"; export const meta: MetaFunction = () => { return [ @@ -31,6 +32,19 @@ export const links: LinksFunction = () => { export default function HomePage() { const bg = useColorModeValue("white", "gray.700"); + const fileInput = React.useRef(null); + + const onFileChange = (e: React.ChangeEvent) => { + const file = e.target.files?.item(0); + if (file) { + const reader = new FileReader(); + reader.onload = () => { + const url = reader.result as string; + window.location.href = `/view.html?url=${encodeURIComponent(url)}`; + }; + reader.readAsDataURL(file); + } + } return ( @@ -43,10 +57,17 @@ export default function HomePage() { {t("view an SVG image from another website")} + + + + {t("view an SVG image from your computer")} +