Skip to content

Commit

Permalink
feat: Add NextJS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dauntlessryan committed Apr 25, 2023
1 parent b694d4f commit 449933d
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 133 deletions.
58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,62 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# Dauntless React, NextJS and TypeScript Test

## Overview

The purpose of this test is to assess your skills and approach to composing a simple NextJS React web app given an API feed.

This test is expected to take about 2-4 hours.

## Getting Started

First, run the development server:
Download or clone this repo.

Install dependencies and run the development server:

```bash
npm install
npm run dev
# or
yarn dev
# or
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
## API for application test

For this test you will be making use of the the **free** [CoinGecko API](https://www.coingecko.com/en/api/documentation).

Keep in mind when building that their free API has a rate limit of 50 calls/minute, however this should be more than sufficient.

## Application requirement

- Convert the static content generated by the array called `cards` in to a dynamic feed of crypto currencies that are traded against the dollar (USD).

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
- Access the CoinGecko api using the `/coins/markets` endpoint and return 45 results using `USD` for the `vs_currency` parameter

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
- With the returned data you will need to display the 45 results with the following information on the cards;

## Learn More
- Image
- Currency Name
- Current Price
- 24h High Price
- 24H Low Price

To learn more about Next.js, take a look at the following resources:
- The cards currently have a "MORE" button that is not connected to any routes. This button needs to take the user to a route for the clicked on currency with the path following the following format `/currency/{symbol}` where `{symbol}` is a value from the returned data.

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- Once the user lands on the `/currency/{symbol}` page for the selected crypto currency you need to display the following information;
- Currency Name
- Current Price
- All time high price
- Market Cap
- Market Cap Rank

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Additional items to consider

## Deploy on Vercel
- Ensure you have navigation back from the currency specific pages back to the main list page.
- The code provided has no code or libraries related to data fetching and this is the main focus of what you are implementing. For this test we do not require that you use a specific library but would recommend [Tanstack Query](https://tanstack.com/query/v3/) as this is our preferred option.
- Making use of Hooks where and if it may make sense would show us your understanding of this.
- If you would like to showcase your understanding of component styling then feel inspired to modify the basics that have been provided to you.

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
## Steps to complete your project

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
- At the start of this project you would have forked the Dauntless React Test repository and once you are complete we would like you to push the code to a public repository in your github account and then provide the link to the repository to Dauntless.
7 changes: 5 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
images: {
domains: ["picsum.photos"],
},
};

module.exports = nextConfig
module.exports = nextConfig;
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@heroicons/react": "^2.0.17",
"@types/node": "18.16.0",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
Expand Down
168 changes: 54 additions & 114 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,58 @@
import Image from 'next/image'
import { Inter } from 'next/font/google'
import Head from "next/head";
import Image from "next/image";
import React from "react";

const inter = Inter({ subsets: ['latin'] })

export default function Home() {
const Home: React.FC = () => {
const cards = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // Replace this with your actual data
return (
<main
className={`flex min-h-screen flex-col items-center justify-between p-24 ${inter.className}`}
>
<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">pages/index.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:h-auto lg:w-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=default-template-tw&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>
<>
<Head>
<title>CoinGecko Market Pairs (USD)</title>
</Head>
<main>
<div className="bg-white pt-8 pb-6">
<div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-sm">
<h1 className="text-4xl font-bold text-center text-gray-900 mb-4">
Market Pairs (USD)
</h1>
<p className="text-xl text-center text-gray-600">
The following is a list of crypto currencies with information
related to the USD trading pair.
</p>
</div>
</div>
</div>

<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] 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-[240px] 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/10 after:dark:from-sky-900 after:dark:via-[#0141ff]/40 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:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-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`}>
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=default-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=default-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`}>
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`}>
Discover and deploy boilerplate example Next.js&nbsp;projects.
</p>
</a>
<div className="container mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* End hero unit */}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
{cards.map((card) => (
<div key={card} className="flex flex-col">
<Image
src={`https://picsum.photos/200/200`}
alt="placeholder"
width={200}
height={200}
className="object-cover object-center"
/>
<div className="flex-1 p-4">
<h2 className="text-xl font-semibold mb-2">Currency Name</h2>
<ul className="list-disc pl-5">
<li>Current Price: xxx</li>
<li>24h High: xxx</li>
<li>24h Low: xxx</li>
</ul>
</div>
<div className="p-4">
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
More
</button>
</div>
</div>
))}
</div>
</div>
</main>
</>
);
};

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-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`}>
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-sm opacity-50`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
)
}
export default Home;

0 comments on commit 449933d

Please sign in to comment.