Skip to content

Commit e3a4a9a

Browse files
authored
Merge pull request #6 from scituinsk/slicing-design-app
refactor: enhance Button and Card components, update Dashboard layout…
2 parents 8b74e9f + 477beaf commit e3a4a9a

File tree

9 files changed

+45
-53
lines changed

9 files changed

+45
-53
lines changed

src/components/ui/button.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef } from "react";
1+
import { forwardRef, cloneElement, isValidElement } from "react";
22
import { cva } from "class-variance-authority";
33
import { Button as AriaButton } from "react-aria-components";
44

@@ -50,11 +50,22 @@ const buttonVariants = cva(
5050
}
5151
);
5252

53-
const Button = forwardRef(({ className, variant, size, rounded, children, ...props }, ref) => {
53+
const Button = forwardRef(({ className, variant, size, rounded, asChild = false, children, ...props }, ref) => {
54+
const buttonClasses = cn(buttonVariants({ variant, size, rounded, className }));
55+
56+
if (asChild && isValidElement(children)) {
57+
return cloneElement(children, {
58+
ref,
59+
className: cn(buttonClasses, children.props.className),
60+
...props,
61+
...children.props,
62+
});
63+
}
64+
5465
return (
5566
<AriaButton
5667
ref={ref}
57-
className={cn(buttonVariants({ variant, size, rounded, className }))}
68+
className={buttonClasses}
5869
{...props}
5970
>
6071
{children}

src/components/ui/card.jsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import React from "react";
22
import { cn } from "../../utils/cn";
33

4-
// Card: Container utama
54
const Card = React.forwardRef(({ className, ...props }, ref) => (
65
<div
76
ref={ref}
8-
className={cn(
9-
"rounded-lg border border-zinc-200 bg-white text-zinc-950 shadow-sm dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-50",
10-
className
11-
)}
7+
className={cn("rounded-lg border border-zinc-200 bg-white text-zinc-950 shadow-sm", className)}
128
{...props}
139
/>
1410
));
1511
Card.displayName = "Card";
1612

17-
// CardHeader: Wrapper untuk bagian atas card
1813
const CardHeader = React.forwardRef(({ className, ...props }, ref) => (
1914
<div
2015
ref={ref}
@@ -24,7 +19,6 @@ const CardHeader = React.forwardRef(({ className, ...props }, ref) => (
2419
));
2520
CardHeader.displayName = "CardHeader";
2621

27-
// CardTitle: Judul di dalam CardHeader (pakai <h3>)
2822
const CardTitle = React.forwardRef(({ className, ...props }, ref) => (
2923
<h3
3024
ref={ref}
@@ -34,7 +28,6 @@ const CardTitle = React.forwardRef(({ className, ...props }, ref) => (
3428
));
3529
CardTitle.displayName = "CardTitle";
3630

37-
// CardDescription: Teks deskripsi di dalam CardHeader (pakai <p>)
3831
const CardDescription = React.forwardRef(({ className, ...props }, ref) => (
3932
<p
4033
ref={ref}
@@ -44,7 +37,6 @@ const CardDescription = React.forwardRef(({ className, ...props }, ref) => (
4437
));
4538
CardDescription.displayName = "CardDescription";
4639

47-
// CardContent: Area konten utama
4840
const CardContent = React.forwardRef(({ className, ...props }, ref) => (
4941
<div
5042
ref={ref}
@@ -54,7 +46,6 @@ const CardContent = React.forwardRef(({ className, ...props }, ref) => (
5446
));
5547
CardContent.displayName = "CardContent";
5648

57-
// CardFooter: Wrapper untuk bagian bawah card
5849
const CardFooter = React.forwardRef(({ className, ...props }, ref) => (
5950
<div
6051
ref={ref}

src/components/ui/input.jsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from "react";
22
import { TextField as AriaTextField, Label as AriaLabel, Input as AriaInput, Text as AriaText } from "react-aria-components";
3-
import { cn } from "../../utils/cn"; // Sesuaikan path
43

5-
// --- 1. Container Utama (Otak dari Field) ---
4+
import { cn } from "../../utils/cn";
5+
66
const TextField = React.forwardRef(({ className, ...props }, ref) => (
77
<AriaTextField
88
ref={ref}
@@ -12,7 +12,6 @@ const TextField = React.forwardRef(({ className, ...props }, ref) => (
1212
));
1313
TextField.displayName = "TextField";
1414

15-
// --- 2. Label ---
1615
const Label = React.forwardRef(({ className, ...props }, ref) => (
1716
<AriaLabel
1817
ref={ref}
@@ -22,26 +21,22 @@ const Label = React.forwardRef(({ className, ...props }, ref) => (
2221
));
2322
Label.displayName = "Label";
2423

25-
// --- 3. Input ---
2624
const Input = React.forwardRef(({ className, ...props }, ref) => (
2725
<AriaInput
2826
ref={ref}
2927
className={cn(
3028
"flex h-10 w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm",
3129
"ring-offset-white placeholder:text-zinc-500",
32-
// Warna focus ring sudah disesuaikan dengan hex #326765
3330
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#326765] focus-visible:ring-offset-2",
3431
"disabled:cursor-not-allowed disabled:opacity-50",
35-
"dark:border-zinc-800 dark:bg-zinc-950 dark:ring-offset-zinc-950 dark:placeholder:text-zinc-400 dark:focus-visible:ring-[#326765]",
36-
"data-[invalid]:border-red-500 dark:data-[invalid]:border-red-700",
32+
"data-[invalid]:border-red-500 ",
3733
className
3834
)}
3935
{...props}
4036
/>
4137
));
4238
Input.displayName = "Input";
4339

44-
// --- 4. Teks Bantuan & Error Message ---
4540
const Text = React.forwardRef(({ className, ...props }, ref) => (
4641
<AriaText
4742
ref={ref}

src/constants/core-app-config.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ export const CORE_APP_NAV_ITEMS = [
33
label: "Dashboard",
44
href: "/app/dashboard",
55
},
6-
{
7-
label: "Schedule",
8-
href: "/app/schedule",
9-
},
106
{
117
label: "History",
128
href: "/app/history",

src/features/core-app/components/dashboard/sensor-card-footer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const SensorCardFooter = ({ icon, label, value, status }) => {
99

1010
{/* Value atau status */}
1111
{status ? (
12-
<span className="mt-1 px-3 py-1 rounded-full bg-green-400 text-black text-sm font-medium">{status}</span>
12+
<p className=" inline-block mt-1 px-3 py-1 rounded-full bg-green-400 text-black text-sm font-medium">{status}</p>
1313
) : (
1414
<p className="mt-1 text-base">{value}</p>
1515
)}

src/pages/core-app/dashboard-page.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { FaPlus } from "react-icons/fa6";
2+
import { FaSearch } from "react-icons/fa";
3+
24
import { Button } from "../../components/ui/button";
3-
import { Card, CardContent, CardHeader } from "../../components/ui/card";
45
import { TextField, Input } from "../../components/ui/input";
6+
import { Card, CardContent, CardHeader } from "../../components/ui/card";
57

68
import { SensorCardFooter } from "../../features/core-app/components/dashboard/sensor-card-footer";
7-
import { FaSearch } from "react-icons/fa";
89

910
export const DashboardPage = () => {
1011
return (
@@ -72,7 +73,7 @@ export const DashboardPage = () => {
7273

7374
<div className="grid grid-cols-12 gap-4 md:gap-2">
7475
{/* Input Pencarian */}
75-
<div className="col-span-12 md:col-span-9 h-[54px]">
76+
<div className="col-span-12 lg:col-span-9 h-[54px]">
7677
<div className="relative h-full w-full">
7778
<FaSearch
7879
aria-hidden="true"
@@ -93,15 +94,14 @@ export const DashboardPage = () => {
9394
</div>
9495

9596
{/* Tombol Filter */}
96-
<div className="col-span-3 md:col-span-1 bg-white size-[54px] aspect-square rounded-full mx-auto flex items-center justify-center">
97+
<div className="col-span-3 lg:col-span-1 bg-white size-[54px] aspect-square rounded-full mx-auto flex items-center justify-center">
9798
<svg
9899
width={19}
99100
height={19}
100101
viewBox="0 0 19 19"
101102
fill="none"
102103
xmlns="http://www.w3.org/2000/svg"
103104
>
104-
{/* ... (SVG path tidak berubah) ... */}
105105
<path
106106
d="M7.0875 1.18164C6.35435 1.18126 5.63914 1.40827 5.04042 1.83139C4.44169 2.25452 3.98894 2.85293 3.74456 3.54414H0V5.90664H3.74456C3.98861 6.5983 4.44119 7.19724 5.03992 7.62088C5.63865 8.04453 6.35405 8.27204 7.0875 8.27204C7.82095 8.27204 8.53635 8.04453 9.13508 7.62088C9.73381 7.19724 10.1864 6.5983 10.4304 5.90664H18.9V3.54414H10.4304C10.1861 2.85293 9.73331 2.25452 9.13458 1.83139C8.53586 1.40827 7.82064 1.18126 7.0875 1.18164ZM5.90625 4.72539C5.90625 4.4121 6.0307 4.11165 6.25223 3.89012C6.47376 3.66859 6.77421 3.54414 7.0875 3.54414C7.40079 3.54414 7.70124 3.66859 7.92277 3.89012C8.1443 4.11165 8.26875 4.4121 8.26875 4.72539C8.26875 5.03868 8.1443 5.33913 7.92277 5.56066C7.70124 5.78219 7.40079 5.90664 7.0875 5.90664C6.77421 5.90664 6.47376 5.78219 6.25223 5.56066C6.0307 5.33913 5.90625 5.03868 5.90625 4.72539ZM11.8125 10.6316C11.0794 10.6313 10.3641 10.8583 9.76542 11.2814C9.16669 11.7045 8.71394 12.3029 8.46956 12.9941H0V15.3566H8.46956C8.71361 16.0483 9.16619 16.6472 9.76492 17.0709C10.3636 17.4945 11.079 17.722 11.8125 17.722C12.546 17.722 13.2613 17.4945 13.8601 17.0709C14.4588 16.6472 14.9114 16.0483 15.1554 15.3566H18.9V12.9941H15.1554C14.9111 12.3029 14.4583 11.7045 13.8596 11.2814C13.2609 10.8583 12.5456 10.6313 11.8125 10.6316ZM10.6312 14.1754C10.6312 13.8621 10.7557 13.5616 10.9772 13.3401C11.1988 13.1186 11.4992 12.9941 11.8125 12.9941C12.1258 12.9941 12.4262 13.1186 12.6478 13.3401C12.8693 13.5616 12.9937 13.8621 12.9937 14.1754C12.9937 14.4887 12.8693 14.7891 12.6478 15.0107C12.4262 15.2322 12.1258 15.3566 11.8125 15.3566C11.4992 15.3566 11.1988 15.2322 10.9772 15.0107C10.7557 14.7891 10.6312 14.4887 10.6312 14.1754Z"
107107
fill="#326765"
@@ -110,7 +110,7 @@ export const DashboardPage = () => {
110110
</div>
111111

112112
{/* Tombol Tambah Module */}
113-
<div className="col-span-9 md:col-span-2">
113+
<div className="col-span-9 lg:col-span-2">
114114
<Button
115115
className="h-[54px] w-full inline-flex text-base"
116116
variant="outline"
@@ -123,8 +123,8 @@ export const DashboardPage = () => {
123123
{/* Ringkasan Module */}
124124
<div className="w-full">
125125
<h2 className="font-semibold text-lg lg:text-[20px] tracking-wider my-5">Ringkasan Modul</h2>
126-
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4 ">
127-
{Array.from({ length: 3 }).map((_, i) => (
126+
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4 ">
127+
{Array.from({ length: 6 }).map((_, i) => (
128128
<Card
129129
className="overflow-hidden"
130130
key={i}
@@ -171,7 +171,7 @@ export const DashboardPage = () => {
171171
</div>
172172
</CardHeader>
173173
<CardContent className="p-4 bg-[#326765] text-white">
174-
<div className="grid grid-cols-4 justify-center gap-8">
174+
<div className="flex justify-between items-center gap-4">
175175
<SensorCardFooter
176176
icon={
177177
<svg

src/pages/core-app/schedule-page.jsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/pages/landing-page/home-page.jsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ export const HomePage = () => {
1818
>
1919
<div className="container mx-auto px-6 lg:px-[89px] pt-0 lg:pt-32">
2020
<div className="max-w-full lg:max-w-[665px] text-center lg:text-left">
21-
<h1 className="text-4xl md:text-5xl lg:text-[64px] font-semibold text-white">Selamat Datang di Pak Tani!</h1>
22-
<p className="text-lg md:text-xl lg:text-[24px] text-white mt-2">
21+
{/* Penyesuaian font H1 */}
22+
<h1 className="text-4xl md:text-5xl lg:text-6xl font-semibold text-white">Selamat Datang di Pak Tani!</h1>
23+
{/* Penyesuaian font Paragraf */}
24+
<p className="text-base md:text-lg lg:text-xl text-white mt-2">
2325
Kelola dan pantau sistem irigasi pertanian Anda dengan mudah, langsung dari genggaman Anda.
2426
</p>
2527

2628
<div className="mt-8 lg:mt-[46px]">
2729
<Button
2830
variant="outline"
2931
size="lg"
30-
className="h-auto py-3 lg:h-[62px] px-8 lg:px-12 text-lg lg:text-[24px] text-[#326765] bg-white rounded-[15px]"
32+
asChild
33+
className="h-auto py-3 lg:h-[62px] px-8 lg:px-12 text-md md:text-lg lg:text-xl text-[#326765] bg-white rounded-[15px]"
3134
>
3235
<Link to="/app/dashboard">Mulai Sekarang</Link>
3336
</Button>
@@ -40,8 +43,12 @@ export const HomePage = () => {
4043
<div className="py-16 lg:mt-[87px] lg:py-0">
4144
<div className="container mx-auto px-6 lg:px-[89px] flex flex-col">
4245
<div className="mx-auto w-full lg:w-[505px] text-center">
43-
<h2 className="text-3xl lg:text-[36px] font-semibold">Fitur - fitur</h2>
44-
<p className="text-base lg:text-[20px] text-[#7d7d7d] mt-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod </p>
46+
{/* Penyesuaian font H2 */}
47+
<h2 className="text-2xl md:text-3xl lg:text-4xl font-semibold">Fitur - fitur</h2>
48+
{/* Penyesuaian font Paragraf */}
49+
<p className="text-sm md:text-base lg:text-lg text-[#7d7d7d] mt-2">
50+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod{" "}
51+
</p>
4552
</div>
4653
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 mt-12 lg:mt-[61px] gap-8 lg:gap-[58px]">
4754
{FEATURES.map((feature, i) => (
@@ -51,8 +58,10 @@ export const HomePage = () => {
5158
>
5259
<div className="flex flex-col items-center gap-4 text-center">
5360
{feature.icon}
54-
<h3 className="font-semibold text-xl lg:text-[24px] text-[#326765] mt-2">{feature.title}</h3>
55-
<p className="text-base lg:text-[18px] leading-relaxed lg:leading-[24px] text-center text-[#7d7d7d]">{feature.description}</p>
61+
{/* Penyesuaian font H3 di dalam kartu */}
62+
<h3 className="font-semibold text-xl lg:text-2xl text-[#326765] mt-2">{feature.title}</h3>
63+
{/* Penyesuaian font Paragraf di dalam kartu */}
64+
<p className="text-base leading-relaxed lg:leading-[24px] text-center text-[#7d7d7d]">{feature.description}</p>
5665
</div>
5766
</div>
5867
))}

src/router.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { HomePage } from "./pages/landing-page/home-page";
99
import { NotFoundPage } from "./pages/common/not-found";
1010
import { InternalServerError } from "./pages/common/internal-server-error";
1111
import { DashboardPage } from "./pages/core-app/dashboard-page";
12-
import { SchedulePage } from "./pages/core-app/schedule-page";
1312
import { HistoryPage } from "./pages/core-app/history-page";
1413

1514
//======================================================================
@@ -21,7 +20,6 @@ const router = createBrowserRouter([
2120
errorElement: <InternalServerError />,
2221
element: <GlobalLayout />,
2322
children: [
24-
// Public routes with LandingPageLayout
2523
{
2624
path: "/",
2725
element: <LandingPageLayout />,
@@ -40,10 +38,9 @@ const router = createBrowserRouter([
4038
},
4139
],
4240
},
43-
// Protected routes (bisa ditambahkan layout khusus)
4441
{
4542
path: "profile",
46-
element: <div>Profile Page</div>, // TODO: Tambahkan layout untuk protected routes
43+
element: <div>Profile Page</div>,
4744
},
4845
// Auth routes with AuthLayout
4946
{
@@ -68,10 +65,6 @@ const router = createBrowserRouter([
6865
path: "dashboard",
6966
element: <DashboardPage />,
7067
},
71-
{
72-
path: "schedule",
73-
element: <SchedulePage />,
74-
},
7568
{
7669
path: "history",
7770
element: <HistoryPage />,

0 commit comments

Comments
 (0)