From 3321db8f9c549103ebae46bf025a3135208a2e3b Mon Sep 17 00:00:00 2001 From: realtradam Date: Fri, 17 May 2024 22:16:00 -0400 Subject: uploading images to games and also iframes for games --- app/javascript/components/Game.jsx | 23 +++++++++++++++++++++++ app/javascript/components/GameCard.jsx | 15 +++++++++++---- app/javascript/components/Games.jsx | 27 +++++++++++++++++++++++---- app/javascript/components/Home.jsx | 2 +- app/javascript/routes/index.jsx | 2 ++ 5 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 app/javascript/components/Game.jsx (limited to 'app/javascript') diff --git a/app/javascript/components/Game.jsx b/app/javascript/components/Game.jsx new file mode 100644 index 0000000..8b80b8e --- /dev/null +++ b/app/javascript/components/Game.jsx @@ -0,0 +1,23 @@ +import React, { useState, useEffect } from "react"; +import { useParams } from "react-router-dom"; +//import { Link } from "react-router-dom"; +import GameCard from "./GameCard"; +import Button from "./Button"; + +//} /> + +//export default () => ( +export default function Games () { + let { user, game } = useParams(); +//http://localhost:3000/api/v1/game/realtradam/orc-arena-of-time/index.html + return( + <> +
+
+
Orc: Arena of Time
+ +
+
+ + ); +}; diff --git a/app/javascript/components/GameCard.jsx b/app/javascript/components/GameCard.jsx index 6b79630..9cd815d 100644 --- a/app/javascript/components/GameCard.jsx +++ b/app/javascript/components/GameCard.jsx @@ -1,17 +1,24 @@ import React from "react"; //import { Link } from "react-router-dom"; -export default function GameCard ({ link = "./", width = "72" }) +//game = { +// card_img: "", +// char_img: "", +// title_img: "" +//} + +export default function GameCard ({ link = "./", width = "72", game = { card_img: "https://ggayane.github.io/css-experiments/cards/dark_rider-cover.jpg", char_img: "https://ggayane.github.io/css-experiments/cards/dark_rider-character.png", title_img: "https://ggayane.github.io/css-experiments/cards/dark_rider-title.png" } }) { + return ( <>
- +
- - + +
diff --git a/app/javascript/components/Games.jsx b/app/javascript/components/Games.jsx index 1862caa..f1545b8 100644 --- a/app/javascript/components/Games.jsx +++ b/app/javascript/components/Games.jsx @@ -1,12 +1,13 @@ import React, { useState, useEffect } from "react"; //import { Link } from "react-router-dom"; import GameCard from "./GameCard"; +import Button from "./Button"; //export default () => ( export default function Games () { const [games, setGames] = useState([]); useEffect(() => { - const url = "/api/v1/games/index"; + const url = "/api/v1/games"; fetch(url).then((response) => { if (response.ok) { return response.json(); @@ -14,8 +15,8 @@ export default function Games () { throw new Error("Network response was not ok."); }).then((response) => setGames(response)).catch(() => navigate("/")); }, []); - const allGames = games.map((games, index) => ( -
{ blog }
+ const allGames = games.map((game) => ( + )); var handleSubmit = (e) => { e.preventDefault() //stops submit from happening @@ -26,6 +27,9 @@ export default function Games () { { formData.append('game[game_files][]', form.game_files.files[i], form.game_files.files[i].value); } + formData.append('game[card_img]', form.card_img.files[0], form.card_img.value); + formData.append('game[char_img]', form.char_img.files[0], form.char_img.value); + formData.append('game[title_img]', form.title_img.files[0], form.title_img.value); for (var pair of formData.entries()) { console.log(pair[0] + ', ' + pair[1]) @@ -53,7 +57,22 @@ export default function Games () { - +
+ + +
+
+ + +
+
+ + +
+
+ }/> +
+ diff --git a/app/javascript/components/Home.jsx b/app/javascript/components/Home.jsx index 5f79834..863d81d 100644 --- a/app/javascript/components/Home.jsx +++ b/app/javascript/components/Home.jsx @@ -28,7 +28,7 @@ export default function Home () {
-

Debug!

+

Debug! Again

Ea optio vitae culpa voluptatem consectetur. Ab quisquam sed ipsum. Perspiciatis minus odit quas qui consequuntur dicta reiciendis a. Nihil minima sed aliquam.

diff --git a/app/javascript/routes/index.jsx b/app/javascript/routes/index.jsx index 6ab155f..1b778ef 100644 --- a/app/javascript/routes/index.jsx +++ b/app/javascript/routes/index.jsx @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; import Home from "../components/Home"; import Blogs from "../components/Blogs"; import Games from "../components/Games"; +import Game from "../components/Game"; import Layout from "../components/Layout"; export default function index() @@ -26,6 +27,7 @@ export default function index() } /> } /> } /> + } /> -- cgit v1.2.3