diff --git a/README.md b/README.md index da3ec2f..cb7e28b 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ You can add your own pets in [`/db.json`](https://github.com/vspedr/developets/b You can use the following format to add your pet -``` +```json { "pets": [ - ... + //... { "id": "", // generate a guid however you like "name": "", @@ -18,7 +18,6 @@ You can use the following format to add your pet "description": "", "img": "" } - ... ] } ``` diff --git a/db.json b/db.json index f6800a1..a4ce7b3 100644 --- a/db.json +++ b/db.json @@ -167,6 +167,14 @@ "type": "dog", "description": "Cute little dog.", "img": "https://i.imgur.com/XoOZNFV.jpeg" + }, + { + "id": "90dbeace-b820-4fa9-8903-3ff9e2b4f0f9", + "name": "LĂ­rio & Narciso", + "owner": "raphaelalmeidamartins", + "type": "cat", + "description": "My little fellas. They love to turn off my computer when I'm working", + "img": "https://ibb.co/FHJhSCD" } ] } diff --git a/src/App.css b/src/App.css index 6d18f1e..0e04eba 100644 --- a/src/App.css +++ b/src/App.css @@ -55,8 +55,12 @@ body { font-size: large; } +.App main { + padding: 20px 0 30px; +} + .App-content { - padding: 20px; + padding: 20px 0; } .App-pagination { @@ -67,3 +71,9 @@ body { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } + +@media only screen and (max-width: 340px) { + .App-title { + font-size: 2em; + } +} diff --git a/src/App.js b/src/App.js index 682eb61..13af54e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,15 +1,15 @@ +import parse from 'parse-link-header'; import React, { useEffect, useState } from 'react'; -import { usePage } from './hooks/use-page'; -import { Card, Container, Pagination } from 'semantic-ui-react'; +import { HashLoader } from 'react-spinners'; import 'semantic-ui-css/semantic.min.css'; -import parse from 'parse-link-header'; +import { Card, Container, Pagination } from 'semantic-ui-react'; import './App.css'; import { PetCard } from './components/PetCard'; import { PetHeader } from './components/PetHeader'; +import { PETS } from './constants'; +import { usePage } from './hooks/use-page'; import fetchPets from './services/pets'; import { cacheRequest } from './_sessionStorage'; -import { PETS } from './constants'; -import { HashLoader } from "react-spinners"; function App() { const LIMIT = 9; @@ -22,9 +22,13 @@ function App() { useEffect(() => { async function fetchData() { const config = { - params: { _page: page, _limit: LIMIT } + params: { _page: page, _limit: LIMIT }, }; - const result = await cacheRequest(PETS, config.params._page, fetchPets(config)); + const result = await cacheRequest( + PETS, + config.params._page, + fetchPets(config) + ); const parsedLink = parse(result.headers.link); setTotalPages(parsedLink.last._page); setPets(result.data); @@ -39,32 +43,33 @@ function App() { return (
- - { - loading ? + {loading ? ( + : -
-
- - {pets.map(pet => PetCard(pet))} - -
-
- -
-
- } + /> + ) : ( +
+ + + {pets.map((pet) => PetCard(pet))} + + + +
+ )}
); } diff --git a/src/components/PetCard.css b/src/components/PetCard.css index 1b9053f..ab1f5f7 100644 --- a/src/components/PetCard.css +++ b/src/components/PetCard.css @@ -1,6 +1,6 @@ .card-image { object-fit: cover; - width: 320px; + width: 100%; height: 320px; } @@ -8,17 +8,3 @@ .ui.cards > .card { width: 320px; } - -@media only screen and (max-width: 767px) { - .card-image { - object-fit: cover; - width: 240px; - height: 240px; - } -} - -@media only screen and (max-width: 767px) { - .ui.stackable.cards > .card { - width: 240px !important; - } -} \ No newline at end of file diff --git a/src/components/PetCard.js b/src/components/PetCard.js index 5ddc86f..2564530 100644 --- a/src/components/PetCard.js +++ b/src/components/PetCard.js @@ -3,7 +3,7 @@ import { Card, Icon, Image } from 'semantic-ui-react'; import placeholder from '../assets/img/paw.png'; import './PetCard.css'; -export const PetCard = pet => { +export const PetCard = (pet) => { const extra = ( @@ -14,11 +14,17 @@ export const PetCard = pet => { ); const image = ( - pet.img ? {pet.name} : {pet.name} + {pet.name} ); return ( { ); }; -document.addEventListener('DOMContentLoaded', function(event) { - document.querySelectorAll('img').forEach(function(img) { - img.onerror = function() { +document.addEventListener('DOMContentLoaded', () => { + const images = document.querySelectorAll('img'); + images.forEach((currImg) => { + currImg.onerror = () => { this.src = placeholder; }; }); diff --git a/src/components/PetHeader.js b/src/components/PetHeader.js index 25bb0c3..9f91348 100644 --- a/src/components/PetHeader.js +++ b/src/components/PetHeader.js @@ -2,14 +2,13 @@ import React from 'react'; import { Icon } from 'semantic-ui-react'; export const PetHeader = () => { - return (
- DeveloPets - +

DeveloPets

+

Introduce your animal buddies to your fellow developers - +