From 4ac3d1c6842463ad2b1a46d6980b4452ca38bc0b Mon Sep 17 00:00:00 2001 From: Travis Kuhl Date: Thu, 23 May 2024 07:34:05 -0700 Subject: [PATCH 1/2] mobile layouts for www and docs --- apps/www/src/app/desktop/download/route.ts | 78 ++++++++++++++++++++-- apps/www/src/app/desktop/route.ts | 3 + apps/www/src/app/layout.tsx | 2 +- apps/www/src/app/page.tsx | 8 +-- 4 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 apps/www/src/app/desktop/route.ts diff --git a/apps/www/src/app/desktop/download/route.ts b/apps/www/src/app/desktop/download/route.ts index 5f06cde..9fe78e0 100644 --- a/apps/www/src/app/desktop/download/route.ts +++ b/apps/www/src/app/desktop/download/route.ts @@ -1,6 +1,16 @@ -export async function GET() { +import {type NextRequest} from 'next/server'; +import type {JsonObject} from '@elwood/common'; + +type Platform = 'mac' | 'win' | 'linux'; + +export async function GET(request: NextRequest) { + const searchParams = request.nextUrl.searchParams; + const p = (searchParams.get('p') ?? 'mac') as Platform; + const a = searchParams.get('a') ?? 'default'; + const f = searchParams.get('f') ?? 'zip'; + const response = await fetch( - 'https://api.github.com/repos/elwood-software/desktop/releases', + 'https://api.github.com/repos/elwood-software/desktop/releases?per_page=1', { method: 'GET', headers: { @@ -11,10 +21,64 @@ export async function GET() { }, ); - console.log(await response.text()); + const body = (await response.json()) as Array<{ + tag_name: string; + assets: Array<{ + name: string; + browser_download_url: string; + }>; + }>; - return Response.redirect( - 'https://github.com/elwood-software/desktop/releases/download/v0.0.1/Elwood-0.0.1.dmg', - 302, - ); + const urls: Record = { + mac: { + arm64: { + dmg: '', + zip: '', + }, + default: { + dmg: '', + zip: '', + }, + }, + win: { + x64: { + exe: '', + zip: '', + }, + }, + linux: { + x64: { + deb: '', + rpm: '', + tar: '', + }, + }, + }; + + for (const asset of body[0].assets) { + if (asset.name.endsWith('arm64.dmg')) { + urls.mac.arm64.dmg = asset.browser_download_url; + } else if (asset.name.endsWith('arm64-mac.zip')) { + urls.mac.arm64.zip = asset.browser_download_url; + } else if (asset.name.endsWith('.dmg')) { + urls.mac.default.dmg = asset.browser_download_url; + } else if (asset.name.endsWith('mac.zip')) { + urls.mac.default.zip = asset.browser_download_url; + } + } + + if (request.headers.get('accept') === 'application/json') { + return Response.json({ + v: body[0].tag_name, + urls, + }); + } + + const url = urls[p][a][f] ?? null; + + if (url) { + return Response.redirect(url, 302); + } + + return Response.redirect('/desktop?error=unknown', 302); } diff --git a/apps/www/src/app/desktop/route.ts b/apps/www/src/app/desktop/route.ts new file mode 100644 index 0000000..4a98dba --- /dev/null +++ b/apps/www/src/app/desktop/route.ts @@ -0,0 +1,3 @@ +export async function GET() { + return Response.redirect('https://github.com/elwood-software/desktop', 302); +} diff --git a/apps/www/src/app/layout.tsx b/apps/www/src/app/layout.tsx index 63878cc..b12eb52 100644 --- a/apps/www/src/app/layout.tsx +++ b/apps/www/src/app/layout.tsx @@ -18,7 +18,7 @@ export default function RootLayout(props: PropsWithChildren): JSX.Element { return ( {props.children} diff --git a/apps/www/src/app/page.tsx b/apps/www/src/app/page.tsx index 7e1dcda..764fb2c 100644 --- a/apps/www/src/app/page.tsx +++ b/apps/www/src/app/page.tsx @@ -10,7 +10,7 @@ export default function Page() {
-

+

Elwood @@ -29,7 +29,7 @@ export default function Page() { variant="default" size="lg" href="/desktop/download" - className="w-full md:w-auto"> + className="w-full md:w-auto hidden md:inline-flex"> Download for Desktop

-
+
-
+
© The Elwood Technology Company
From f8a1fd67cac9c96c7856a496066982a342cdbad1 Mon Sep 17 00:00:00 2001 From: Travis Kuhl Date: Thu, 23 May 2024 09:47:03 -0700 Subject: [PATCH 2/2] docs and www fixes --- apps/docs/src/app/docs/desktop/page.md | 13 +++++++++++++ apps/docs/src/app/layout.tsx | 1 + apps/docs/src/components/DocsHeader.tsx | 2 +- apps/docs/src/components/Icon.tsx | 2 +- apps/docs/src/components/Layout.tsx | 15 +++++++++++---- apps/docs/src/components/Navigation.tsx | 6 +++--- apps/docs/src/lib/navigation.ts | 5 +++++ apps/docs/src/styles/tailwind.css | 5 ++++- apps/docs/tailwind.config.ts | 1 + packages/react/src/provider.tsx | 3 ++- 10 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 apps/docs/src/app/docs/desktop/page.md diff --git a/apps/docs/src/app/docs/desktop/page.md b/apps/docs/src/app/docs/desktop/page.md new file mode 100644 index 0000000..7805ee0 --- /dev/null +++ b/apps/docs/src/app/docs/desktop/page.md @@ -0,0 +1,13 @@ +--- +title: Desktop +--- + +Elwood... but on your desktop. 🤯 {% .lead %} + +{% quick-links %} + +{% quick-link title="Install for Mac" icon="installation" href="https://elwood.software/desktop/download?p=mac" description="Download for macOS" /%} + +{% quick-link title="More Information" icon="plugins" href="https://github.com/elwood-software/desktop" description="Get more info in the repo." /%} + +{% /quick-links %} diff --git a/apps/docs/src/app/layout.tsx b/apps/docs/src/app/layout.tsx index 6b5f570..9295153 100644 --- a/apps/docs/src/app/layout.tsx +++ b/apps/docs/src/app/layout.tsx @@ -7,6 +7,7 @@ import clsx from 'clsx'; import {Providers} from '@/app/providers'; import {Layout} from '@/components/Layout'; +import '@elwood/ui/style.css'; import '@/styles/tailwind.css'; const inter = Inter({ diff --git a/apps/docs/src/components/DocsHeader.tsx b/apps/docs/src/components/DocsHeader.tsx index e69bbc1..db560db 100644 --- a/apps/docs/src/components/DocsHeader.tsx +++ b/apps/docs/src/components/DocsHeader.tsx @@ -17,7 +17,7 @@ export function DocsHeader({title}: {title?: string}) { return (
{section && ( -

+

{section.title}

)} diff --git a/apps/docs/src/components/Icon.tsx b/apps/docs/src/components/Icon.tsx index 782d96d..f1c4840 100644 --- a/apps/docs/src/components/Icon.tsx +++ b/apps/docs/src/components/Icon.tsx @@ -18,7 +18,7 @@ const icons = { }; const iconStyles = { - blue: '[--icon-foreground:theme(colors.slate.900)] [--icon-background:theme(colors.white)]', + blue: '[--icon-foreground:theme(colors.brand)] [--icon-background:theme(colors.white)]', amber: '[--icon-foreground:theme(colors.amber.900)] [--icon-background:theme(colors.amber.100)]', }; diff --git a/apps/docs/src/components/Layout.tsx b/apps/docs/src/components/Layout.tsx index c252aa8..8cd8af9 100644 --- a/apps/docs/src/components/Layout.tsx +++ b/apps/docs/src/components/Layout.tsx @@ -38,14 +38,21 @@ function Header(): JSX.Element { 'sticky top-0 z-50 flex flex-none flex-wrap items-center justify-between bg-background px-4 py-5 shadow-md shadow-slate-900/5 transition duration-500 dark:shadow-none sm:px-6 lg:px-8', isScrolled ? 'dark:bg-background/95 dark:backdrop-blur dark:[@supports(backdrop-filter:blur(0))]:bg-background/75' - : 'dark:bg-transparent', + : 'dark:bg-background/95', )}>
-
+
- + + + + + Home + + + Docs
{/* */}
@@ -53,7 +60,7 @@ function Header(): JSX.Element { {/* */} hello@elwood.software diff --git a/apps/docs/src/components/Navigation.tsx b/apps/docs/src/components/Navigation.tsx index dcaef84..38ad56d 100644 --- a/apps/docs/src/components/Navigation.tsx +++ b/apps/docs/src/components/Navigation.tsx @@ -23,7 +23,7 @@ export function Navigation({
    + className="mt-2 space-y-2 border-l-2 lg:mt-4 lg:space-y-4"> {section.links.map(link => (
  • {link.title} diff --git a/apps/docs/src/lib/navigation.ts b/apps/docs/src/lib/navigation.ts index bd268ac..a6f25fc 100644 --- a/apps/docs/src/lib/navigation.ts +++ b/apps/docs/src/lib/navigation.ts @@ -7,6 +7,11 @@ export const navigation = [ {title: 'Support', href: '/docs/support'}, ], }, + { + title: 'Desktop', + + links: [{title: 'Install', href: '/docs/desktop'}], + }, { title: 'Development', diff --git a/apps/docs/src/styles/tailwind.css b/apps/docs/src/styles/tailwind.css index b6a6242..cd4eef8 100644 --- a/apps/docs/src/styles/tailwind.css +++ b/apps/docs/src/styles/tailwind.css @@ -2,9 +2,12 @@ @import './prism.css'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; -@import '@elwood/ui/style.css'; @layer base { + * { + @apply border-border; + } + [inert] ::-webkit-scrollbar { display: none; } diff --git a/apps/docs/tailwind.config.ts b/apps/docs/tailwind.config.ts index 2cfcab3..8a327a8 100644 --- a/apps/docs/tailwind.config.ts +++ b/apps/docs/tailwind.config.ts @@ -34,6 +34,7 @@ export default { maxWidth: { '8xl': '88rem', }, + colors: themeExtend.colors, }, }, plugins: [...Array.from(plugins as PluginCreator[]), typographyPlugin], diff --git a/packages/react/src/provider.tsx b/packages/react/src/provider.tsx index 5dd5f77..08e1cc7 100644 --- a/packages/react/src/provider.tsx +++ b/packages/react/src/provider.tsx @@ -10,6 +10,7 @@ import {Spinner} from '@elwood/ui'; import {ProviderContext, type ProviderContextValue} from '@/context'; import {NoAccess} from '@/components/no-access'; import {defaultRenders} from '@/renderer/default-renderers'; +import {MainLayout} from '@/components/layouts/main'; export type ElwoodProviderProps = Omit< ProviderContextValue, @@ -85,7 +86,7 @@ export function ElwoodProvider( } if (member === null) { - return ; + return ; } return (