Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Engine pages to teams (chakra) #4456

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions apps/dashboard/src/@/components/ChakraProviderSetup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";

import { ChakraProvider, useColorMode } from "@chakra-ui/react";
import { useTheme } from "next-themes";
import { useEffect } from "react";
import chakraTheme from "../../theme";

export function ChakraProviderSetup(props: {
children: React.ReactNode;
}) {
return (
<ChakraProvider theme={chakraTheme}>
{props.children}
<SyncTheme />
</ChakraProvider>
);
}

function SyncTheme() {
const { theme, setTheme } = useTheme();
const { setColorMode } = useColorMode();

// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
setColorMode(theme === "light" ? "light" : "dark");
}, [setColorMode, theme]);

// handle dashboard with now old "system" set
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (theme === "system") {
setTheme("dark");
setColorMode("dark");
}
}, [theme, setTheme, setColorMode]);

return null;
}
5 changes: 4 additions & 1 deletion apps/dashboard/src/@/components/blocks/MobileSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { useState } from "react";
import { NavLink } from "../ui/NavLink";
import type { SidebarLink } from "./Sidebar";

export function MobileSidebar(props: {
links?: { href: string; label: React.ReactNode }[];
links?: SidebarLink[];
footer?: React.ReactNode;
trigger: React.ReactNode;
}) {
Expand All @@ -31,6 +32,8 @@ export function MobileSidebar(props: {
href={link.href}
className="!text-left justify-start flex gap-2 h-auto py-3"
activeClassName="bg-accent"
exactMatch={link.exactMatch}
tracking={link.tracking}
>
{link.label}
</NavLink>
Expand Down
13 changes: 12 additions & 1 deletion apps/dashboard/src/@/components/blocks/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ import type React from "react";
import { cn } from "../../lib/utils";
import { NavLink } from "../ui/NavLink";

export type SidebarLink = {
href: string;
label: React.ReactNode;
exactMatch?: boolean;
tracking?: {
category: string;
action: string;
label: string;
};
};

export type SidebarContentProps = {
header?: React.ReactNode;
links: { href: string; label: React.ReactNode; exactMatch?: boolean }[];
links: SidebarLink[];
className?: string;
};

Expand Down
17 changes: 17 additions & 0 deletions apps/dashboard/src/@/components/ui/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
import { cn } from "@/lib/utils";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useTrack } from "../../../hooks/analytics/useTrack";

export type NavButtonProps = {
className?: string;
activeClassName?: string;
href: string;
exactMatch?: boolean;
tracking?: {
category: string;
action: string;
label: string;
};
};

export function NavLink(props: React.PropsWithChildren<NavButtonProps>) {
const track = useTrack();
const pathname = usePathname();
const isActive = pathname
? props.exactMatch
Expand All @@ -23,6 +30,16 @@ export function NavLink(props: React.PropsWithChildren<NavButtonProps>) {
href={props.href}
className={cn(props.className, isActive && props.activeClassName)}
target={props.href.startsWith("http") ? "_blank" : undefined}
onClick={() => {
if (props.tracking) {
track({
category: props.tracking.category,
action: props.tracking.action,
label: props.tracking.label,
url: props.href,
});
}
}}
>
{props.children}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function TeamHeaderDesktopUI(props: TeamHeaderCompProps) {
className="font-normal text-sm flex flex-row gap-2 items-center"
>
{/* TODO - replace with team image */}
<div className="bg-muted border size-6 rounded-full" />
<div className="bg-muted border border-border size-6 rounded-full" />

<span> {currentTeam.name} </span>
<Badge
Expand Down Expand Up @@ -146,7 +146,7 @@ export function TeamHeaderMobileUI(props: TeamHeaderCompProps) {
)}
>
{/* TODO - replace with team image */}
<div className="bg-muted border size-7 rounded-full" />
<div className="bg-muted border border-border size-7 rounded-full" />

{!props.currentProject && (
<span className="font-semibold">{currentTeam.name}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function TeamOverviewPage(props: {

{/* Projects */}
{projectsToShow.length === 0 ? (
<div className="border rounded-lg h-[450px] flex items-center justify-center ">
<div className="border border-border rounded-lg h-[450px] flex items-center justify-center ">
No projects found
</div>
) : (
Expand Down Expand Up @@ -101,7 +101,7 @@ function ProjectCard(props: {
return (
<div
key={project.id}
className="border rounded-lg p-4 relative hover:bg-muted/70 flex items-center gap-4 bg-muted/50 transition-colors"
className="border border-border rounded-lg p-4 relative hover:bg-muted/70 flex items-center gap-4 bg-muted/50 transition-colors"
>
{/* TODO - replace with project image */}
<div className="size-10 rounded-full bg-border shrink-0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function RenderLinkGroup(props: {
<>
<div className="flex items-center gap-1.5 px-4">
{/* TODO - using placeholder for now */}
<div className="size-4 bg-muted rounded-full border" />
<div className="size-4 bg-muted rounded-full border border-border" />
<p className="text-muted-foreground text-xs">{props.title}</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function TeamSettingsMobileNav(props: {

if (!showFull) {
return (
<div className="py-4 px-4 border-b flex items-center gap-2 text-muted-foreground">
<div className="py-4 px-4 border-b border-border flex items-center gap-2 text-muted-foreground">
<Link
href={teamLinks[0].href}
className="inline-flex items-center gap-1"
Expand Down Expand Up @@ -43,7 +43,7 @@ export function TeamSettingsMobileNav(props: {
<li key={link.href}>
<Link
href={link.href}
className="p-4 border-b flex"
className="p-4 border-b flex border-border"
onClick={() => {
if (link === teamLinks[0]) {
setShowFull(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Story() {

function ComponentVariantions() {
return (
<div className="pt-20 border-t p-6">
<div className="pt-20 border-t p-6 border-border">
<div className="max-w-[1100px] mx-auto">
<h2 className="mb-5 text-3xl"> Component variations </h2>
<div className="flex flex-col gap-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ function TeamSlugFormControl(props: {
}}
noPermissionText={undefined} // TODO
>
<div className="relative border rounded-lg flex md:w-[450px]">
<div className="bg-muted/50 text-muted-foreground/80 self-stretch flex items-center px-3 text-sm border-r rounded-l-lg font-mono">
<div className="relative border border-border rounded-lg flex md:w-[450px]">
<div className="bg-muted/50 text-muted-foreground/80 self-stretch flex items-center px-3 text-sm border-r border-border rounded-l-lg font-mono">
thirdweb.com/team/
</div>
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function SettingsCard(props: {
<div className="border rounded-lg bg-muted/50 relative">
<div
className={cn(
"border-b px-4 lg:px-6 py-6 relative",
"border-b border-border px-4 lg:px-6 py-6 relative",
props.noPermissionText && "cursor-not-allowed",
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Layout(props: {
return (
<div>
{/* Huge page title */}
<div className="py-10 border-b">
<div className="py-10 border-b border-border">
<div className="container max-w-[1200px]">
<h1 className="text-3xl tracking-tight font-semibold">
Team Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function InviteSection(props: {

if (teamPlan !== "pro") {
bottomSection = (
<div className="px-4 lg:px6 py-4 flex items-center justify-between border-t gap-4">
<div className="px-4 lg:px6 py-4 flex items-center justify-between border-t border-border gap-4">
<p className="text-muted-foreground text-sm">
This feature is only available on the{" "}
<Link
Expand All @@ -49,15 +49,15 @@ export function InviteSection(props: {
);
} else if (!props.userHasEditPermission) {
bottomSection = (
<div className="px-4 lg:px-6 py-4 flex items-center justify-between border-t min-h-[60px]">
<div className="px-4 lg:px-6 py-4 flex items-center justify-between border-t border-border min-h-[60px]">
<p className="text-muted-foreground text-sm">
You don't have permission to invite members
</p>
</div>
);
} else {
bottomSection = (
<div className="py-4 px-4 lg:px-6 flex items-center lg:justify-end border-t ">
<div className="py-4 px-4 lg:px-6 flex items-center lg:justify-end border-t border-border">
<Button variant="outline" size="sm" className="gap-2 max-sm:w-full">
<UserPlus className="size-3" />
Invite
Expand All @@ -71,7 +71,7 @@ export function InviteSection(props: {
<h2 className="text-2xl font-semibold tracking-tight mb-3">Invite</h2>

{/* Card */}
<div className="border rounded-lg bg-muted/50">
<div className="border border-border rounded-lg bg-muted/50">
{/* Invite via Link */}
<div
className={cn(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"use client";

import type { Team } from "@/api/team";
import { Input } from "@/components/ui/input";
import { EllipsisIcon, SearchIcon } from "lucide-react";

import type { TeamAccountRole, TeamMember } from "@/api/team-members";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { EllipsisIcon, SearchIcon } from "lucide-react";
import { useState } from "react";
import { Button } from "../../../../../../../@/components/ui/button";
import { Checkbox } from "../../../../../../../@/components/ui/checkbox";
import { Label } from "../../../../../../../@/components/ui/label";

export function ManageMembersSection(props: {
team: Team;
Expand All @@ -26,15 +25,15 @@ export function ManageMembersSection(props: {

if (!props.userHasEditPermission) {
topSection = (
<div className="border-b p-4">
<div className="border-b border-border p-4">
<p className="text-muted-foreground text-sm">
You don't have permission to manage members
</p>
</div>
);
} else {
topSection = (
<div className="border-b p-4 flex items-center justify-between">
<div className="border-b border-border p-4 flex items-center justify-between">
<div className="flex items-center gap-3 lg:gap-4">
<Checkbox
id="select-all"
Expand Down Expand Up @@ -74,7 +73,7 @@ export function ManageMembersSection(props: {
<div className="h-4" />

{/* Card */}
<div className="border rounded-lg bg-muted/50">
<div className="border border-border rounded-lg bg-muted/50">
{/* Top section */}
{topSection}

Expand Down Expand Up @@ -109,7 +108,7 @@ function MemberRow(props: {
userHasEditPermission: boolean;
}) {
return (
<div className="flex items-center justify-between py-4 px-4 border-b">
<div className="flex items-center justify-between py-4 px-4 border-b border-border">
<div className="flex items-center gap-3 lg:gap-4">
{/* Checkbox */}
<Checkbox
Expand All @@ -119,7 +118,7 @@ function MemberRow(props: {
/>

{/* PFP */}
<div className="size-8 lg:size-9 bg-muted border rounded-full" />
<div className="size-8 lg:size-9 bg-muted border border-border rounded-full" />

<div>
<p className="text-sm font-semibold mb-0.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function Story() {

function CompVariants() {
return (
<div className="py-10 border-t">
<div className="py-10 border-t border-border">
<div className="max-w-[1000px] mx-auto px-4">
<h2 className="text-3xl font-semibold py-4"> Invite Variants </h2>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CreateEnginePage } from "components/engine/create/CreateEnginePage";

export default function Page() {
return <CreateEnginePage />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { SidebarLink } from "@/components/blocks/Sidebar";

export function getEngineGeneralSidebarLinks(
linkPrefix: string,
): SidebarLink[] {
return [
{
label: "Overview",
href: `${linkPrefix}`,
exactMatch: true,
},
{
label: "Create",
href: `${linkPrefix}/create`,
},
{
label: "Import",
href: `${linkPrefix}/import`,
},
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { EngineImportPage } from "components/engine/import/EngineImportPage";

export default function Page() {
return <EngineImportPage />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Sidebar } from "@/components/blocks/Sidebar";
import { getEngineGeneralSidebarLinks } from "./getEngineGeneralSidebarLinks";
import { EngineGeneralPageMobileSidebar } from "./sidebars";

export default function Layout(props: {
params: {
team_slug: string;
project_slug: string;
engineId: string;
};
children: React.ReactNode;
}) {
const linkPrefix = `/team/${props.params.team_slug}/${props.params.project_slug}/engine`;
const sidebarLinks = getEngineGeneralSidebarLinks(linkPrefix);

return (
<div className="container flex gap-6">
<Sidebar links={sidebarLinks} />
<div className="pt-6 grow max-sm:w-full">
<EngineGeneralPageMobileSidebar links={sidebarLinks} />
{props.children}
</div>
</div>
);
}
Loading
Loading