Skip to content

Commit

Permalink
🎨 added empty states for movies and shows
Browse files Browse the repository at this point in the history
  • Loading branch information
pouyio committed Feb 7, 2024
1 parent 398d70d commit 2442182
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/assets/ufo-3-svgrepo-com.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
20 changes: 20 additions & 0 deletions src/components/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Link } from 'react-router-dom';
import { Icon } from './Icon';

export const EmptyState = () => (
<div className="bg-gray-100 max-w-80 m-auto mt-12 rounded-3xl p-5">
<div className="text-center">
<Icon name="ufo" />
<h1 className="my-5 text-2xl font-bold">Nothing to see here yet</h1>
<p className="my-5 font-thin">
Start following a show or add a movie to your watchlist
</p>
<Link
to="/search"
className="bg-gray-200 py-2 px-6 rounded-full text-gray-700 inline-block"
>
Go for it!
</Link>
</div>
</div>
);
2 changes: 2 additions & 0 deletions src/components/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Share from 'assets/share-svgrepo-com.svg?react';
import Like from 'assets/like-svgrepo-com.svg?react';
import Play from 'assets/play-circle-svgrepo-com.svg?react';
import Logout from 'assets/logout-2-svgrepo-com.svg?react';
import Ufo from 'assets/ufo-3-svgrepo-com.svg?react';
import { ThemeContext } from 'contexts';
import React, { HTMLProps, useContext } from 'react';

Expand All @@ -36,6 +37,7 @@ const iconsMap = {
like: <Like />,
play: <Play />,
logout: <Logout />,
ufo: <Ufo />,
} as const;

interface IconProps extends HTMLProps<HTMLDivElement> {
Expand Down
5 changes: 4 additions & 1 deletion src/pages/movies/MoviesWatched.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAppSelector } from 'state/store';
import ImageLink from '../../components/ImageLink';
import PaginationContainer from '../../components/Pagination/PaginationContainer';
import { usePagination } from '../../hooks';
import { EmptyState } from 'components/EmptyState';

export const MoviesWatched: React.FC = () => {
const [orderedMovies, setOrderedMovies] = useState<MovieWatched[]>([]);
Expand All @@ -21,7 +22,7 @@ export const MoviesWatched: React.FC = () => {
setOrderedMovies(newItems);
}, [watched]);

return (
return orderedMovies.length ? (
<PaginationContainer items={orderedMovies} onFilter={setGenres}>
<ul className="flex flex-wrap p-2 items-stretch justify-center">
{getItemsByPage().map((m, i) => (
Expand All @@ -41,5 +42,7 @@ export const MoviesWatched: React.FC = () => {
))}
</ul>
</PaginationContainer>
) : (
<EmptyState />
);
};
5 changes: 4 additions & 1 deletion src/pages/movies/MoviesWatchlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useState } from 'react';
import { filterByGenres } from 'state/slices/movies';
import { useAppSelector } from 'state/store';
import { usePagination } from '../../hooks';
import { EmptyState } from 'components/EmptyState';

export const MoviesWatchlist: React.FC = () => {
const [genres, setGenres] = useState<string[]>([]);
Expand All @@ -29,7 +30,7 @@ export const MoviesWatchlist: React.FC = () => {

const { getItemsByPage } = usePagination(orderedMovies);

return (
return orderedMovies.length ? (
<PaginationContainer items={orderedMovies} onFilter={setGenres}>
<ul className="flex flex-wrap p-2 items-stretch justify-center">
{getItemsByPage().map((m, i) => (
Expand All @@ -49,5 +50,7 @@ export const MoviesWatchlist: React.FC = () => {
))}
</ul>
</PaginationContainer>
) : (
<EmptyState />
);
};
5 changes: 4 additions & 1 deletion src/pages/shows/ShowsWatched.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAppSelector } from 'state/store';
import ImageLink from '../../components/ImageLink';
import PaginationContainer from '../../components/Pagination/PaginationContainer';
import { usePagination } from '../../hooks';
import { EmptyState } from 'components/EmptyState';

const ShowsWatched: React.FC = () => {
const [orderedShows, setOrderedShows] = useState<ShowWatched[]>([]);
Expand All @@ -29,7 +30,7 @@ const ShowsWatched: React.FC = () => {

const { getItemsByPage } = usePagination(orderedShows);

return (
return orderedShows.length ? (
<PaginationContainer items={orderedShows} onFilter={setGenres}>
<ul className="flex flex-wrap p-2 items-stretch justify-center">
{getItemsByPage().map((m) => (
Expand All @@ -49,6 +50,8 @@ const ShowsWatched: React.FC = () => {
))}
</ul>
</PaginationContainer>
) : (
<EmptyState />
);
};

Expand Down
5 changes: 4 additions & 1 deletion src/pages/shows/ShowsWatchlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAppSelector } from 'state/store';
import ImageLink from '../../components/ImageLink';
import PaginationContainer from '../../components/Pagination/PaginationContainer';
import { usePagination } from '../../hooks';
import { EmptyState } from 'components/EmptyState';

const ShowsWatchlist: React.FC = () => {
const [genres, setGenres] = useState<string[]>([]);
Expand All @@ -28,7 +29,7 @@ const ShowsWatchlist: React.FC = () => {
}, []);
const { getItemsByPage } = usePagination(orderedShows);

return (
return orderedShows.length ? (
<PaginationContainer items={orderedShows} onFilter={setGenres}>
<ul className="flex flex-wrap p-2 items-stretch justify-center">
{getItemsByPage().map((m) => (
Expand All @@ -48,6 +49,8 @@ const ShowsWatchlist: React.FC = () => {
))}
</ul>
</PaginationContainer>
) : (
<EmptyState />
);
};

Expand Down

0 comments on commit 2442182

Please sign in to comment.