Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18,389 changes: 18,389 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>MediaStream - Jose Valor</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
21 changes: 21 additions & 0 deletions src/components/Cards/CartCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './styles.css';
import MovieCard from "../MovieCard";

export default function CartCard({ movie, onIncrement, onDecrement }) {
return (
<li className="movies__cart-card">
<MovieCard movie={movie} />
<div className="movies__cart-card-quantity">
<button onClick={() => onDecrement(movie.id)}>
-
</button>
<span>
{movie.quantity}
</span>
<button onClick={() => onIncrement(movie.id)}>
+
</button>
</div>
</li>
);
}
34 changes: 34 additions & 0 deletions src/components/Cards/CartCard/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.movies__cart-card {
background-color: #333333;
margin-bottom: 1rem;
padding: .75em;
border-radius: .2em;
}

.movies__cart-card:last-child {
margin-bottom: 0;
}

.movies__cart-card ul li {
font-size: 1em;
line-height: 120%;
}

.movies__cart-card-quantity {
display: flex;
align-items: center;
margin-top: .5em;
}

.movies__cart-card span {
margin: 0 .5em;
}

.movies__cart-card button {
background-color: var(--ms-green);
border: none;
cursor: pointer;
font-size: .75em;
border-radius: .25em;
padding: .25em .5em;
}
13 changes: 13 additions & 0 deletions src/components/Cards/ListCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import './styles.css';
import MovieCard from '../MovieCard';

export default function ListCard({ movie, onAddToCart }) {
return (
<li className="movies__list-card">
<MovieCard movie={movie} />
<button onClick={() => onAddToCart(movie)}>
Add to cart
</button>
</li>
);
}
25 changes: 25 additions & 0 deletions src/components/Cards/ListCard/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.movies__list-card {
background-color: #333333;
margin-bottom: 1rem;
padding: .75em;
border-radius: .2em;
}

.movies__list-card:last-child {
margin-bottom: 0;
}

.movies__list-card ul li {
font-size: 1em;
line-height: 120%;
}

.movies__list-card button {
background-color: var(--ms-green);
border: none;
cursor: pointer;
font-size: .75em;
border-radius: .25em;
margin-top: .75em;
padding: .25em .5em;
}
9 changes: 9 additions & 0 deletions src/components/Cards/MovieCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function MovieCard({ movie }) {
return (
<ul>
<li> ID: {movie.id} </li>
<li> Name: {movie.name} </li>
<li> Price: ${movie.price} </li>
</ul>
);
}
17 changes: 17 additions & 0 deletions src/components/MoviesCart/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import CartCard from "../Cards/CartCard";
import "./styles.css";

export default function MoviesCart({ cart, onIncrement, onDecrement, getTotal }) {
return (
<div className="movies__cart">
<ul>
{cart.map(cartMovie => (
<CartCard key={cartMovie.id} movie={cartMovie} onDecrement={onDecrement} onIncrement={onIncrement} />
))}
</ul>
<div className="movies__cart-total">
<p>Total: ${getTotal()}</p>
</div>
</div>
);
}
11 changes: 11 additions & 0 deletions src/components/MoviesCart/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.movies__cart {
width: 24em;
background-color: #222222;
padding: 1em;
border-radius: .2em;
}

.movies__cart-total {
margin-top: 1em;
font-size: 1.25em;
}
13 changes: 13 additions & 0 deletions src/components/MoviesList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import './styles.css'
import ListCard from '../Cards/ListCard';

export default function MoviesList({ movies, onAddToCart }) {
return (
<div className="movies__list">
<ul>
{movies.map(movie => (
<ListCard key={movie.id} movie={movie} onAddToCart={onAddToCart} />))}
</ul>
</div>
);
}
7 changes: 7 additions & 0 deletions src/components/MoviesList/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.movies__list {
width: 24em;
background-color: #222222;
padding: 1em;
border-radius: .2em;
margin-right: 2em;
}
83 changes: 0 additions & 83 deletions src/components/pages/Exercise01/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,4 @@
display: flex;
align-items: center;
justify-content: center;
}

.movies__list, .movies__cart {
width: 24em;
}

.movies__list {
background-color: #222222;
padding: 1em;
border-radius: .2em;
margin-right: 2em;
}

.movies__list-card {
background-color: #333333;
margin-bottom: 1rem;
padding: .75em;
border-radius: .2em;
}

.movies__list-card:last-child {
margin-bottom: 0;
}

.movies__list-card ul li {
font-size: 1em;
line-height: 120%;
}

.movies__list-card button {
background-color: var(--ms-green);
border: none;
cursor: pointer;
font-size: .75em;
border-radius: .25em;
margin-top: .75em;
padding: .25em .5em;
}

.movies__cart {
background-color: #222222;
padding: 1em;
border-radius: .2em;
}

.movies__cart-card {
background-color: #333333;
margin-bottom: 1rem;
padding: .75em;
border-radius: .2em;
}

.movies__cart-card:last-child {
margin-bottom: 0;
}

.movies__cart-card ul li {
font-size: 1em;
line-height: 120%;
}

.movies__cart-card-quantity {
display: flex;
align-items: center;
margin-top: .5em;
}

.movies__cart-card span {
margin: 0 .5em;
}

.movies__cart-card button {
background-color: var(--ms-green);
border: none;
cursor: pointer;
font-size: .75em;
border-radius: .25em;
padding: .25em .5em;
}

.movies__cart-total {
margin-top: 1em;
font-size: 1.25em;
}
37 changes: 37 additions & 0 deletions src/components/pages/Exercise01/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const movies = [
{
id: 1,
name: 'Star Wars',
price: 20
},
{
id: 2,
name: 'Minions',
price: 25
},
{
id: 3,
name: 'Fast and Furious',
price: 10
},
{
id: 4,
name: 'The Lord of the Rings',
price: 5
}
];

export const discountRules = [
{
m: [3, 2],
discount: 0.25
},
{
m: [2, 4, 1],
discount: 0.5
},
{
m: [4, 2],
discount: 0.1
}
];
Loading