Skip to content

Commit 403904a

Browse files
authored
Merge pull request #106 from refactor-group/create_shared_page_container
2 parents a536f36 + 6d13411 commit 403904a

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

src/app/dashboard/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import type { Metadata } from "next";
22
import { DashboardContainer } from "../../components/ui/dashboard/dashboard-container";
3+
import { PageContainer } from "@/components/ui/page-container";
34

45
export const metadata: Metadata = {
56
title: "Dashboard",
67
description: "Coaching dashboard",
78
};
89

910
export default function DashboardPage() {
10-
return <DashboardContainer />;
11+
return (
12+
<PageContainer>
13+
<DashboardContainer />
14+
</PageContainer>
15+
);
1116
}

src/app/organizations/[id]/members/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useUserList } from "@/lib/api/organizations/users";
99
import { useOrganizationStateStore } from "@/lib/providers/organization-state-store-provider";
1010
import { Id } from "@/types/general";
1111
import { MemberContainer } from "@/components/ui/members/member-container";
12+
import { PageContainer } from "@/components/ui/page-container";
1213

1314
export default function MembersPage({
1415
params,
@@ -65,7 +66,7 @@ export default function MembersPage({
6566
}
6667

6768
return (
68-
<div className="container mx-auto p-6 space-y-8">
69+
<PageContainer>
6970
<MemberContainer
7071
users={users}
7172
relationships={relationships}
@@ -74,6 +75,6 @@ export default function MembersPage({
7475
isLoading={isRelationshipsLoading || isUsersLoading}
7576
openAddMemberDialog={openAddMemberDialog}
7677
/>
77-
</div>
78+
</PageContainer>
7879
);
7980
}

src/components/ui/dashboard/dashboard-container.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { useState } from "react";
44
import type * as React from "react";
5-
import { cn } from "@/components/lib/utils";
65
import CoachingSessionList from "@/components/ui/dashboard/coaching-session-list";
76
import AddEntities from "@/components/ui/dashboard/add-entities";
87
import { CoachingSessionDialog } from "@/components/ui/dashboard/coaching-session-dialog";
@@ -25,18 +24,7 @@ export function DashboardContainer() {
2524
};
2625

2726
return (
28-
<div
29-
className={cn(
30-
// Base styles
31-
"p-4",
32-
// Mobile: stack vertically
33-
"flex flex-col gap-6",
34-
// Never grow wider than the site-header
35-
"max-w-screen-2xl",
36-
// Ensure full width for children
37-
"[&>*]:w-full"
38-
)}
39-
>
27+
<>
4028
<AddEntities
4129
className="mb-8"
4230
onCreateSession={() => handleOpenDialog()}
@@ -47,6 +35,6 @@ export function DashboardContainer() {
4735
onOpenChange={handleCloseDialog}
4836
coachingSessionToEdit={sessionToEdit}
4937
/>
50-
</div>
38+
</>
5139
);
5240
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { cn } from "@/components/lib/utils";
2+
3+
/// A reusable parent page container that contains and provides all children components
4+
/// the right style to adhere to the right max width and padding from the sidebar.
5+
export function PageContainer({
6+
children,
7+
}: Readonly<{
8+
children: React.ReactNode;
9+
}>) {
10+
return (
11+
<div
12+
className={cn(
13+
// Base styles
14+
"p-4",
15+
// Mobile: stack vertically
16+
"flex flex-col gap-6",
17+
// Never grow wider than the site-header
18+
"max-w-screen-2xl",
19+
// Ensure full width for children
20+
"[&>*]:w-full"
21+
)}
22+
>
23+
{children}
24+
</div>
25+
);
26+
}

0 commit comments

Comments
 (0)