Skip to content

Commit

Permalink
Merge pull request #4 from OneRandom1509/feat-migration-to-app-router
Browse files Browse the repository at this point in the history
Issue #1 - Migration from pages router to app router
  • Loading branch information
ThEditor authored Oct 31, 2023
2 parents e4cbcfe + bbe1db6 commit 9e53fde
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 237 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/pages/404.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';

import NotFoundPage from '@/pages/404';
import NotFoundPage from '@/app/not-found';

describe('404', () => {
describe('not-found', () => {
it('renders a heading', () => {
render(<NotFoundPage />);

Expand Down
7 changes: 4 additions & 3 deletions src/pages/account.tsx → src/app/account/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import { Metadata } from 'next';

import Seo from '@/components/Seo';
export const metadata: Metadata = {
title: 'Account',
};

export default function AccountPage() {
return (
<>
<Seo />
<main className='flex items-center justify-center'>
<h1>Account Settings Here</h1>
</main>
Expand Down
35 changes: 35 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Metadata } from 'next';
import * as React from 'react';

import '../styles/globals.css';

import Player from '../components/Player';
import Sidebar from '../components/sidebar/Sidebar';

export const metadata: Metadata = {
title: {
default: 'Nex | Music Player',
template: '%s | Nex',
},
applicationName: 'Nex | Music Player',
description: 'A spotify inspired music players for communities and groups',
authors: { name: 'ThEditor', url: 'https://nex.theditor.xyz' },
robots: 'follow, index',
icons: { icon: 'https://theditor.xyz/assets/img/profile-img.jpg' },
};

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<div className='text-alt bg-dark flex h-screen flex-col'>
<div className='flex h-[87%]'>
<Sidebar className='w-[5%]' />
<div className='h-full flex-grow overflow-y-auto'>{children}</div>
</div>
<Player className='h-[13%]' />
</div>
</body>
</html>
);
}
17 changes: 7 additions & 10 deletions src/pages/login.tsx → src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { useRouter } from 'next/router';
import { useEffect } from 'react';
import { Metadata } from 'next';
import { redirect } from 'next/navigation';

import Button from '@/components/buttons/Button';
import UnderlineLink from '@/components/links/UnderlineLink';

export const metadata: Metadata = {
title: 'Login',
};

export default function LoginPage() {
const router = useRouter();
const signedin = false;

useEffect(() => {
if (signedin) router.push('/');
}, [router, signedin]);

if (signedin) {
router.push('/');
return <></>;
redirect('/');
}

return !signedin ? (
Expand Down
12 changes: 12 additions & 0 deletions src/app/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Metadata } from 'next';
import { redirect } from 'next/navigation';

export const metadata: Metadata = {
title: 'Logout',
};

export default function LogoutPage() {
const signedin = true;

return signedin ? redirect('/') : <></>;
}
3 changes: 0 additions & 3 deletions src/pages/404.tsx → src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import * as React from 'react';
import { RiAlarmWarningFill } from 'react-icons/ri';

import ArrowLink from '@/components/links/ArrowLink';
import Seo from '@/components/Seo';

export default function NotFoundPage() {
return (
<div className='h-full'>
<Seo templateTitle='Not Found' />

<main className='h-full'>
<section className='h-full bg-white'>
<div className='layout flex h-full flex-col items-center justify-center text-center text-black'>
Expand Down
17 changes: 5 additions & 12 deletions src/pages/index.tsx → src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import * as React from 'react';

import Carousel, { CarouselProps } from '@/components/carousel/Carousel';
Expand All @@ -14,17 +15,13 @@ export default function HomePage() {
{
title: 'Life in a bubble',
subtitle: 'The van',
clickAction: () => {
return;
},
link: '/',
imgSrc: '/images/test.png',
},
{
title: 'Life in a bubble',
subtitle: 'The van',
clickAction: () => {
return;
},
link: '/',
imgSrc: '/images/test.png',
},
],
Expand All @@ -35,17 +32,13 @@ export default function HomePage() {
{
title: 'Life in a bubble',
subtitle: 'The van',
clickAction: () => {
return;
},
link: '/',
imgSrc: '/images/test.png',
},
{
title: 'Life in a bubble',
subtitle: 'The van',
clickAction: () => {
return;
},
link: '/',
imgSrc: '/images/test.png',
},
],
Expand Down
8 changes: 4 additions & 4 deletions src/pages/search.tsx → src/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';

import Seo from '@/components/Seo';
import { Metadata } from 'next';

export const metadata: Metadata = {
title: 'Search',
};
export default function Search() {
return (
<>
<Seo />
<main className='flex items-center justify-center'>
<h1>Searching...</h1>
</main>
Expand Down
1 change: 1 addition & 0 deletions src/components/NextImage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import Image, { ImageProps } from 'next/image';
import * as React from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
ImVolumeHigh,
} from 'react-icons/im';

import '@/styles/globals.css';

import clsxm from '@/lib/clsxm';

import IconButton from '@/components/buttons/IconButton';
import NextImage from '@/components/NextImage';
import Slider from '@/components/Slider';

interface PlayerProps {
className?: string;
}
Expand Down
111 changes: 0 additions & 111 deletions src/components/Seo.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Carousel({ data }: CarouselProps) {
title={v.title}
subtitle={v.subtitle}
imgSrc={v.imgSrc}
clickAction={v.clickAction}
link={v.link}
/>
))}
</div>
Expand Down
9 changes: 6 additions & 3 deletions src/components/carousel/CarouselItem.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
'use client';
import { redirect } from 'next/navigation';

import clsxm from '@/lib/clsxm';

import NextImage from '@/components/NextImage';

export interface CarouselItemProps {
title: string;
subtitle: string;
clickAction: () => void;
link: string;
imgSrc: string;
className?: string;
}

export default function CarouselItem({
title,
subtitle,
clickAction,
link,
imgSrc,
className,
}: CarouselItemProps) {
Expand All @@ -23,7 +26,7 @@ export default function CarouselItem({
className,
'text-light font-quicksand hover:bg-light flex w-fit cursor-pointer select-none flex-col gap-1 rounded-3xl p-3 transition-all ease-linear hover:bg-opacity-10'
)}
onClick={() => clickAction()}
onClick={() => redirect(link)}
>
<NextImage
style={{ borderRadius: '20%' }}
Expand Down
16 changes: 0 additions & 16 deletions src/components/layout/Layout.tsx

This file was deleted.

Loading

0 comments on commit 9e53fde

Please sign in to comment.