Skip to content

Commit

Permalink
Merge pull request #3 from iqbalpa/feat/home
Browse files Browse the repository at this point in the history
Feat/home
  • Loading branch information
iqbalpa authored Jul 20, 2024
2 parents 3460596 + 33f6674 commit 3c32237
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
"format:fix": "prettier --write --list-different ."
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-scroll-area": "^1.1.0",
"axios": "^1.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"daisyui": "^4.12.10",
"hamburger-react": "^2.5.1",
"lint-staged": "^15.2.7",
"lucide-react": "^0.411.0",
"next": "14.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/backButton/backButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const BackButton: React.FC = () => {
return (
<button
onClick={handleBack}
className="absolute left-5 top-20 z-40 flex flex-row gap-2 rounded-full bg-slate-600 bg-opacity-80 px-5 py-3 text-white duration-100 hover:scale-105 hover:cursor-pointer hover:bg-slate-500 hover:bg-opacity-95"
className="absolute left-5 top-20 z-40 flex flex-row items-center gap-2 rounded-full bg-slate-600 bg-opacity-80 px-5 py-3 text-white duration-100 hover:scale-105 hover:cursor-pointer hover:bg-slate-500 hover:bg-opacity-95"
>
<CircleArrowLeft />
<p>Back</p>
Expand Down
59 changes: 58 additions & 1 deletion src/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,69 @@
'use client';

import Link from 'next/link';
import React from 'react';
import React, { useState } from 'react';
import Hamburger from 'hamburger-react';
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@/components/ui/sheet';

const Header: React.FC = () => {
const [fontSize, setFontSize] = useState<string>('medium');

const handleFontSizeChange = (size: string) => {
setFontSize(size);
document.documentElement.style.fontSize = size;
};
return (
<div className="fixed inset-x-0 z-10 flex flex-row items-center justify-between bg-gray-900 p-5">
<Link href="/" className="text-xl font-bold">
Al - Quran
</Link>
<Sheet>
<SheetTrigger>
<div className="-my-4">
<Hamburger toggled={false} />
</div>
</SheetTrigger>
<SheetContent className="bg-slate-900">
<SheetHeader>
<SheetTitle className="text-white">Ukuran Teks</SheetTitle>
<SheetDescription>
<div className="flex items-center justify-start space-x-2">
<button
onClick={() => handleFontSizeChange('small')}
className={`rounded px-3 py-1 text-sm ${
fontSize === 'small' ? 'bg-blue-500' : 'bg-gray-700'
} text-white`}
>
S
</button>
<button
onClick={() => handleFontSizeChange('medium')}
className={`rounded px-3 py-1 text-base ${
fontSize === 'medium' ? 'bg-blue-500' : 'bg-gray-700'
} text-white`}
>
M
</button>
<button
onClick={() => handleFontSizeChange('large')}
className={`rounded px-3 py-1 text-lg ${
fontSize === 'large' ? 'bg-blue-500' : 'bg-gray-700'
} text-white`}
>
L
</button>
</div>
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet>
</div>
);
};
Expand Down
140 changes: 140 additions & 0 deletions src/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
'use client';

import * as React from 'react';
import * as SheetPrimitive from '@radix-ui/react-dialog';
import { cva, type VariantProps } from 'class-variance-authority';
import { X } from 'lucide-react';

import { cn } from '@/lib/utils';

const Sheet = SheetPrimitive.Root;

const SheetTrigger = SheetPrimitive.Trigger;

const SheetClose = SheetPrimitive.Close;

const SheetPortal = SheetPrimitive.Portal;

const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className,
)}
{...props}
ref={ref}
/>
));
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;

const sheetVariants = cva(
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
{
variants: {
side: {
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
bottom:
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
right:
'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
},
},
defaultVariants: {
side: 'right',
},
},
);

interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
VariantProps<typeof sheetVariants> {}

const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(({ side = 'right', className, children, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
ref={ref}
className={`${cn(sheetVariants({ side }), className)}`}
{...props}
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
));
SheetContent.displayName = SheetPrimitive.Content.displayName;

const SheetHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col space-y-2 text-center sm:text-left',
className,
)}
{...props}
/>
);
SheetHeader.displayName = 'SheetHeader';

const SheetFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
className,
)}
{...props}
/>
);
SheetFooter.displayName = 'SheetFooter';

const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold text-foreground', className)}
{...props}
/>
));
SheetTitle.displayName = SheetPrimitive.Title.displayName;

const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Description
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
));
SheetDescription.displayName = SheetPrimitive.Description.displayName;

export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
};
2 changes: 1 addition & 1 deletion src/modules/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const HomeModule: React.FC = () => {
setQuery(e.target.value);

return (
<div className="max-w-screen mt-36 flex min-h-screen flex-col items-center md:mt-28">
<div className="max-w-screen mb-14 mt-36 flex min-h-screen flex-col items-center md:mt-28">
<h1 className="text-2xl font-bold">Baca Al-Quran Online</h1>
<SearchBar query={query} handleQueryChange={handleQueryChange} />
<div className="mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
Expand Down
Loading

0 comments on commit 3c32237

Please sign in to comment.