-
Notifications
You must be signed in to change notification settings - Fork 183
Miramita #8
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
Diegocf435
wants to merge
8
commits into
ed-roh:master
Choose a base branch
from
Diegocf435:miramita
base: master
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
Miramita #8
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4a6867
todo filter
Diegocf435 0a3ccbb
commiteando
Diegocf435 c996e27
commiteando
Diegocf435 3f9c64a
commit desde susbter
diegosubter 49b9574
Merge branch 'miramita' into master
Diegocf435 c2e08c0
Merge pull request #1 from Diegocf435/master
Diegocf435 d091373
que onda hermano
Diegocf435 9e3d9aa
ahora si o no
Diegocf435 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,21 @@ | ||
| .card{ | ||
| display:flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
|
|
||
| } | ||
| .card__image-container{ | ||
| width:100%; | ||
| } | ||
| .card__content-container img{ | ||
| width:100%; | ||
| object-fit: cover; | ||
| } | ||
| .card__content-container{ | ||
| padding:0 1rem; | ||
| display:flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| width:100%; | ||
| } |
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,18 @@ | ||
| import React from 'react' | ||
| import './MyItem.css' | ||
| const MyItem = ({item}) => { | ||
| return ( | ||
| <div className='card'> | ||
| <div className='card__image-container'> | ||
| <img src={item.image} alt="character" /> | ||
| </div> | ||
| <div className='card__content-container'> | ||
| <p>{item.name}</p> | ||
| <p style={{color:item.status === 'Alive'? 'green':item.status === 'Dead'? 'red':'black'}}>{item.status}</p> | ||
| </div> | ||
|
|
||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default MyItem |
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,28 @@ | ||
| .products{ | ||
| margin-top: 60px; | ||
| width:100%; | ||
| min-height: calc(100vh - 60px); | ||
| padding:1.5rem; | ||
| } | ||
| .products-container{ | ||
| display:grid; | ||
| grid-template-columns: 20% 70%; | ||
| row-gap: 10%; | ||
| width:100%; | ||
| height:100%; | ||
| } | ||
| .filter-container{ | ||
| padding:1.5rem; | ||
| display:flex; | ||
| flex-direction: column; | ||
| } | ||
| .products-wrapper{ | ||
| display:grid; | ||
| grid-template-columns: repeat(auto-fill,minmax(15rem,1fr)); | ||
| place-items: center; | ||
| padding:1.5rem; | ||
| gap:1.5rem; | ||
| border:1px solid #eee; | ||
| border-radius: 0.5rem; | ||
| box-shadow: 1px 1px -2px 1px; | ||
| } |
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,93 @@ | ||
| import React, { useEffect, useState } from 'react' | ||
| import './Products.css' | ||
| import { UseFetch } from '../../utils/UseFetch' | ||
| import MyItem from '../Item/MyItem'; | ||
| import { Checkbox, FormControlLabel, FormGroup, Typography } from '@mui/material'; | ||
|
|
||
| const Products = () => { | ||
| const [rickAndMortyData, setRickAndMortyData] = useState([]); | ||
| const urlRickAndMorty = 'https://rickandmortyapi.com/api/character' | ||
| const [error, setError] = useState(''); | ||
| const [loading, setLoading] = useState(false) | ||
| const [aliveChecked, setAliveChecked] = useState(true); | ||
| const [deadChecked, setDeadChecked] = useState(true); | ||
| const [unknownChecked, setUnknownChecked] = useState(true); | ||
| const [filtedData, setFilteredData] = useState([]); | ||
| const fetchingData = async() =>{ | ||
| try{ | ||
| setLoading(true); | ||
| const result = await UseFetch(`${urlRickAndMorty}`); | ||
| setRickAndMortyData(result.results); | ||
| setFilteredData(result.results); | ||
| setLoading(false); | ||
| }catch(error){ | ||
| setError(error); | ||
| setLoading(false); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| useEffect(() =>{ | ||
| fetchingData(); | ||
| },[]) | ||
|
|
||
| const handleAliveCheckboxChange = (event) => { | ||
| setAliveChecked(event.target.checked); | ||
|
|
||
| const filteringData = rickAndMortyData.filter(item => item.status === 'Alive'); | ||
| setFilteredData(filteringData); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| const handleDeadCheckboxChange = (event) => { | ||
| setDeadChecked(event.target.checked); | ||
| }; | ||
|
|
||
| const handleUnknownCheckboxChange = (event) => { | ||
| setUnknownChecked(event.target.checked); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| return ( | ||
| <div className='products'> | ||
| <div className='products-container'> | ||
| <div className='filter-container'> | ||
| <Typography variant="h2" color="initial">Filters</Typography> | ||
| <Typography variant="h4" color="initial">Statu</Typography> | ||
| <FormGroup> | ||
| <FormControlLabel | ||
| control={<Checkbox checked={aliveChecked} />} | ||
| label="Alive" | ||
| onChange={handleAliveCheckboxChange} | ||
| /> | ||
| <FormControlLabel | ||
| control={<Checkbox checked={deadChecked} />} | ||
| label="Dead" | ||
| onChange={handleDeadCheckboxChange} | ||
| /> | ||
| <FormControlLabel | ||
| control={<Checkbox checked={unknownChecked} />} | ||
| label="unknown" | ||
| onChange={handleUnknownCheckboxChange} | ||
| /> | ||
| </FormGroup> | ||
|
|
||
| </div> | ||
| <div className='products-wrapper'> | ||
| {loading?(<div>Loading...</div>):( | ||
|
|
||
| filtedData.map(item =>( | ||
| <MyItem key={item.key} item={item}/> | ||
| )) | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default Products |
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 |
|---|---|---|
|
|
@@ -10,5 +10,4 @@ body { | |
| } | ||
|
|
||
| .app { | ||
| margin: auto; | ||
| } | ||
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
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,5 @@ | ||
| export const UseFetch = async (url, option) =>{ | ||
| const result = await fetch(url); | ||
| const json = await result.json(); | ||
| return json; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Uh oh!
There was an error while loading. Please reload this page.