From 6d6dd40cbafc9ee7685da99a36a453bf59784892 Mon Sep 17 00:00:00 2001 From: Andrew Powell Date: Sat, 20 Apr 2024 11:26:32 -0400 Subject: [PATCH] fix(app-preview): add logic for mobile sidebar and update ui (#190) Co-authored-by: Paul Ehikhuemen <67395687+lordelogos@users.noreply.github.com> --- apps/preview/app/src/components/nav.tsx | 117 +++++++++++++------- apps/preview/app/src/components/send.tsx | 2 +- apps/preview/app/src/components/shell.tsx | 20 ++-- apps/preview/app/src/components/sidebar.tsx | 25 ++++- 4 files changed, 110 insertions(+), 54 deletions(-) diff --git a/apps/preview/app/src/components/nav.tsx b/apps/preview/app/src/components/nav.tsx index 9a766d49..3879aae9 100644 --- a/apps/preview/app/src/components/nav.tsx +++ b/apps/preview/app/src/components/nav.tsx @@ -1,4 +1,4 @@ -import { Cross2Icon, QuestionMarkCircledIcon } from '@radix-ui/react-icons'; +import { Cross2Icon, QuestionMarkCircledIcon, HamburgerMenuIcon } from '@radix-ui/react-icons'; import * as Popover from '@radix-ui/react-popover'; import * as ToggleGroup from '@radix-ui/react-toggle-group'; import classnames from 'classnames'; @@ -12,50 +12,89 @@ import { NavButton } from './nav-button'; interface NavProps extends React.ComponentPropsWithoutRef<'header'> { activeView?: Views; markup?: string; + openNav: () => void; setActiveView?: (view: Views) => void; title: string; } export const Nav = React.forwardRef, Readonly>( - ({ className, title, markup, activeView, setActiveView, ...props }, forwardedRef) => ( -
- + ({ className, title, markup, activeView, setActiveView, openNav, ...props }, forwardedRef) => ( + <> +
+
+ + {!!title && ( + + )} +
-
- - - - - - -
- The Desktop and Mobile views are an approximation of what your email - template will looke like on various devices. It should not be considered a source of - truth, but rather a guide for styling and layout. Always send a test email to your - target email clients for Quality Control, before sending emails in production. -
- - - - -
-
-
+ {!!title && ( +
+ + + + + + +
+ The Desktop and Mobile views are an approximation of what your email + template will looke like on various devices. It should not be considered a + source of truth, but rather a guide for styling and layout. Always send a test + email to your target email clients for Quality Control, before sending emails in + production. +
+ + + + +
+
+
+ + {setActiveView && ( + { + if (value) setActiveView(value as Views); + }} + > + + + + + + + )} + +
+ )} +
+
{setActiveView && ( , Readonly
-
+ ) ); diff --git a/apps/preview/app/src/components/send.tsx b/apps/preview/app/src/components/send.tsx index 8b3c6d95..eb106b77 100644 --- a/apps/preview/app/src/components/send.tsx +++ b/apps/preview/app/src/components/send.tsx @@ -70,7 +70,7 @@ export const Send: React.FC = ({ markup }) => {
diff --git a/apps/preview/app/src/components/shell.tsx b/apps/preview/app/src/components/shell.tsx index ea9d5c81..83251b05 100644 --- a/apps/preview/app/src/components/shell.tsx +++ b/apps/preview/app/src/components/shell.tsx @@ -18,12 +18,13 @@ interface ShellProps extends RootProps { export const Shell = React.forwardRef>( ({ title, templateParts, children, html, activeView, setActiveView }, forwardedRef) => { - const [showNav] = React.useState(false); + const [showNav, setShowNav] = React.useState(false); return (
setShowNav(false)} + className={classNames('w-screen max-w-full lg:max-w-[275px]', { 'translate-x-[-100%] lg:translate-x-0 absolute lg:relative': !showNav, 'translate-x-0': showNav })} @@ -36,14 +37,13 @@ export const Shell = React.forwardRef>( 'w-screen lg:w-[calc(100%_-_275px)]': !showNav })} > - {title && ( -