Skip to content

Commit

Permalink
買い物かごの中身を出力するコンテナを作成しよう:その1
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yoshiii committed Sep 12, 2022
1 parent c8048e1 commit a1721c2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
25 changes: 15 additions & 10 deletions index.html
@@ -1,13 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />

</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
3 changes: 2 additions & 1 deletion src/App.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
import CartContainer from "./components/CartContainer";
import Navbar from "./components/Navbar";

function App() {
Expand All @@ -7,7 +8,7 @@ function App() {
return (
<div className="App">
<Navbar />
Shopping Cart
<CartContainer />
</div>
);
}
Expand Down
23 changes: 23 additions & 0 deletions src/components/CartContainer.tsx
@@ -0,0 +1,23 @@
import { Box, Container, Typography } from "@mui/material";
import React from "react";
import { useAppSelector } from "../store";

const CartContainer = () => {
const { amount } = useAppSelector((store) => store.cart);
if (amount < 1) {
return (
<Container>
<Box sx={{ my: 14 }}>
<Typography variant="h2" gutterBottom>
Cart
</Typography>
<Typography variant="h6" gutterBottom>
何も入っていません。
</Typography>
</Box>
</Container>
);
}
};

export default CartContainer;

0 comments on commit a1721c2

Please sign in to comment.