-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df1a4cc
commit 4cd9987
Showing
25 changed files
with
163 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
import { Character } from 'rickmortyapi'; | ||
import { useLoaderData } from 'react-router-dom'; | ||
import MiniCard from './MiniCard'; | ||
|
||
export default function CharacterDetail({ character }: { character?: Character }) { | ||
const char = character || useLoaderData() as Character; | ||
return ( | ||
<section className="p-4 text-left"> | ||
<div className="flex gap-4 p-4 border-b border-gray-200 dark:border-gray-700"> | ||
<img src={char.image} alt={char.name} className="w-24 h-24 rounded-full" /> | ||
<div> | ||
<h2 className="text-xl font-bold text-gray-800 dark:text-gray-200">{char.name}</h2> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
{char.species} from {char.origin.name} | ||
</p> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
Status: {char.status} | ||
</p> | ||
</div> | ||
</div> | ||
</section> | ||
<MiniCard title={char.name} image={char.image} description={char.species} /> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { useLoaderData } from "react-router-dom"; | ||
import { Episode } from "rickmortyapi"; | ||
import MiniCard from "./MiniCard"; | ||
|
||
import Season1 from "/seasons/s01.jpg"; | ||
import Season2 from "/seasons/s02.jpg"; | ||
import Season3 from "/seasons/s03.jpg"; | ||
import Season4 from "/seasons/s04.jpg"; | ||
import Season5 from "/seasons/s05.jpg"; | ||
import Season6 from "/seasons/s06.jpg"; | ||
|
||
export default function EpisodeDetail({ episode }: { episode?: Episode }) { | ||
const ep = episode || useLoaderData() as Episode; | ||
const season = parseInt(ep.episode.slice(2, 3), 10); | ||
const images = [Season1, Season2, Season3, Season4, Season5, Season6]; | ||
const image = season <= 6 ? images[season - 1] : images[0]; | ||
return ( | ||
<section className="p-4 text-left"> | ||
<div className="flex gap-4 p-4 border-b border-gray-200 dark:border-gray-700"> | ||
<div> | ||
<h2 className="text-xl font-bold text-gray-800 dark:text-gray-200">{ep.episode}: {ep.name}</h2> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
{ep.air_date} | ||
</p> | ||
{ep.characters.length} characters | ||
</div> | ||
</div> | ||
</section> | ||
<MiniCard title={`${ep.episode}`} image={image} description={`${ep.name}`} /> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
import { useLoaderData } from "react-router-dom"; | ||
import { Location } from "rickmortyapi"; | ||
import MiniCard from "./MiniCard"; | ||
import PortalImage from "/portal.png" | ||
import PlanetImage from "/planet.png" | ||
|
||
export default function LocationDetail({ location }: { location?: Location }) { | ||
const place = location || useLoaderData() as Location; | ||
return ( | ||
<section className="p-4 text-left"> | ||
<div className="flex gap-4 p-4 border-b border-gray-200 dark:border-gray-700"> | ||
<div> | ||
<h2 className="text-xl font-bold text-gray-800 dark:text-gray-200">{place.name}</h2> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
{place.type} - {place.dimension} | ||
</p> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
{place.residents.length} residents | ||
</p> | ||
</div> | ||
</div> | ||
</section> | ||
<MiniCard title={place.name} image={place.type === "Planet" ? PlanetImage : PortalImage} description={`${place.type}`} /> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function MiniCard({ title, image, description}: { title: string, image: string, description: string }) { | ||
return (<section className="portal-hover h-full text-left max-w-md mx-auto bg-white dark:bg-gray-800 rounded-lg shadow-md"> | ||
<div className="flex h-full gap-4"> | ||
<img src={image} alt={title} className="w-24 h-24 rounded-tl-lg rounded-bl-lg" /> | ||
<div className='z-10'> | ||
<h2 className="text-xl mt-2 font-bold text-gray-800 dark:text-gray-200">{title}</h2> | ||
<p className="text-gray-600 dark:text-gray-400"> | ||
{description} | ||
</p> | ||
</div> | ||
</div> | ||
</section>); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Character } from 'rickmortyapi'; | ||
import { Link, useLoaderData, useSearchParams } from 'react-router-dom'; | ||
import CharacterDetail from '../components/CharacterDetail'; | ||
import Pagination from '../components/Pagination'; | ||
|
||
export default function Characters() { | ||
const [params, ] = useSearchParams() | ||
const page = parseInt(params.get('page') || '1'); | ||
const { characters, pages } = useLoaderData() as { characters: Character[], pages: number }; | ||
|
||
return ( | ||
<section className="p-4 text-left"> | ||
<Pagination page={page} totalPages={pages} /> | ||
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4'> | ||
{characters.map((character) => ( | ||
<Link key={character.id} to={`/characters/${character.id}`}> | ||
<CharacterDetail key={character.id} character={character} /> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Link, useLoaderData, useSearchParams } from "react-router-dom"; | ||
import { Episode } from "rickmortyapi"; | ||
import EpisodeDetail from "../components/EpisodeDetail"; | ||
import Pagination from "../components/Pagination"; | ||
|
||
export default function Episodes() { | ||
const [params, ] = useSearchParams() | ||
const page = parseInt(params.get('page') || '1'); | ||
const { episodes, pages } = useLoaderData() as { episodes: Episode[], pages: number }; | ||
|
||
return ( | ||
<section className="p-4 text-left"> | ||
<Pagination page={page} totalPages={pages} /> | ||
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4'> | ||
{episodes.map((episode) => ( | ||
<Link key={episode.id} to={`/episodes/${episode.id}`}> | ||
<EpisodeDetail key={episode.id} episode={episode} /> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Link, useLoaderData, useSearchParams } from "react-router-dom"; | ||
import { Location } from "rickmortyapi"; | ||
import LocationDetail from "../components/LocationDetail"; | ||
import Pagination from "../components/Pagination"; | ||
|
||
export default function Locations() { | ||
const [params, ] = useSearchParams() | ||
const page = parseInt(params.get('page') || '1'); | ||
const { locations, pages } = useLoaderData() as { locations: Location[], pages: number }; | ||
|
||
return ( | ||
<section className="p-4 text-left"> | ||
<Pagination page={page} totalPages={pages} /> | ||
<div className='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4'> | ||
{locations.map((location) => ( | ||
<Link key={location.id} to={`/locations/${location.id}`}> | ||
<LocationDetail key={location.id} location={location} /> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.