refactor: layout improvements; suggestions count increased up to 10

This commit is contained in:
ner committed 2023-08-05 16:11:20 +03:00
1 parent c605414f73
commit a4f420821a
8 files changed
+44 -30

No files matched your search

+3 -3
View File
@@ -11,9 +11,9 @@ export async function GET(request: Request) {
try {
const completion = await openai.createCompletion({
model: 'text-davinci-003',
prompt: `Based on the movie description: ${params.description}, suggest 5 movies. Format of suggestions: only title separated by comma`,
max_tokens: 70,
temperature: 0.4,
prompt: `Based on the movie description: ${params.description}, suggest 10 movies. Format of suggestions: only title separated by comma`,
max_tokens: 120,
temperature: 0.2,
stop: ['Based on the movie description:']
});
+7 -1
View File
@@ -9,7 +9,13 @@ import '@/styles/index.css';
export const metadata: Metadata = {
title: 'Movie advisor',
description: 'It will help you find a movie for evening'
description: 'It will help you find a movie for evening',
viewport: {
width: 'device-width',
initialScale: 1,
maximumScale: 1,
userScalable: false
}
};
export default function RootLayout({ children }: { children: ReactNode }) {
+4 -4
View File
@@ -17,18 +17,18 @@ const Card: FC<Props> = ({ movie, className }) => {
className={`${className} p-4 rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-lg`}
>
<div>
<div className='grid items-center grid-cols-[1fr_70px]'>
<div className='grid items-center grid-cols-[1fr_50px]'>
<Title title={movie.title} />
{movie.release_date && (
<span className='flex justify-end text-lg font-semibold'>{new Date(movie.release_date).getFullYear()}</span>
)}
</div>
<div className='flex w-full justify-between'>
<Star />
<div className='flex w-full justify-end items-center gap-1 mt-[-8px]'>
<Star size={17} />
<span className='text-lg font-semibold'>{movie.vote_average}</span>
</div>
</div>
<div className='flex justify-center relative'>
<div className='flex justify-center relative mt-1 h-full'>
<Poster title={movie.title} width={300} height={450} size={100} poster={movie.poster_path} />
</div>
</div>
+2 -2
View File
@@ -36,7 +36,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage }) => {
return (
<>
<ul className='flex gap-3 flex-wrap'>
<ul className='flex gap-3 flex-wrap justify-between'>
{pages.map((page) => (
<Fragment key={page.page}>
{page.results?.map((movie, index, array) => (
@@ -52,7 +52,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage }) => {
</Fragment>
))}
</ul>
<div className='h-4 w-full'></div>
<div className='h-4 w-full' />
{movie && (
<Dialog defaultOpen={true} onOpenChange={(isOpen) => !isOpen && setMovie(null)}>
<DialogContent className='block p-0'>
+17 -7
View File
@@ -19,17 +19,27 @@ const Preview: FC<Props> = ({ movie, className }) => {
return (
<div className={`p-3 rounded-lg border bg-card text-card-foreground shadow-sm ${className}`}>
<div className='flex flex-col lg:flex-row max-w-[100%] gap-3 overflow-hidden'>
<Poster title={movie.title} width={300} height={450} size={250} poster={movie.poster_path} />
<Poster
title={movie.title}
width={300}
height={450}
size={250}
poster={movie.poster_path}
className='max-w-[300px]'
/>
<div className='flex flex-col grow lg:max-w-[calc(100%-(300px+0.75rem))]'>
<div className='flex'>
<div className='flex flex-row w-full items-end justify-between text-lg font-semibold'>
<span>
<Title title={movie.title} /> {movie.release_date && `(${new Date(movie.release_date).getFullYear()})`}
<div className='flex flex-row flex-wrap w-full text-lg font-semibold'>
<span className='flex w-full items-center'>
<span className='mr-2 w-full'>
<Title title={movie.title} />
</span>
<div className='flex items-center gap-2'>
<Star />
{movie.release_date && <span className='ml-auto'>{new Date(movie.release_date).getFullYear()}</span>}
</span>
<span className='flex items-center ml-auto gap-1 mt-[-8px]'>
<Star size={18} />
<span>{movie.vote_average}</span>
</div>
</span>
</div>
</div>
<Separator className='my-4' />
+7 -4
View File
@@ -8,14 +8,17 @@ interface Props {
width: number;
height: number;
size: number;
className?: string;
}
const Poster: FC<Props> = ({ title, poster, width, height, size = 250 }) => {
const Poster: FC<Props> = ({ title, poster, width, height, size = 250, className }) => {
return (
<div className='max-w-[300px] h-[450px] w-full rounded-lg overflow-hidden shrink-0 relative m-auto lg:m-0'>
<div
className={`h-[${height}px] w-full flex flex-col rounded-lg overflow-hidden shrink-0 relative m-auto lg:m-0 ${className}`}
>
{poster ? (
<Image
className='rounded-lg '
className='rounded-lg m-auto'
unoptimized
height={height}
width={width}
@@ -23,7 +26,7 @@ const Poster: FC<Props> = ({ title, poster, width, height, size = 250 }) => {
alt={title}
/>
) : (
<div className={`w-[${width}px] h-[${height}px] flex items-center justify-center rounded-lg border`}>
<div className={'w-full h-full grow flex items-center justify-center rounded-lg border'}>
<ImageOff size={size} strokeWidth={1} />
</div>
)}
+3 -8
View File
@@ -2,7 +2,6 @@
import * as React from 'react';
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { X } from 'lucide-react';
import { cn } from '@/lib/utils';
@@ -35,21 +34,17 @@ const DialogContent = React.forwardRef<
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay className='overflow-auto'>
<DialogOverlay className='overflow-auto flex justify-center'>
<DialogPrimitive.Content
ref={ref}
className={cn(
'absolute left-[50%] translate-x-[-50%] top-[20vh] max-w-[1000px] w-[calc(100%-24px)] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-lg',
'absolute top-[20vh] max-w-[1000px] w-[calc(100%-24px)] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-lg',
className
)}
{...props}
>
{children}
<DialogPrimitive.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-accent data-[state=open]:text-muted-foreground'>
<X className='h-4 w-4' />
<span className='sr-only'>Close</span>
</DialogPrimitive.Close>
<DialogPrimitive.Close className='absolute w-full block h-[20vh]' />
<DialogPrimitive.Close type='button' autoFocus={false} className='absolute w-full block h-[20vh] outline-0' />
</DialogPrimitive.Content>
</DialogOverlay>
</DialogPortal>
+1 -1
View File
@@ -81,7 +81,7 @@
main,
header {
max-width: 1200px;
max-width: 1050px;
margin: 0 auto;
padding: 0 12px;
}