Skip to content

Commit 6f0848e

Browse files
authored
Merge pull request #34 from a-company-jp/feature/all-change
色々修正した
2 parents 4dce473 + e46a29e commit 6f0848e

File tree

22 files changed

+427
-380
lines changed

22 files changed

+427
-380
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@reduxjs/toolkit": "^2.2.3",
67
"@testing-library/jest-dom": "^5.17.0",
78
"@testing-library/react": "^13.4.0",
89
"@testing-library/user-event": "^13.5.0",
@@ -15,9 +16,12 @@
1516
"copy-image-clipboard": "^2.1.2",
1617
"react": "^18.2.0",
1718
"react-dom": "^18.2.0",
19+
"react-dropzone": "^14.2.3",
1820
"react-hook-form": "^7.51.3",
1921
"react-icons": "^5.0.1",
22+
"react-redux": "^9.1.1",
2023
"react-scripts": "5.0.1",
24+
"redux-thunk": "^3.1.0",
2125
"typescript": "^4.9.5",
2226
"web-vitals": "^2.1.4"
2327
},

src/App.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ import "./App.css";
22
import "./font/LINESeedJP_OTF_Rg.woff";
33
import "./font/LINESeedJP_OTF_Bd.woff";
44
import "./font/LINESeedJP_OTF_Th.woff";
5-
import CardList from "./components/CardList";
6-
import { UIProvider } from "@yamada-ui/react";
7-
import { useState } from "react";
8-
import useLGTMFetch from "./hooks/useLGTMFetch";
9-
import Sidebar from "./components/Sidebar";
5+
import CardList from "./components/features/CardList";
6+
import { Loading, UIProvider } from "@yamada-ui/react";
7+
import { useEffect } from "react";
8+
import Sidebar from "./components/features/Sidebar";
9+
import { useDispatch, useSelector } from "react-redux";
10+
import { getLgtms } from "./store/lgtmListSlice";
11+
import { AppDispatch, RootState } from "./store";
1012

1113
function App() {
12-
const [uploaded, setUploaded] = useState(false);
13-
const [activePage] = useState(1);
14-
const { LGTMUrls } = useLGTMFetch(activePage, uploaded, setUploaded);
14+
const { lgtms, loading } = useSelector((state: RootState) => state.lgtms);
15+
const dispatch = useDispatch<AppDispatch>();
16+
useEffect(() => {
17+
dispatch(getLgtms());
18+
}, [dispatch]);
1519

1620
const styles = {
1721
container: "grid grid-cols-7 h-screen w-screen",
@@ -22,13 +26,15 @@ function App() {
2226
return (
2327
<UIProvider>
2428
<div className={styles.container} style={{ fontFamily: "regular" }}>
25-
<Sidebar
26-
className="col-span-2"
27-
uploaded={uploaded}
28-
setUploaded={setUploaded}
29-
/>
29+
<Sidebar className="col-span-2" />
3030
<div className={styles.content}>
31-
<CardList {...LGTMUrls} />
31+
{loading ? (
32+
<div className="h-full flex justify-center items-center">
33+
<Loading size="3xl" />
34+
</div>
35+
) : (
36+
<CardList lgtms={lgtms} />
37+
)}
3238
</div>
3339
</div>
3440
</UIProvider>

src/components/.keep

Whitespace-only changes.

src/components/CardList/index.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/components/InputImage/index.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/components/Pagination/index.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/components/SendImageButton/index.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.
File renamed without changes.

src/components/Card/index.tsx renamed to src/components/features/Card/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import React, { useState } from "react";
22
import { FaRegCheckCircle, FaRegCopy } from "react-icons/fa";
3-
import { imageCopy } from "../../utils";
3+
import { imageCopy } from "../../../utils";
4+
import { Lgtm } from "../../../types/lgtm";
45

5-
export type CardProps = {
6-
imageUrl: string;
7-
};
6+
interface Props {
7+
lgtm: Lgtm;
8+
}
89

9-
const Card = ({ imageUrl }: CardProps) => {
10+
const Card = ({ lgtm }: Props) => {
1011
const [isCopying, setIsCopying] = useState(false);
1112

1213
const handleCopyClick = async () => {
13-
await imageCopy(imageUrl);
14+
await imageCopy(lgtm.url);
1415
setIsCopying(true);
1516
setTimeout(() => {
1617
setIsCopying(false);
@@ -39,7 +40,7 @@ const Card = ({ imageUrl }: CardProps) => {
3940
>
4041
<img
4142
alt="LGTMの画像"
42-
src={imageUrl}
43+
src={lgtm.url}
4344
className="max-h-48 max-w-100 transition-opacity group-hover:opacity-30"
4445
/>
4546
{isCopying ? (
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react";
2+
import Card from "../Card";
3+
import { Lgtm } from "../../../types/lgtm";
4+
5+
interface Props {
6+
lgtms: Lgtm[];
7+
}
8+
9+
function CardList({ lgtms }: Props) {
10+
const styles = {
11+
container: "flex flex-col",
12+
grid: "grid grid-cols-3 gap-4",
13+
};
14+
15+
return (
16+
<div className={styles.container}>
17+
<div className={`${styles.grid} my-4`}>
18+
{lgtms.map((lgtm) => (
19+
<Card key={lgtm.id} lgtm={lgtm} />
20+
))}
21+
</div>
22+
</div>
23+
);
24+
}
25+
26+
export default CardList;

0 commit comments

Comments
 (0)