Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Jan 20, 2025
1 parent 872394b commit 661d266
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 75 deletions.
100 changes: 26 additions & 74 deletions apps/builder/app/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
forwardRef,
useEffect,
useState,
type ComponentProps,
type ReactNode,
} from "react";
import { useEffect, useState, type ReactNode } from "react";
import {
Flex,
List,
Expand Down Expand Up @@ -45,34 +39,6 @@ const globalStyles = globalCss({
},
});

const Main = (props: ComponentProps<typeof Flex>) => {
return <Flex {...props} as="main" direction="column" gap="5" grow />;
};

const Section = (props: ComponentProps<typeof Flex>) => {
return (
<Flex
{...props}
justify="center"
as="section"
css={{ minWidth: theme.spacing[33] }}
/>
);
};

export type DashboardProps = {
user: User;
projects?: Array<DashboardProject>;
templates?: Array<DashboardProject>;
userPlanFeatures: UserPlanFeatures;
publisherHost: string;
projectToClone?: {
authToken: string;
id: string;
title: string;
};
};

const CloneProject = ({
projectToClone,
}: {
Expand Down Expand Up @@ -128,31 +94,6 @@ const sidebarLinkStyle = css({
},
});

const SidebarLink = forwardRef<
HTMLAnchorElement,
{
prefix: ReactNode;
children: string;
to: string;
target?: string;
}
>(({ to, prefix, children, target }, forwardedRef) => {
return (
<NavLink
to={to}
end
target={target}
className={sidebarLinkStyle()}
ref={forwardedRef}
>
{prefix}
<Text variant="labelsSentenceCase" color="main">
{children}
</Text>
</NavLink>
);
});

const NavigationItems = ({
items,
}: {
Expand Down Expand Up @@ -186,6 +127,19 @@ const NavigationItems = ({
);
};

type DashboardProps = {
user: User;
projects?: Array<DashboardProject>;
templates?: Array<DashboardProject>;
userPlanFeatures: UserPlanFeatures;
publisherHost: string;
projectToClone?: {
authToken: string;
id: string;
title: string;
};
};

export const Dashboard = ({
user,
projects,
Expand Down Expand Up @@ -260,20 +214,18 @@ export const Dashboard = ({
</CollapsibleSection>
</nav>
</Flex>
<Main>
<Section>
{projects && (
<Projects
projects={projects}
hasProPlan={userPlanFeatures.hasProPlan}
publisherHost={publisherHost}
/>
)}
{templates && (
<Templates templates={templates} publisherHost={publisherHost} />
)}
</Section>
</Main>
<Flex as="main" direction="column" gap="5" grow>
{projects && (
<Projects
projects={projects}
hasProPlan={userPlanFeatures.hasProPlan}
publisherHost={publisherHost}
/>
)}
{templates && (
<Templates templates={templates} publisherHost={publisherHost} />
)}
</Flex>
</Flex>
<CloneProject projectToClone={projectToClone} />
<Toaster />
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/app/dashboard/projects/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Projects = ({
<Flex
direction="column"
gap="3"
css={{ paddingInline: theme.spacing[13] }}
css={{ paddingInline: theme.spacing[13], paddingTop: "20vh" }}
>
{projects.length === 0 && <EmptyState />}
<Grid
Expand Down

0 comments on commit 661d266

Please sign in to comment.