Skip to content
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

create button and add the style #22

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Sandra-Duarte
Copy link

@Sandra-Duarte Sandra-Duarte commented Feb 4, 2023

Contributors, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with ISSUE NUMBER | ISSUE TITLE
  • I have linked my PR to the paired issue with #123
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the acceptance criteria

Changelist

Briefly explain your PR.

Context

Link to ticket with fixes #123

Questions

Ask any questions you have for your reviewer.

@netlify
Copy link

netlify bot commented Feb 4, 2023

Deploy Preview for rainyplaytime failed.

Name Link
🔨 Latest commit a0b8c33
🔍 Latest deploy log https://app.netlify.com/sites/rainyplaytime/deploys/647cf3aed69b0800084df6ba

@SallyMcGrath SallyMcGrath mentioned this pull request Feb 4, 2023
2 tasks
Copy link
Member

@SallyMcGrath SallyMcGrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too much code for what we need. My suggestion is to only create a single buttons.scss partial and just create the style.

Then link the buttons css in global. There should be only 2 files in this PR when we merge it.

Copy link
Author

@Sandra-Duarte Sandra-Duarte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create the button in App.js
Add button. scss in theme,
create the button style,
import button in the global.scss

Copy link

@LucyMac LucyMac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @Sandra-Duarte
Please update your branch (that means merge 'master' into your branch so you get the latest changes from the master branch) and resolve the conflicts so we can merge (you can resolve them in VS Code to visualise the issues).

src/App.js Outdated
Comment on lines 15 to 16
<button> FIND WEATHER</button>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This button should live inside the Header component @Sandra-Duarte

@LucyMac LucyMac changed the base branch from master to main March 2, 2023 10:44
Copy link

@LucyMac LucyMac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've made some good progress Sandra! I've made a few comments for improvements below, but good work on the whole 🙌🏼

Comment on lines +30 to +31
<CurrentWeather weatherInfo={weatherInfo} />
<FutureWeather weatherInfo={weatherInfo} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to pass ALL the data to both these components? It's always best to pass down just what a component needs.
In this case: CurrentWeather only needs one item from the array of weather in the API response. And FutureWeather needs 7 items (according to the design which is our source of truth here), so you need to make a small array of 7 items here, and pass down that small array to FutureWeather instead of the whole thing

Comment on lines 14 to 25
{
infWeather < 300 ? <img src={Storm} />
: infWeather >= 300 && infWeather <= 499 ? <img
src={Drizzle} /> : infWeather >= 500 && infWeather <= 599 ? <img
src={Rain} /> : infWeather >= 600 && infWeather <= 699 ? <img
src={Snow} /> : infWeather >= 700 && infWeather <= 799 ? <img
src={Fog} /> : infWeather === 800 ? <img
src={Clear} /> : infWeather === 801 ? <img
src={PartlyCloudy} /> : infWeather >= 802 && infWeather <= 805 ? <img
src={MostlyCloudy} /> :
<p>No Image Found</p>
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good logic here. As a side note on best practices, when there is a complex conditional statement like this one, it's best to move it outside the component's JSX because it makes it hard to read. You could move this to a function (inside the component but before the return) like for example:

const selectIconById = (id) => {
  // move your logic here and return either the icon name or 
  // the whole <img /> element with the correct icon in the src
}

Comment on lines +12 to +24
// const WeatherIcons = (infWeather)=>{
// return (
// infWeather < 300 ? <img src={Storm} />
// : infWeather >= 300 && infWeather <= 499 ? <img
// src={Drizzle} /> : infWeather >= 500 && infWeather <= 599 ? <img
// src={Rain} /> : infWeather >= 600 && infWeather <= 699 ? <img
// src={Snow} /> : infWeather >= 700 && infWeather <= 799 ? <img
// src={Fog} /> : infWeather === 800 ? <img
// src={Clear} /> : infWeather === 801 ? <img
// src={PartlyCloudy} /> : infWeather >= 802 && infWeather <= 805 ? <img
// src={MostlyCloudy} /> :
// <p>No Image Found</p>
// )}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best not to commit commented out code like this. I would delete it.

Especially because your WeatherImage component is fulfilling this function on line 29 :)

Comment on lines +6 to +10
const CurrentWeather = ({weatherInfo}) => {

if(weatherInfo.length > 0){

const infWeather = weatherInfo[0].weather[0].id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in my comment in App.js, this component should only receive weatherInfo[0] here, so then you will be able to extract what you need from that object directly in here

<div className="weather-container" style={{display: "flex", justifyContent:"center"}}>
{
weatherInfo.length > 0 ?
weatherInfo.slice(1, 7).map((item) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you're slicing the data here 👍🏼
As I said in my comment in App.js, you could be slicing your data up there in the parent, and only passing down the sub-array to FutureWeather

Comment on lines +21 to +27
// axios request
// try {

// }
// catch(err){

// }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid committing comments like this, unless they are particularly useful to the other developers working on the project with you.

Comment on lines +3 to +7
appearance: none;
background-color: var(--theme-color--button);
color: var(--theme-color--ink);
padding: var(--theme-spacing--2);
text-transform: uppercase;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try and make this button looks as much like the design provided as possible. Replicating designs into CSS is a key front-end developer skill.

@LucyMac LucyMac added the duplicate This issue or pull request already exists label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants