├── src
├── assets
│ ├── css
│ │ ├── post.css
│ │ ├── 404.css
│ │ ├── blog.css
│ │ ├── componentes
│ │ │ ├── button.css
│ │ │ ├── table.css
│ │ │ ├── card.css
│ │ │ ├── inputs.css
│ │ │ └── header.css
│ │ └── base
│ │ │ ├── _variables.css
│ │ │ ├── base.css
│ │ │ └── _reset.css
│ └── img
│ │ ├── checkmark.svg
│ │ ├── menu.svg
│ │ ├── doguito.svg
│ │ ├── doguito404.svg
│ │ └── doguitoadm.svg
├── setupTests.js
├── api
│ └── api.js
├── App.test.js
├── pages
│ ├── SubCategoria.jsx
│ ├── Home.jsx
│ ├── Page404.jsx
│ ├── Sobre.jsx
│ ├── Post.jsx
│ └── Categoria.jsx
├── index.css
├── reportWebVitals.js
├── index.js
├── App.css
├── App.js
├── components
│ ├── ListCategories.jsx
│ ├── ListPosts.jsx
│ └── Header.jsx
└── logo.svg
├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
├── index.html
└── doguito.svg
├── .gitignore
├── package.json
├── README.md
└── db.json
/src/assets/css/post.css:
--------------------------------------------------------------------------------
1 | .post {
2 | margin-top: 1.25rem;
3 | }
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alura-es-cursos/1845-react-router-v2/master/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alura-es-cursos/1845-react-router-v2/master/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alura-es-cursos/1845-react-router-v2/master/public/logo512.png
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/src/api/api.js:
--------------------------------------------------------------------------------
1 | import axios from "axios"
2 |
3 | export const api = axios.create({
4 | baseURL: "http://localhost:5000"
5 | })
6 |
7 | export const buscar = async (url, setData) => {
8 | const respuesta = await api.get(url)
9 | setData(respuesta.data)
10 | }
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/src/assets/css/404.css:
--------------------------------------------------------------------------------
1 | .dog-image {
2 | width: 100%;
3 | max-width: 25rem;
4 | margin-top: 1.25rem;
5 | margin-bottom: 2rem;
6 | }
7 |
8 | .notfound-text {
9 | font-size: var(--font-size-not-found);
10 | margin-bottom: 1rem;
11 | }
12 |
13 | .notfound-link {
14 | color: var(--primary-color);
15 | }
16 |
--------------------------------------------------------------------------------
/src/pages/SubCategoria.jsx:
--------------------------------------------------------------------------------
1 | import { useParams } from "react-router-dom"
2 | import ListPosts from "../components/ListPosts"
3 |
4 | const SubCategoria = () => {
5 | const { subcategoria } = useParams()
6 | return (
7 |
8 | )
9 | }
10 |
11 | export default SubCategoria
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/src/pages/Home.jsx:
--------------------------------------------------------------------------------
1 | import ListPosts from "../components/ListPosts"
2 | import ListCategories from "../components/ListCategories"
3 | const Home = () => {
4 | return (
5 |
6 |
7 |
Pet noticias
8 |
9 |
10 |
11 |
12 | )
13 | }
14 |
15 | export default Home
16 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/pages/Page404.jsx:
--------------------------------------------------------------------------------
1 | import image from "../assets/img/doguito404.svg"
2 | import '../assets/css/404.css'
3 |
4 | const Page404 = () => {
5 | return (
6 |
7 |
8 | Esta página no existe
9 |
10 | )
11 | }
12 |
13 | export default Page404
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/src/assets/img/checkmark.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/pages/Sobre.jsx:
--------------------------------------------------------------------------------
1 | const Sobre = () => {
2 | return (
3 |
4 |
5 |
Sobre Doguito
6 |
7 |
8 |
9 | El blog de PetShop fue creado para ayudarte con las preguntas más comunes sobre tu mascota.
10 |
11 |
12 |
13 | )
14 | }
15 |
16 | export default Sobre
17 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | const root = ReactDOM.createRoot(document.getElementById('root'));
8 | root.render(
9 |
10 |
11 |
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/assets/img/menu.svg:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/src/assets/css/blog.css:
--------------------------------------------------------------------------------
1 | .category-list {
2 | width: 100%;
3 | box-sizing: border-box;
4 | justify-content: space-evenly;
5 | margin-bottom: 2rem;
6 | }
7 |
8 | .category-list__category {
9 | font-weight: var(--font-size-categories);
10 | background-color: var(--contrast-light-color);
11 | border-radius: 3rem;
12 | padding: 1rem;
13 | }
14 |
15 | .category-list__category--bienestar {
16 | color: var(--contrast-light-color);
17 | background-color: var(--cor-categoria-bienestar);
18 | }
19 |
20 | .category-list__category--comportamiento {
21 | color: var(--contrast-light-color);
22 | background-color: var(--cor-categoria-comportamiento);
23 | }
24 |
--------------------------------------------------------------------------------
/src/assets/css/componentes/button.css:
--------------------------------------------------------------------------------
1 | .button {
2 | display: block;
3 | background-color: var(--primary-color);
4 | border-radius: 7px;
5 | width: 100%;
6 | margin-top: 1rem;
7 | max-width: 20rem;
8 | padding: 1.125rem;
9 | box-sizing: border-box;
10 | color: var(--contrast-light-color);
11 | font-size: var(--font-size-button);
12 | align-self: center;
13 | text-align: center;
14 | }
15 |
16 | .simple-button {
17 | border: none;
18 | background-color: unset;
19 | }
20 |
21 | .button--add {
22 | color: var(--primary-color);
23 | }
24 |
25 | .button--delete {
26 | color: var(--danger-color);
27 | }
28 |
29 | .button--edit {
30 | color: var(--success-color);
31 | }
32 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import './assets/css/base/base.css';
2 | import './assets/css/componentes/card.css'
3 | import Home from "./pages/Home"
4 | import Sobre from "./pages/Sobre"
5 | import Page404 from './pages/Page404';
6 | import Header from './components/Header';
7 | import Post from './pages/Post';
8 | import Categoria from './pages/Categoria';
9 |
10 | import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
11 |
12 | function App() {
13 |
14 | return (
15 |
16 |
17 |
18 | } />
19 | } />
20 | } />
21 | } />
22 | } />
23 |
24 |
25 | );
26 | }
27 |
28 | export default App;
--------------------------------------------------------------------------------
/src/pages/Post.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react"
2 | import "../assets/css/componentes/card.css"
3 | import { useParams, useNavigate } from "react-router-dom"
4 | import { buscar } from "../api/api"
5 |
6 | const Post = ({ url }) => {
7 |
8 | const [post, setPost] = useState({})
9 |
10 | const { id } = useParams()
11 |
12 | const navigate = useNavigate()
13 |
14 | useEffect(() => {
15 | buscar(`/posts/${id}`, setPost).catch(() => {
16 | navigate("/not-found")
17 | })
18 | }, [id])
19 |
20 |
21 | return (
22 |
23 |
24 | {post.title}
25 | {post.body}
26 |
27 |
28 | )
29 | }
30 |
31 | export default Post
--------------------------------------------------------------------------------
/src/components/ListCategories.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 | import { Link } from "react-router-dom"
3 | import { buscar } from "../api/api";
4 | import "../assets/css/blog.css"
5 |
6 | const ListCategories = () => {
7 |
8 | const [categories, setCategories] = useState([]);
9 |
10 | useEffect(() => {
11 | buscar(`/categorias`, setCategories)
12 | }, [])
13 |
14 | return (
15 |
16 | {
17 | categories.map(category => (
18 |
19 | -
20 | {category.nombre}
21 |
22 |
23 | ))
24 | }
25 |
26 | )
27 | }
28 |
29 | export default ListCategories;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1845-react-router-v2",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "axios": "^1.3.4",
10 | "json-server": "^0.17.2",
11 | "react": "^18.2.0",
12 | "react-dom": "^18.2.0",
13 | "react-router-dom": "^6.9.0",
14 | "react-scripts": "5.0.1",
15 | "web-vitals": "^2.1.4"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "test": "react-scripts test",
21 | "eject": "react-scripts eject"
22 | },
23 | "eslintConfig": {
24 | "extends": [
25 | "react-app",
26 | "react-app/jest"
27 | ]
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/components/ListPosts.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from "react"
2 | import "../assets/css/componentes/card.css"
3 | import { buscar } from "../api/api"
4 | import { Link } from "react-router-dom"
5 |
6 | const ListPosts = ({ url }) => {
7 | const [posts, setPosts] = useState([])
8 |
9 | useEffect(() => {
10 | buscar(url, setPosts)
11 | }, [url])
12 |
13 | return (
14 |
15 | {
16 | posts.map(post => {
17 | const { id, title, metadescription, categoria } = post;
18 | return
19 |
20 |
21 | {title}
22 |
23 | {metadescription}
24 |
25 |
26 | })
27 | }
28 |
29 | )
30 | }
31 |
32 | export default ListPosts
--------------------------------------------------------------------------------
/src/assets/css/base/_variables.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --font-family-body: "Montserrat", sans-serif;
3 | --font-family-logo: "Pacifico", cursive;
4 | --font-family-title-page: "Pacifico", cursive;
5 |
6 | --font-input: 300;
7 | --font-card: 500;
8 | --font-size-categories: 500;
9 | --font-size-menu-header-item: 500;
10 |
11 | --font-logo: 1.75rem;
12 | --font-size-card-title: 1.75rem;
13 |
14 | --font-size-card-post-title: 1.375rem;
15 | --font-size-input-label: 1.25rem;
16 |
17 | --font-size-button: 1.375rem;
18 | --font-size-form-fieldset: 1.375rem;
19 |
20 | --font-table-header: 1.375rem;
21 | --font-size-title-page: 1.75rem;
22 | --font-size-menu-header-item: 1.2rem;
23 |
24 | --font-size-not-found: 1.25rem;
25 |
26 | --primary-color: #0071ea;
27 | --secundary-color: #d6eaff;
28 | --contrast-dark-color: #4d4d4d;
29 | --contrast-light-color: #fff;
30 | --cor-divisao: #dadada;
31 | --danger-color: #df2525;
32 | --success-color: #46bb42;
33 |
34 | --cor-categoria-bienestar: #ff4949;
35 | --cor-categoria-comportamiento: #368dff;
36 |
37 | --shadow: 0 5px 10px #55a6ff38;
38 | }
39 |
40 | @media (min-width: 800px) {
41 | :root {
42 | --font-logo: 2.5rem;
43 | --font-size-menu-header-item: 1rem;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/assets/css/componentes/table.css:
--------------------------------------------------------------------------------
1 | .table {
2 | margin-top: 2.25rem;
3 | width: 100%;
4 | background-color: var(--contrast-light-color);
5 | border-radius: 10px;
6 | box-shadow: var(--shadow);
7 | border-collapse: initial;
8 | text-align: left;
9 | }
10 |
11 | .table td:first-of-type,
12 | .table th:first-of-type {
13 | padding-left: 1.75rem;
14 | }
15 |
16 | .table td:last-of-type,
17 | .table th:last-of-type {
18 | padding-right: 1.75rem;
19 | }
20 |
21 | .table thead {
22 | font-size: var(--font-table-header);
23 | }
24 |
25 | .table th {
26 | padding-top: 1.75rem;
27 | padding-bottom: 1.75rem;
28 | border-bottom: 1px solid var(--secundary-color);
29 | }
30 |
31 | .table td {
32 | padding-top: 1rem;
33 | padding-bottom: 1rem;
34 | }
35 |
36 | .table__align--right {
37 | text-align: right;
38 | }
39 |
40 | .table__column--p {
41 | width: 20%;
42 | }
43 |
44 | .table__column--m {
45 | width: 25%;
46 | }
47 |
48 | .table__column--g {
49 | width: 50%;
50 | }
51 |
52 | .table tr:last-of-type td {
53 | padding-bottom: 1.75rem;
54 | }
55 |
56 | .table__botons-control {
57 | display: flex;
58 | align-items: center;
59 | justify-content: flex-end;
60 | }
61 |
62 | .table__botons-control li:first-of-type {
63 | margin-right: 2.25rem;
64 | }
65 |
--------------------------------------------------------------------------------
/src/assets/css/base/base.css:
--------------------------------------------------------------------------------
1 | @import url(_reset.css);
2 | @import url(_variables.css);
3 | @import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500&family=Pacifico&display=swap");
4 |
5 | body {
6 | background-color: var(--secundary-color);
7 | color: var(--contrast-dark-color);
8 | font-family: var(--font-family-body);
9 | }
10 |
11 | .container {
12 | padding-right: 1rem;
13 | padding-left: 1rem;
14 | }
15 |
16 | .flex {
17 | display: flex;
18 | }
19 |
20 | .flex--center {
21 | align-items: center;
22 | justify-content: center;
23 | }
24 |
25 | .flex--column {
26 | flex-direction: column;
27 | }
28 |
29 | .title-page {
30 | display: flex;
31 | align-items: center;
32 | font-family: var(--font-family-title-page);
33 | font-size: var(--font-size-title-page);
34 | background-color: var(--contrast-light-color);
35 | border-radius: 10px;
36 | box-shadow: var(--shadow);
37 | height: 4.75rem;
38 | margin-top: 1.25rem;
39 | margin-bottom: 2rem;
40 | padding-left: 2rem;
41 | }
42 |
43 | @media (min-width: 800px) {
44 | .container {
45 | padding-right: 2.5rem;
46 | padding-left: 2.5rem;
47 | }
48 | }
49 |
50 | @media (min-width: 1200px) {
51 | .container {
52 | padding-left: calc((100vw - 900px) / 2);
53 | padding-right: calc((100vw - 900px) / 2);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/components/Header.jsx:
--------------------------------------------------------------------------------
1 | import image from "../assets/img/doguito.svg"
2 | import "../assets/css/componentes/header.css"
3 | import { Link } from "react-router-dom"
4 |
5 |
6 | const Header = () => {
7 | return (
8 |
9 |
10 |
11 |
12 |
13 |
14 |

15 |
Petshop
16 |
17 |
18 |
26 |
27 |
28 | )
29 | }
30 |
31 | export default Header
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/assets/css/componentes/card.css:
--------------------------------------------------------------------------------
1 | .card {
2 | background-color: var(--contrast-light-color);
3 | border-radius: 10px;
4 | box-shadow: var(--shadow);
5 | width: 100%;
6 | max-width: 45rem;
7 | padding: 1.75rem;
8 | box-sizing: border-box;
9 | margin-bottom: 1rem;
10 | }
11 |
12 | .title__card {
13 | font-size: var(--font-size-card-title);
14 | margin-bottom: 1rem;
15 | }
16 |
17 | .text__card {
18 | line-height: 1.2rem;
19 | }
20 |
21 | .post__card {
22 | background-color: var(--contrast-light-color);
23 | border-radius: 10px;
24 | box-shadow: var(--shadow);
25 | width: 100%;
26 | max-width: 25rem;
27 | padding: 1rem 2rem 2rem;
28 | box-sizing: border-box;
29 | margin-bottom: 2.25rem;
30 | border-top: 1rem solid;
31 | }
32 |
33 | .post-card__title {
34 | font-size: var(--font-size-card-post-title);
35 | font-weight: var(--font-card);
36 | margin-bottom: 1rem;
37 | }
38 |
39 | .post-card__meta {
40 | line-height: 1.3rem;
41 | }
42 |
43 | .post-card--bienestar {
44 | border-color: var(--cor-categoria-bienestar);
45 | }
46 |
47 | .post-card--comportamiento {
48 | border-color: var(--cor-categoria-comportamiento);
49 | }
50 |
51 | .posts {
52 | display: flex;
53 | flex-direction: column;
54 | align-items: center;
55 | }
56 |
57 | .post {
58 | margin-top: 25px;
59 | }
60 |
61 | @media (min-width: 900px) {
62 | .posts {
63 | align-items: stretch;
64 | flex-direction: row;
65 | flex-wrap: wrap;
66 | justify-content: space-evenly;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/assets/css/base/_reset.css:
--------------------------------------------------------------------------------
1 | html, body, div, span, applet, object, iframe,
2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
3 | a, abbr, acronym, address, big, cite, code,
4 | del, dfn, em, img, ins, kbd, q, s, samp,
5 | small, strike, strong, sub, sup, tt, var,
6 | b, u, i, center,
7 | dl, dt, dd, ol, ul, li,
8 | fieldset, form, label, legend,
9 | table, caption, tbody, tfoot, thead, tr, th, td,
10 | article, aside, canvas, details, embed,
11 | figure, figcaption, footer, header, hgroup,
12 | menu, nav, output, ruby, section, summary,
13 | time, mark, audio, video {
14 | margin: 0;
15 | padding: 0;
16 | border: 0;
17 | font-size: 100%;
18 | font: inherit;
19 | vertical-align: baseline;
20 | }
21 |
22 | article, aside, details, figcaption, figure,
23 | footer, header, hgroup, menu, nav, section {
24 | display: block;
25 | }
26 | body {
27 | line-height: 1;
28 | }
29 | ol, ul {
30 | list-style: none;
31 | }
32 | blockquote, q {
33 | quotes: none;
34 | }
35 | blockquote:before, blockquote:after,
36 | q:before, q:after {
37 | content: '';
38 | content: none;
39 | }
40 | table {
41 | border-collapse: collapse;
42 | border-spacing: 0;
43 | }
44 |
45 | a {
46 | color: inherit;
47 | text-decoration: none;
48 | }
49 |
50 | img {
51 | width: inherit;
52 | }
53 |
54 | button {
55 | font-family: inherit;
56 | font-size: inherit;
57 | color: inherit;
58 | font-weight: inherit;
59 | padding: 0;
60 | border: none;
61 | background-color: unset;
62 | }
63 |
64 | input {
65 | border: none;
66 | color: inherit;
67 | font-size: inherit;
68 | font-weight: inherit;
69 | font-family: inherit;
70 | }
--------------------------------------------------------------------------------
/src/pages/Categoria.jsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 | import "../assets/css/blog.css"
3 | import { buscar } from '../api/api'
4 | import ListCategories from '../components/ListCategories'
5 | import ListPosts from '../components/ListPosts'
6 | import SubCategoria from './SubCategoria'
7 | import { useParams, Routes, Route, Link, useResolvedPath } from 'react-router-dom'
8 |
9 | const Categoria = () => {
10 | const [subcategorias, setSubcategorias] = useState([])
11 | const { id } = useParams()
12 |
13 | const url = useResolvedPath("").pathname
14 |
15 |
16 | useEffect(() => {
17 | buscar(`/categorias?id=${id}`, (response) => {
18 | setSubcategorias(response[0].subcategorias)
19 | })
20 | }, [id])
21 |
22 |
23 | return (
24 | <>
25 |
26 |
Pet Noticias
27 |
28 |
29 |
30 | {
31 | subcategorias.map(subcategoria => (
32 | -
33 |
34 | {subcategoria}
35 |
36 |
37 | ))
38 | }
39 |
40 |
41 | } />
42 | } />
43 |
44 |
45 | >
46 | )
47 | }
48 |
49 | export default Categoria
50 |
51 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | Doguito
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/css/componentes/inputs.css:
--------------------------------------------------------------------------------
1 | .form {
2 | margin-top: 2rem;
3 | }
4 |
5 | .form__label {
6 | font-size: var(--font-size-form-fieldset);
7 |
8 | margin-bottom: 1rem;
9 | }
10 |
11 | .input-container {
12 | font-weight: var(--font-input);
13 | position: relative;
14 | margin-bottom: 1rem;
15 | display: flex;
16 | flex-direction: column;
17 | justify-content: flex-end;
18 | box-sizing: border-box;
19 | }
20 |
21 | .input {
22 | box-sizing: border-box;
23 | border-bottom: 1px solid var(--secundary-color);
24 | padding: 1.375rem 0.5rem 0.5rem;
25 | height: 3.25rem;
26 | width: 100%;
27 | }
28 |
29 | .input::placeholder {
30 | visibility: hidden;
31 | color: #00000000;
32 | }
33 |
34 | .input:focus {
35 | outline: none;
36 | }
37 |
38 | .input-label {
39 | position: absolute;
40 | top: 1.375rem;
41 | left: 0.5rem;
42 | font-size: var(--font-size-input-label);
43 |
44 | transition: all 0.25s;
45 | }
46 |
47 | .input:not(:placeholder-shown) + .input-label,
48 | .input:focus + .input-label {
49 | font-size: 0.875rem;
50 | top: 0.25rem;
51 | transition: all 0.25s;
52 | }
53 |
54 | .input-container--invalid {
55 | margin-bottom: 0.5rem;
56 | }
57 |
58 | .input-container--invalid .input {
59 | border: 1px solid var(--danger-color);
60 | border-radius: 7px;
61 | }
62 |
63 | .input-container--invalid .input-label {
64 | color: var(--danger-color);
65 | }
66 |
67 | .input-mensagem-erro {
68 | display: none;
69 | }
70 |
71 | .input-container--invalid .input-mensagem-erro {
72 | color: var(--danger-color);
73 | display: block;
74 | margin-top: 0.5rem;
75 | padding-left: 0.5rem;
76 | }
77 |
78 | .textarea {
79 | box-sizing: border-box;
80 | border: 1px solid var(--secundary-color);
81 | padding: 0.5rem;
82 | border-radius: 7px;
83 | width: 100%;
84 | min-height: 3rem;
85 | }
86 |
87 | .textarea-container {
88 | position: relative;
89 | margin-top: 2rem;
90 | margin-bottom: 1rem;
91 | font-weight: var(--font-input);
92 | }
93 |
94 | .textarea::placeholder {
95 | visibility: hidden;
96 | }
97 |
98 | .textarea:focus {
99 | outline: none;
100 | }
101 |
102 | .textarea-label {
103 | position: absolute;
104 | top: 0.5rem;
105 | left: 0.5rem;
106 | font-size: var(--font-size-input-label);
107 | transition: all 0.25s;
108 | }
109 |
110 | .textarea:not(:placeholder-shown) + .textarea-label,
111 | .textarea:focus + .textarea-label {
112 | font-size: 0.875rem;
113 | top: -1.25rem;
114 | transition: all 0.25s;
115 | }
116 |
117 | .textarea-container--invalid {
118 | margin-bottom: 0.5rem;
119 | }
120 |
121 | .textarea-container--invalid .textarea {
122 | border: 1px solid var(--danger-color);
123 | }
124 |
125 | .textarea-container--invalid .textarea-label {
126 | color: var(--danger-color);
127 | }
128 |
129 | .textarea-mensagem-erro {
130 | display: none;
131 | }
132 |
133 | .textarea-container--invalid .textarea-mensagem-erro {
134 | display: block;
135 | color: var(--danger-color);
136 | margin-top: 0.5rem;
137 | padding-left: 0.5rem;
138 | }
139 |
--------------------------------------------------------------------------------
/public/doguito.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/img/doguito.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/img/doguito404.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/css/componentes/header.css:
--------------------------------------------------------------------------------
1 | .header {
2 | background-color: var(--contrast-light-color);
3 | border-radius: 0 0 10px 10px;
4 | box-shadow: var(--shadow);
5 | display: grid;
6 | grid-template-columns: 1fr 1fr 1fr;
7 | align-items: center;
8 | height: 4.75rem;
9 | }
10 |
11 | .menu-hamburguer {
12 | width: 1.5rem;
13 | height: 0.75rem;
14 | transition: 0.2s;
15 | }
16 |
17 | .menu-hamburguer--active .menu-hamburguer__icon {
18 | transform: rotate(90deg);
19 | transition: 0.2s;
20 | }
21 |
22 | .menu-hamburguer__icon {
23 | display: block;
24 | width: 100%;
25 | height: 100%;
26 | background-image: url(../../img/menu.svg);
27 | background-size: contain;
28 | }
29 |
30 | .header__logo {
31 | width: 3rem;
32 | }
33 |
34 | .header__title {
35 | font-family: var(--font-family-logo);
36 | font-size: var(--font-logo);
37 | margin-left: 0.5rem;
38 | }
39 |
40 | .menu-header-background {
41 | background-color: #00000020;
42 | position: fixed;
43 | top: 0;
44 | left: -100vw;
45 | width: 100vw;
46 | height: 100vh;
47 | }
48 |
49 | .menu-header {
50 | position: fixed;
51 | left: -100vw;
52 | top: 0;
53 | background-color: var(--contrast-light-color);
54 | width: 70vw;
55 | height: 100vh;
56 | box-sizing: border-box;
57 | font-size: var(--font-size-menu-header-item);
58 | font-weight: var(--font-menu-header-item);
59 | z-index: 10;
60 | transition: 0.25s;
61 | }
62 |
63 | .menu-header__fechar {
64 | position: absolute;
65 | right: -2.5rem;
66 | top: 0.5rem;
67 | color: var(--contrast-light-color);
68 | padding: 1rem;
69 | box-sizing: border-box;
70 | border-radius: 50%;
71 | background-color: var(--primary-color);
72 | }
73 |
74 | .menu-header__fechar::before {
75 | content: "X";
76 | position: absolute;
77 | left: 50%;
78 | top: 50%;
79 | transform: translate(-50%, -50%);
80 | }
81 |
82 | .menu-item {
83 | display: block;
84 | padding-top: 1.5rem;
85 | padding-left: 1rem;
86 | padding-bottom: 1.5rem;
87 | border-bottom: 1px solid var(--cor-divisao);
88 | }
89 |
90 | .menu-item--entrar {
91 | background-color: var(--primary-color);
92 | color: var(--contrast-light-color);
93 | border: none;
94 | }
95 |
96 | .menu-header--ativo {
97 | left: 0;
98 | top: 0;
99 | transition: 0.25s;
100 | }
101 |
102 | .menu-header--ativo + .menu-header-background {
103 | left: 0;
104 | }
105 |
106 | @media (min-width: 900px) {
107 | .header {
108 | grid-template-areas: "menu logo .";
109 | height: 6.75rem;
110 | }
111 |
112 | .header-container {
113 | grid-area: logo;
114 | }
115 |
116 | .menu-hamburguer {
117 | display: none;
118 | }
119 |
120 | .menu-header {
121 | justify-self: flex-start;
122 | position: static;
123 | width: fit-content;
124 | height: fit-content;
125 | grid-area: menu;
126 | }
127 |
128 | .menu-header__fechar {
129 | display: none;
130 | }
131 |
132 | .menu-header-background {
133 | display: none;
134 | }
135 |
136 | .menu-items {
137 | display: flex;
138 | align-items: center;
139 | }
140 |
141 | .menu-item {
142 | border: none;
143 | padding: 0;
144 | margin-right: 1rem;
145 | }
146 |
147 | .menu-item--entrar {
148 | border-radius: 2rem;
149 | padding: 1rem 1.5rem;
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/db.json:
--------------------------------------------------------------------------------
1 | {
2 | "categorias": [
3 | {
4 | "id": "bienestar",
5 | "nombre": "bienestar",
6 | "subcategorias": [
7 | "higiene",
8 | "salud"
9 | ]
10 | },
11 | {
12 | "id": "comportamiento",
13 | "nombre": "comportamiento",
14 | "subcategorias": [
15 | "entrenamiento",
16 | "educacion"
17 | ]
18 | }
19 | ],
20 | "posts": [
21 | {
22 | "id": 1,
23 | "title": "Baño en perros",
24 | "metadescription": "Utiliza las herramientas ideales para bañar a tu perro",
25 | "body": "La mayoría de los perros prefieren saltarse la hora del baño, pero el baño juega un papel importante en la salud del pelaje y la piel de su perro, ya que ayuda a mantenerla limpia y libre de suciedad y parásitos. Tener los productos adecuados puede ayudarlo a sentirse más cómodo.",
26 | "categoria": "bienestar",
27 | "subcategoria": "higiene"
28 | },
29 | {
30 | "id": 2,
31 | "title": "Tu cachorro merece un tapete higiénico",
32 | "metadescription": "El baño que tu cachorro merece",
33 | "body": "Los tapetes higiénicos son una innovación en el mercado de las mascotas, perfectas para que tu perro haga sus necesidades con comodidad y sin ensuciar la casa. Son productos desechables o lavables que garantizan la comodidad de tu mascota.",
34 | "categoria": "bienestar",
35 | "subcategoria": "higiene"
36 | },
37 | {
38 | "id": 3,
39 | "title": "¿Época de pulgas?",
40 | "metadescription": "Es necesario evitar que tus mascotas contraigan estos parásitos",
41 | "body": "No es la mordedura, sino la reacción alérgica a ella lo que hace que tu perro sienta comezón. Algunas mascotas son hipersensibles a las pulgas y pueden tener una reacción grave con solo un mordisco. Sin embargo, todas las mascotas experimentarán molestias por las picaduras de pulgas. Entonces, tan pronto como veas rasguños repetidos, sospeche de las pulgas.",
42 | "categoria": "bienestar",
43 | "subcategoria": "salud"
44 | },
45 | {
46 | "id": 4,
47 | "title": "¿Tu mascota está estresada?",
48 | "metadescription": "El cambio de rutina puede ser el mayor factor.",
49 | "body": "Talvez eres de las personas que le dan atención adicional, pero cuando tienes que ir a la oficina o a realizar alguna actividad lo dejas en tu casa, causandole esa falta de atención que le brindas constantemente, lo ideal es mimarlos en la medida cierta. Debido a la pandemia hemos estado más presentes en nuestro hogar lo cuál puede acostumbrar a tu mascota a estar más tiempo contigo.",
50 | "categoria": "comportamiento",
51 | "subcategoria": "educacion"
52 | },
53 | {
54 | "id": 5,
55 | "title": "¿Cómo entrenar a tu perro para que no tenga miedo?",
56 | "metadescription": "La socialización es un grande factor en este aprendizaje.",
57 | "body": "Solo se puede enseñar a un perro a dejar de tener miedo aumentando su confianza en sí mismo. Esto significa cambiar la forma en que reacciona su mente en determinadas situaciones y convertir las asociaciones negativas en positivas. Hacer esto requiere mucha paciencia y una serie de exposiciones controladas al evento u objeto temido, pero lo suficientemente lejos como para que el perro no se sienta ansioso.",
58 | "categoria": "comportamiento",
59 | "subcategoria": "educacion"
60 | },
61 | {
62 | "id": 6,
63 | "title": "¿Por qué los gatos ronroñean?",
64 | "metadescription": "El ronroneo es una señal de aviso.",
65 | "body": "Una cosa que los científicos saben con certeza es que la parte del cerebro del gato que controla las vocalizaciones está muy conectada con la parte del cerebro que controla las emociones del gato. Entonces, lo que el gato está “diciendo” es absolutamente un reflejo de como se siente.",
66 | "categoria": "comportamiento",
67 | "subcategoria": "entrenamiento"
68 | },
69 | {
70 | "id": 7,
71 | "title": "¿Cómo entrenar a tu gato?",
72 | "metadescription": "Si, tu puedes entrenar a tu gato y es mucho más fácil de lo que pensabas.",
73 | "body": "Puedes utilizar herramientas de entrenamiento para una amplia variedad de animales, un 'clicker' solo costará unos pocos dólares y te ayudará a dar un refuerzo positivo cuando aprendas a entrenar a un gato. (También puedes usar un bolígrafo normal con un botón de click; lo importante es tener un ruido distintivo). La mayoría de los entrenamientos para gatos implican darle a tu gato una golosina que le guste después de un click para marcar el comportamiento deseado.",
74 | "categoria": "comportamiento",
75 | "subcategoria": "entrenamiento"
76 | }
77 | ]
78 | }
--------------------------------------------------------------------------------
/src/assets/img/doguitoadm.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------