Skip to content

Commit

Permalink
feat: create home page with list of surah
Browse files Browse the repository at this point in the history
  • Loading branch information
iqbalpa committed Jul 19, 2024
1 parent c0ee85a commit c3ece79
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"trailingComma": "all",
"semi": true,
"bracketSpacing": true,
"tabWidth": 4,
"tabWidth": 2,
"plugins": ["prettier-plugin-tailwindcss"]
}
65 changes: 34 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
{
"name": "quran",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --check .",
"format:fix": "prettier --write --list-different .",
"prepare": "npx husky install"
},
"dependencies": {
"next": "14.2.2",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"postcss": "^8",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
"name": "quran",
"version": "0.1.0",
"private": true,
"proxy": "https://equran.id",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --check .",
"format:fix": "prettier --write --list-different .",
"prepare": "npx husky install"
},
"dependencies": {
"axios": "^1.7.2",
"lint-staged": "^15.2.7",
"next": "14.2.2",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"postcss": "^8",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
15 changes: 15 additions & 0 deletions src/api/api.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ISurah } from '@/constant/surah.constant';
import axios from 'axios';

const BASE_URL = 'https://equran.id';

export const getAllSurah = async (): Promise<ISurah[]> => {
const res = await axios.get(`${BASE_URL}/api/v2/surat`, {
headers: {
Accept: '*/*',
'Content-Type': 'application/json',
},
});
const surahs: ISurah[] = res.data.data;
return surahs;
};
30 changes: 0 additions & 30 deletions src/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
20 changes: 11 additions & 9 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import './globals.css';
const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: "Al - Qur'an",
description: 'Reading Quran Online Here',
title: "Al - Qur'an",
description: 'Reading Quran Online Here',
};

export default function RootLayout({
children,
children,
}: Readonly<{
children: React.ReactNode;
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
return (
<html lang="en">
<body className={`${inter.className} bg-gray-900 text-slate-200`}>
{children}
</body>
</html>
);
}
112 changes: 2 additions & 110 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,5 @@
import Image from "next/image";
import HomeModule from '@/modules/home/home';

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">src/app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:size-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{" "}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>

<div className="relative z-[-1] flex place-items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>

<div className="mb-32 grid text-center lg:mb-0 lg:w-full lg:max-w-5xl lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Docs{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Find in-depth information about Next.js features and API.
</p>
</a>

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Learn{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Templates{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Explore starter templates for Next.js.
</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Deploy{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-balance text-sm opacity-50">
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
);
return <HomeModule />;
}
17 changes: 0 additions & 17 deletions src/components/card/Card.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions src/constant/surah.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface ISurah {
nomor: number;
nama: string;
namaLatin: string;
jumlahAyat: number;
tempatTurun: string;
arti: string;
deskripsi: string;
audioFull: { [key: string]: string };
}
17 changes: 0 additions & 17 deletions src/modules/about/About.tsx

This file was deleted.

59 changes: 59 additions & 0 deletions src/modules/home/home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use client';

import React, { useEffect, useState } from 'react';
import { getAllSurah } from '@/api/api';
import { ISurah } from '@/constant/surah.constant';

const HomeModule: React.FC = () => {
const [surahs, setSurahs] = useState<ISurah[]>([]);

useEffect(() => {
const fetchData = async () => {
try {
const res = await getAllSurah();
console.log(res);
setSurahs(res);
} catch (e) {
console.log('failed to fetch the surah');
}
};
fetchData();
}, []);

return (
<div className="max-w-screen m-10 flex min-h-screen flex-col items-center">
<h1 className="text-2xl font-bold">Baca Al-Quran Online</h1>
<div className="mt-5 grid grid-cols-4 gap-3">
{surahs.map((surah, _index) => (
<div
key={surah.nomor}
className="hover:border-teal-300S group flex flex-row justify-between rounded-md border-[1px] border-slate-400 bg-slate-700 p-4 duration-200 hover:cursor-pointer hover:border-teal-300"
>
<div className="flex flex-row items-center gap-3">
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-slate-900 group-hover:bg-teal-300">
<p className="font-bold group-hover:text-slate-900">
{surah.nomor}
</p>
</div>

<div>
<p className="font-semibold">{surah.namaLatin}</p>
<p className="text-sm text-slate-400 group-hover:text-teal-300">
{surah.arti}
</p>
</div>
</div>
<div className="text-right">
<p>{surah.nama}</p>
<p className="text-sm text-slate-400 group-hover:text-teal-300">
{surah.jumlahAyat} ayat
</p>
</div>
</div>
))}
</div>
</div>
);
};

export default HomeModule;
Loading

0 comments on commit c3ece79

Please sign in to comment.