Skip to content

Commit

Permalink
Merge pull request #149 from midday-ai/feature/responsive-dashboard-v1
Browse files Browse the repository at this point in the history
Responsive
  • Loading branch information
pontusab committed Jun 13, 2024
2 parents a8aca2b + 74fec59 commit f65d3cb
Show file tree
Hide file tree
Showing 63 changed files with 157 additions and 234 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@upstash/ratelimit": "^1.2.0",
"@vercel/speed-insights": "^1.0.12",
"@zip.js/zip.js": "2.7.45",
"ai": "^3.1.32",
"ai": "^3.1.33",
"change-case": "^5.4.4",
"dub": "^0.29.17",
"framer-motion": "^11.2.10",
Expand Down
Binary file removed apps/dashboard/public/assets/mobile.png
Binary file not shown.
16 changes: 0 additions & 16 deletions apps/dashboard/src/actions/close-mobile-overlay-action.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions apps/dashboard/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export const changeSpendingPeriodSchema = z.object({
to: z.string().datetime(),
});

export const closeMobileOverlaySchema = z.object({
value: z.boolean(),
});

export const changeChartCurrencySchema = z.string();
export const changeChartTypeSchema = z.enum(["profit", "revenue", "burn_rate"]);
export const changeChartPeriodSchema = z.object({
Expand Down
12 changes: 1 addition & 11 deletions apps/dashboard/src/app/[locale]/(app)/(sidebar)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import dynamic from "next/dynamic";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";

const MobileOverview = dynamic(
() => import("@/components/mobile-overlay").then((mod) => mod.MobileOverview),
{
ssr: false,
}
);

const AssistantModal = dynamic(
() =>
import("@/components/assistant/assistant-modal").then(
Expand Down Expand Up @@ -98,7 +91,6 @@ export default async function Layout({
: getCountryCode();

const isEU = isEUCountry(countryCode);
const mobileOverlay = cookies().has(Cookies.MobileOverlay);

if (!user?.data?.team) {
redirect("/teams");
Expand All @@ -111,11 +103,9 @@ export default async function Layout({
return (
<div className="relative">
<AI initialAIState={{ user: user.data, messages: [], chatId: nanoid() }}>
{!mobileOverlay && <MobileOverview />}

<Sidebar />

<div className="ml-[95px] mr-10 pb-8">
<div className="mx-4 md:ml-[95px] md:mr-10 pb-8">
<Header />
{children}
</div>
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const metadata: Metadata = {
};

export const viewport = {
width: "device-width",
initialScale: 1,
maximumScale: 1,
userScalable: false,
themeColor: [
{ media: "(prefers-color-scheme: light)" },
{ media: "(prefers-color-scheme: dark)" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function AssistantModal() {
return (
<Dialog open={isOpen} onOpenChange={setOpen}>
<DialogContent
className="overflow-hidden p-0 max-w-[740px] h-[480px] rounded-lg"
className="overflow-hidden p-0 max-w-full w-full h-full md:max-w-[740px] md:h-[480px] md:rounded-lg m-0"
hideClose
>
<Assistant />
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/assistant/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export function AssistantButton() {
return (
<Button
variant="outline"
className="relative w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 lg:w-64 border-0 p-0 hover:bg-transparent font-normal todesktop:hidden"
className="relative w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 lg:w-64 border-0 p-0 hover:bg-transparent font-normal no-drag"
onClick={() => setOpen()}
>
<span className="hidden lg:inline-flex">Ask Midday a question...</span>
<span className="ml-4 md:ml-0">Ask Midday a question...</span>
<kbd className="pointer-events-none absolute right-1.5 top-1.5 hidden h-5 select-none items-center gap-1 rounded border bg-accent px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">
<span className="text-xs"></span>K
</kbd>
Expand Down
14 changes: 13 additions & 1 deletion apps/dashboard/src/components/assistant/header.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useAssistantStore } from "@/store/assistant";
import { Button } from "@midday/ui/button";
import { Icons } from "@midday/ui/icons";
import { Experimental } from "../experimental";
Expand All @@ -8,6 +9,8 @@ type Props = {
};

export function Header({ toggleSidebar, isExpanded }: Props) {
const { setOpen } = useAssistantStore();

return (
<div className="px-4 py-3 flex justify-between items-center border-border border-b-[1px]">
<div className="flex items-center space-x-3">
Expand All @@ -27,7 +30,16 @@ export function Header({ toggleSidebar, isExpanded }: Props) {
<h2>Assistant</h2>
</div>

<div className="flex space-x-2 items-center">
<Button
className="flex md:hidden todesktop:hidden"
size="icon"
variant="ghost"
onClick={() => setOpen()}
>
<Icons.Close />
</Button>

<div className="space-x-2 items-center hidden md:flex todesktop:flex">
<Experimental className="border-border text-[#878787]" />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/assistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function Assistant() {
}, [chatId]);

return (
<div className="overflow-hidden p-0 max-w-[760px] h-[480px]">
<div className="overflow-hidden p-0 h-full w-full todesktop:max-w-[760px] md:max-w-[760px] md:h-[480px] todesktop:h-[480px]">
{showFeedback && (
<AssistantFeedback onClose={() => setShowFeedback(false)} />
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/assistant/sidebar-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function SidebarItems({ onSelect, chatId }: SidebarItemsProps) {
}, [aiState]);

return (
<div className="overflow-auto relative h-[410px] mt-16 scrollbar-hide p-4 pt-0 pb-[50px] flex flex-col space-y-6">
<div className="overflow-auto relative h-screen md:h-[410px] mt-16 scrollbar-hide p-4 pt-0 pb-[50px] flex flex-col space-y-6">
{!Object.keys(items).length && (
<div className="flex flex-col justify-center items-center h-full">
<div className="flex flex-col items-center -mt-12 text-xs space-y-1">
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/assistant/sidebar-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function SidebarList({
<div
ref={ref}
className={cn(
"w-[220px] h-[477px] bg-background dark:bg-[#131313] absolute -left-[220px] top-0 bottom-[1px] duration-200 ease-out transition-all border-border border-r-[1px] z-20 invisible",
"w-[220px] h-screen md:h-[477px] bg-background dark:bg-[#131313] absolute -left-[220px] top-0 bottom-[1px] duration-200 ease-out transition-all border-border border-r-[1px] z-20 invisible",
isExpanded && "visible translate-x-full"
)}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function Attachments({ id, data }) {
/>
<div
className={cn(
"mt-4 w-full h-[120px] border-dotted border-2 border-border rounded-xl text-center flex flex-col justify-center space-y-1 transition-colors text-[#606060]",
"mt-4 w-full h-[120px] border-dotted border-2 border-border text-center flex flex-col justify-center space-y-1 transition-colors text-[#606060]",
isDragActive && "bg-secondary text-primary"
)}
{...getRootProps()}
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/charts/chart-period.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ export function ChartPeriod({ defaultValue, disabled }: Props) {
variant="outline"
className="justify-start text-left font-medium space-x-2"
>
<span>{placeholder}</span>
<span className="line-clamp-1 text-ellipsis">{placeholder}</span>
<Icons.ChevronDown />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[450px] mt-2 pt-1" align="end">
<PopoverContent className="w-screen md:w-[450px] mt-2 pt-1" align="end">
<MonthRangePicker setDate={handleChangePeriod} date={date} />
</PopoverContent>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/charts/chart-selectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function ChartSelectors({ defaultValue, currency }) {
const chartType = cookies().get(Cookies.ChartType)?.value ?? "profit";

return (
<div className="flex justify-between mt-6">
<div className="flex justify-between mt-6 space-x-2">
<div className="flex space-x-2">
<ChartType initialValue={chartType} />
<ChartCurrency defaultValue={currency} />
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/charts/spending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SpendingPeriod } from "./spending-period";
export async function Spending({ disabled, initialPeriod }) {
return (
<div className="border aspect-square relative overflow-hidden">
<div className="p-8 flex-col">
<div className="p-4 md:p-8 flex-col">
<SpendingPeriod initialPeriod={initialPeriod} />

<ErrorBoundary errorComponent={ErrorFallback}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function TransactionListItem({ transaction, disabled }: Props) {
<div className="w-[35%]">
<span
className={cn(
"text-sm",
"text-sm line-clamp-1",
disabled && "skeleton-box",
transaction?.category?.slug === "income" && "text-[#00C969]"
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/charts/transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function Transactions({ disabled }) {
const type = cookies().get("transactions-period")?.value ?? "all";

return (
<div className="border aspect-square overflow-hidden relative p-8">
<div className="border aspect-square overflow-hidden relative p-4 md:p-8">
<TransactionsPeriod type={type} disabled={disabled} />

<div className="mt-8">
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/chat/chat-empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {

export function ChatEmpty({ firstName }: Props) {
return (
<div className="w-full mt-24 flex flex-col items-center justify-center text-center">
<div className="w-full mt-[200px] todesktop:mt-24 md:mt-24 flex flex-col items-center justify-center text-center">
<Icons.LogoSmall />
<span className="font-medium text-xl mt-6">
Hi {firstName}, how can I help <br />
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/chat/chat-examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function ChatExamples({ onSubmit }) {

return (
<div
className="absolute z-10 bottom-[100px] left-0 right-0 overflow-scroll scrollbar-hide cursor-grabbing"
className="absolute z-10 bottom-[100px] left-0 right-0 overflow-scroll scrollbar-hide cursor-grabbing hidden md:block"
{...events}
ref={ref}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/chat/chat-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function ChatFooter({ onSubmit, showFeedback }: Props) {
};

return (
<div className="flex px-3 h-[40px] w-full border-t-[1px] items-center bg-background backdrop-filter dark:border-[#2C2C2C] backdrop-blur-lg dark:bg-[#151515]/[99]">
<div className="hidden todesktop:flex md:flex px-3 h-[40px] w-full border-t-[1px] items-center bg-background backdrop-filter dark:border-[#2C2C2C] backdrop-blur-lg dark:bg-[#151515]/[99]">
<Popover>
<PopoverTrigger>
<div className="scale-50 opacity-50 -ml-2">
Expand Down
12 changes: 6 additions & 6 deletions apps/dashboard/src/components/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useScrollAnchor } from "@/hooks/use-scroll-anchor";
import { useAssistantStore } from "@/store/assistant";
import { ScrollArea } from "@midday/ui/scroll-area";
import { Textarea } from "@midday/ui/textarea";
import { useMediaQuery } from "@uidotdev/usehooks";
import { useActions } from "ai/rsc";
import { nanoid } from "nanoid";
import { useEffect, useRef } from "react";
Expand Down Expand Up @@ -67,9 +68,9 @@ export function Chat({
}, []);

useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
requestAnimationFrame(() => {
inputRef?.current.focus();
});
}, [messages]);

const { messagesRef, scrollRef, visibilityRef, scrollToBottom } =
Expand All @@ -79,7 +80,7 @@ export function Chat({

return (
<div className="relative">
<ScrollArea className="h-[335px]" ref={scrollRef}>
<ScrollArea className="todesktop:h-[335px] md:h-[335px]" ref={scrollRef}>
<div ref={messagesRef}>
{messages.length ? (
<ChatList messages={messages} />
Expand All @@ -91,7 +92,7 @@ export function Chat({
</div>
</ScrollArea>

<div className="fixed bottom-[1px] left-[1px] right-[1px] h-[88px] bg-background border-border border-t-[1px]">
<div className="fixed bottom-[1px] left-[1px] right-[1px] todesktop:h-[88px] md:h-[88px] bg-background border-border border-t-[1px]">
{showExamples && <ChatExamples onSubmit={onSubmit} />}

<form
Expand All @@ -111,7 +112,6 @@ export function Chat({
value={input}
className="h-12 min-h-12 pt-3 resize-none border-none"
placeholder="Ask Midday a question..."
autoFocus
onKeyDown={onKeyDown}
onChange={(evt) => {
setInput(evt.target.value);
Expand Down
9 changes: 8 additions & 1 deletion apps/dashboard/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ import { Skeleton } from "@midday/ui/skeleton";
import { isDesktopApp } from "@todesktop/client-core/platform/todesktop";
import { Suspense } from "react";
import { DesktopTrafficLight } from "./desktop-traffic-light";
import { MobileMenu } from "./mobile-menu";

export function Header() {
return (
<header className="border-b-[1px] flex justify-between py-4 items-center todesktop:sticky todesktop:top-0 todesktop:bg-background todesktop:z-10 todesktop:border-none">
<header className="-ml-4 -mr-4 md:m-0 z-10 px-4 md:px-4 md:border-b-[1px] flex justify-between pt-4 pb-2 md:pb-4 items-center todesktop:sticky todesktop:top-0 todesktop:bg-background todesktop:border-none sticky md:static top-0 backdrop-filter backdrop-blur-xl md:backdrop-filter md:backdrop-blur-none dark:bg-[#121212] bg-[#fff] bg-opacity-70 ">
<MobileMenu />

{isDesktopApp() && <DesktopTrafficLight />}
{isDesktopApp() && <BrowserNavigation />}

<AssistantButton />

<div className="flex space-x-2 no-drag ml-auto">
{isDesktopApp() && <DesktopAssistantuButton />}

<TrackerControl />

<Suspense>
<ReconnectBank />
</Suspense>

<NotificationCenter />

<Suspense fallback={<Skeleton className="h-8 w-8 rounded-full" />}>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/inbox-details-skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Skeleton } from "@midday/ui/skeleton";

export function InboxDetailsSkeleton() {
return (
<div className="flex h-[calc(100vh-120px)] overflow-hidden flex-col border w-[1160px]">
<div className="h-[calc(100vh-120px)] overflow-hidden flex-col border w-[1160px] hidden md:flex">
<div className="flex items-center py-2 h-[52px]">
<div className="flex items-center gap-2" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/inbox-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export function InboxDetails({
};

if (isEmpty) {
return <div className="w-[1160px]" />;
return <div className="hidden md:block w-[1160px]" />;
}

return (
<div className="flex h-[calc(100vh-120px)] overflow-hidden flex-col border w-[1160px]">
<div className="h-[calc(100vh-120px)] overflow-hidden flex-col border w-[1160px] hidden md:flex">
<div className="flex items-center p-2">
<div className="flex items-center gap-2">
<Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/inbox-list-skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function InboxListSkeleton({
<div className={cn("flex flex-col gap-4", className)}>
{[...Array(numberOfItems)].map((_, index) => (
<div
className="flex flex-col items-start gap-2 rounded-xl border p-4 text-left text-sm transition-all h-[82px]"
className="flex flex-col items-start gap-2 border p-4 text-left text-sm transition-all h-[82px]"
key={index.toString()}
>
<div className="flex w-full flex-col gap-1">
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/inbox-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function InboxToolbar({ isFirst, isLast, onKeyPress, onAction }: Props) {
});

return (
<div className="left-0 right-0 absolute bottom-0 flex items-center justify-center">
<div className="left-0 right-0 absolute bottom-0 hidden md:flex items-center justify-center">
<div className="backdrop-filter backdrop-blur-lg dark:bg-[#1A1A1A]/80 bg-[#F6F6F3]/80 h-10 justify-between items-center flex px-2 rounded-lg space-x-4 text-[#878787]">
<button
type="button"
Expand Down

0 comments on commit f65d3cb

Please sign in to comment.