-
Notifications
You must be signed in to change notification settings - Fork 35
rtk eval #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PaulJohnson19
wants to merge
2
commits into
projectshft:main
Choose a base branch
from
PaulJohnson19:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
rtk eval #6
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,42 @@ | ||
| import React from 'react' | ||
| import { useState } from 'react' | ||
|
|
||
| const SearchBar = ({ onSearch }) => { | ||
| const [searchCity, setSearchCity] = useState(''); | ||
|
|
||
| //trim removing whitespace to help validate search parameters | ||
| const handleSearch = () => { | ||
| if (searchCity.trim() !=='') { | ||
| onSearch(searchCity.trim()); | ||
| setSearchCity(''); | ||
| } | ||
| }; | ||
| //convenience to hit 'enter' instead of only clicking by calling handlesearch via 'enter' keydown | ||
| const handleKeyDown = (e) => { | ||
| if (e.key === 'Enter') { | ||
| handleSearch(); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <input | ||
| className='city-input' | ||
| type='text' | ||
| placeholder='Enter city' | ||
| value={searchCity} | ||
| onChange={(e) => setSearchCity(e.target.value)} | ||
| onKeyDown={handleKeyDown} | ||
| /> | ||
| <button | ||
| className='button' | ||
|
|
||
| onClick={handleSearch} | ||
| > | ||
| Search | ||
| </button> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default SearchBar; | ||
This file contains hidden or 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,107 +1,29 @@ | ||
| :root { | ||
| --max-width: 1100px; | ||
| --border-radius: 12px; | ||
| --font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', | ||
| 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', | ||
| 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace; | ||
|
|
||
| --foreground-rgb: 0, 0, 0; | ||
| --background-start-rgb: 214, 219, 220; | ||
| --background-end-rgb: 255, 255, 255; | ||
|
|
||
| --primary-glow: conic-gradient( | ||
| from 180deg at 50% 50%, | ||
| #16abff33 0deg, | ||
| #0885ff33 55deg, | ||
| #54d6ff33 120deg, | ||
| #0071ff33 160deg, | ||
| transparent 360deg | ||
| ); | ||
| --secondary-glow: radial-gradient( | ||
| rgba(255, 255, 255, 1), | ||
| rgba(255, 255, 255, 0) | ||
| ); | ||
|
|
||
| --tile-start-rgb: 239, 245, 249; | ||
| --tile-end-rgb: 228, 232, 233; | ||
| --tile-border: conic-gradient( | ||
| #00000080, | ||
| #00000040, | ||
| #00000030, | ||
| #00000020, | ||
| #00000010, | ||
| #00000010, | ||
| #00000080 | ||
| ); | ||
|
|
||
| --callout-rgb: 238, 240, 241; | ||
| --callout-border-rgb: 172, 175, 176; | ||
| --card-rgb: 180, 185, 188; | ||
| --card-border-rgb: 131, 134, 135; | ||
| body { | ||
| background-color: rgb(243, 231, 217); | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --foreground-rgb: 255, 255, 255; | ||
| --background-start-rgb: 0, 0, 0; | ||
| --background-end-rgb: 0, 0, 0; | ||
|
|
||
| --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0)); | ||
| --secondary-glow: linear-gradient( | ||
| to bottom right, | ||
| rgba(1, 65, 255, 0), | ||
| rgba(1, 65, 255, 0), | ||
| rgba(1, 65, 255, 0.3) | ||
| ); | ||
|
|
||
| --tile-start-rgb: 2, 13, 46; | ||
| --tile-end-rgb: 2, 5, 19; | ||
| --tile-border: conic-gradient( | ||
| #ffffff80, | ||
| #ffffff40, | ||
| #ffffff30, | ||
| #ffffff20, | ||
| #ffffff10, | ||
| #ffffff10, | ||
| #ffffff80 | ||
| ); | ||
|
|
||
| --callout-rgb: 20, 20, 20; | ||
| --callout-border-rgb: 108, 108, 108; | ||
| --card-rgb: 100, 100, 100; | ||
| --card-border-rgb: 200, 200, 200; | ||
| } | ||
| h2 { | ||
| color: rgb(78, 140, 240); | ||
| } | ||
|
|
||
| * { | ||
| box-sizing: border-box; | ||
| padding: 0; | ||
| margin: 0; | ||
| .button{ | ||
| margin-left: 5px; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| max-width: 100vw; | ||
| overflow-x: hidden; | ||
| .button:hover { | ||
| background-color: rgb(193, 193, 241); | ||
| } | ||
|
|
||
| body { | ||
| color: rgb(var(--foreground-rgb)); | ||
| background: linear-gradient( | ||
| to bottom, | ||
| transparent, | ||
| rgb(var(--background-end-rgb)) | ||
| ) | ||
| rgb(var(--background-start-rgb)); | ||
| .city-name-render { | ||
| text-align: center; | ||
| } | ||
|
|
||
| a { | ||
| color: inherit; | ||
| text-decoration: none; | ||
| .render-container { | ||
| display: flex; | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| html { | ||
| color-scheme: dark; | ||
| } | ||
| .spark-box { | ||
| flex: 1; | ||
| margin: 5px; | ||
| border: rgb(75, 74, 74); | ||
| } |
This file contains hidden or 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,17 +1,18 @@ | ||
| 'use client' | ||
| import store from './store/configureStore'; | ||
| import { Inter } from 'next/font/google'; | ||
| import { Provider } from 'react-redux'; | ||
| import './globals.css' | ||
| import { Inter } from 'next/font/google' | ||
|
|
||
| const inter = Inter({ subsets: ['latin'] }) | ||
|
|
||
| export const metadata = { | ||
| title: 'Create Next App', | ||
| description: 'Generated by create next app', | ||
| } | ||
|
|
||
| export default function RootLayout({ children }) { | ||
| return ( | ||
| <html lang="en"> | ||
| <body className={inter.className}>{children}</body> | ||
| <body className={inter.className}> | ||
| <Provider store={store}>{children}</Provider> | ||
| </body> | ||
| </html> | ||
| ) | ||
| } |
This file contains hidden or 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,95 +1,84 @@ | ||
| import Image from 'next/image' | ||
| import styles from './page.module.css' | ||
|
|
||
| 'use client' | ||
| import React from 'react'; | ||
| import SearchBar from './components/searchBar'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import { fetchWeatherAPI } from './store/slices/weatherSlice'; | ||
| import { SparklinesLine, Sparklines, SparklinesReferenceLine } from 'react-sparklines'; | ||
|
|
||
| function getHighLow(data) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: use functional expressions vs declarations |
||
| if (data.length === 0) return { high: 0, low: 0 }; | ||
| const high = Math.round(Math.max(...data)); | ||
| const low = Math.round(Math.min(...data)); | ||
| return { high, low }; | ||
| } | ||
|
|
||
| function averageTemps(data) { | ||
| if (data.length === 0) return 0; | ||
| const sum = data.reduce((accumulator, value) => accumulator + value, 0); | ||
| return Math.round(sum / data.length); | ||
| } | ||
|
|
||
| export default function Home() { | ||
| return ( | ||
| <main className={styles.main}> | ||
| <div className={styles.description}> | ||
| <p> | ||
| Get started by editing | ||
| <code className={styles.code}>app/page.js</code> | ||
| </p> | ||
| <div> | ||
| <a | ||
| href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| By{' '} | ||
| <Image | ||
| src="/vercel.svg" | ||
| alt="Vercel Logo" | ||
| className={styles.vercelLogo} | ||
| width={100} | ||
| height={24} | ||
| priority | ||
| /> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| const dispatch = useDispatch(); | ||
| const cities = useSelector((state) => [...state.weather.cities].reverse()); | ||
| const loading = useSelector((state) => state.weather.loading); | ||
| const error = useSelector((state) => state.weather.error); | ||
|
|
||
| <div className={styles.center}> | ||
| <Image | ||
| className={styles.logo} | ||
| src="/next.svg" | ||
| alt="Next.js Logo" | ||
| width={180} | ||
| height={37} | ||
| priority | ||
| /> | ||
| </div> | ||
| const handleSearch = (searchCity) => { | ||
| dispatch(fetchWeatherAPI(searchCity)); | ||
| }; | ||
|
|
||
| <div className={styles.grid}> | ||
| <a | ||
| href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" | ||
| className={styles.card} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <h2> | ||
| Docs <span>-></span> | ||
| </h2> | ||
| <p>Find in-depth information about Next.js features and API.</p> | ||
| </a> | ||
| return ( | ||
| <div className='smaller'> | ||
| <div className='boxes'> | ||
| <h1 className='page-title'>Basic RTK Weather App</h1> | ||
|
|
||
| <a | ||
| href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" | ||
| className={styles.card} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <h2> | ||
| Learn <span>-></span> | ||
| </h2> | ||
| <p>Learn about Next.js in an interactive course with quizzes!</p> | ||
| </a> | ||
| <SearchBar onSearch={handleSearch} /> | ||
|
|
||
| <a | ||
| href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" | ||
| className={styles.card} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <h2> | ||
| Templates <span>-></span> | ||
| </h2> | ||
| <p>Explore the Next.js 13 playground.</p> | ||
| </a> | ||
| {loading && <p className='Slow-ding'>Be super patient or you'll run out of time.</p>} | ||
| {error && <p className='error'>Error: {error}</p>} | ||
|
|
||
| <a | ||
| href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app" | ||
| className={styles.card} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <h2> | ||
| Deploy <span>-></span> | ||
| </h2> | ||
| <p> | ||
| Instantly deploy your Next.js site to a shareable URL with Vercel. | ||
| </p> | ||
| </a> | ||
| </div> | ||
| </main> | ||
| ) | ||
| } | ||
| {cities.map((cityData, index) => ( | ||
| <div key={index} className='big-container'> | ||
| <h2 className='city-name-render'>Weather in {cityData.city.name}</h2> | ||
| <div className='render-container'> | ||
| <div className='spark-box'> | ||
| <h3 className='temperature-title'>Temperature</h3> | ||
| <Sparklines data={cityData.temperature} height={40}> | ||
| <SparklinesLine color='blue' /> | ||
| <SparklinesReferenceLine type='avg' /> | ||
| </Sparklines> | ||
| <p className='average-temp-display'> | ||
| Average 5-day Temperature: {averageTemps(cityData.temperature)}°F | ||
| </p> | ||
| <p className='average-temp-display'>High: {getHighLow(cityData.temperature).high}°F</p> | ||
| <p className='average-temp-display'>Low: {getHighLow(cityData.temperature).low}°F</p> | ||
| </div> | ||
| <div className='spark-box'> | ||
| <h3 className='pressure-title'>Pressure</h3> | ||
| <Sparklines data={cityData.pressure} height={40}> | ||
| <SparklinesLine color='green' /> | ||
| <SparklinesReferenceLine type='avg' /> | ||
| </Sparklines> | ||
| <p className='average-pressure-display'> | ||
| Average 5-day Pressure: {averageTemps(cityData.pressure)} hPa | ||
| </p> | ||
| </div> | ||
| <div className='spark-box'> | ||
| <h3 className='humidity-title'>Humidity</h3> | ||
| <div className='sparkline-box'> | ||
| <Sparklines data={cityData.humidity} height={40}> | ||
| <SparklinesLine color='purple' /> | ||
| <SparklinesReferenceLine type='avg' /> | ||
| </Sparklines> | ||
| </div> | ||
| <p className='average-humidity-display'>Average: {averageTemps(cityData.humidity)}%</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: use names that are less vague - instead of e use event