From cc8d3c7f8c7a33f63bc087849201469af573672a Mon Sep 17 00:00:00 2001 From: gxnca Date: Thu, 27 Nov 2025 17:34:38 +0000 Subject: [PATCH 1/4] feat: minigames page --- lib/pearl_web/config.ex | 22 +++------------- .../app/games_live/components/game_card.ex | 25 +++++++++++++++++++ lib/pearl_web/live/app/games_live/index.ex | 25 +++++++++++++++++++ .../live/app/games_live/index.html.heex | 15 +++++++++++ .../live/app/scratch_card_live/index.ex | 10 ++++++++ .../app/scratch_card_live/index.html.heex | 7 ++++++ lib/pearl_web/router.ex | 10 +++++--- 7 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 lib/pearl_web/live/app/games_live/components/game_card.ex create mode 100644 lib/pearl_web/live/app/games_live/index.ex create mode 100644 lib/pearl_web/live/app/games_live/index.html.heex create mode 100644 lib/pearl_web/live/app/scratch_card_live/index.ex create mode 100644 lib/pearl_web/live/app/scratch_card_live/index.html.heex diff --git a/lib/pearl_web/config.ex b/lib/pearl_web/config.ex index 92d343b..7b5d9a1 100644 --- a/lib/pearl_web/config.ex +++ b/lib/pearl_web/config.ex @@ -61,26 +61,12 @@ defmodule PearlWeb.Config do enabled: true }, %{ - key: :wheel, - title: "Wheel", - image: "/images/icons/wheel.svg", - url: "/app/wheel", + key: :games, + title: "Games", + icon: "hero-play", + url: "/app/games", enabled: attendee_eligible? }, - %{ - key: :coin_flip, - title: "Coin Flip", - image: "/images/icons/coin-flip.svg", - url: "/app/coin_flip", - enabled: attendee_eligible? - }, - %{ - key: :slots, - title: "Slots", - image: "/images/icons/slots.svg", - url: "/app/slots", - enabled: true - }, %{ key: :leaderboard, title: "Leaderboard", diff --git a/lib/pearl_web/live/app/games_live/components/game_card.ex b/lib/pearl_web/live/app/games_live/components/game_card.ex new file mode 100644 index 0000000..2f4f492 --- /dev/null +++ b/lib/pearl_web/live/app/games_live/components/game_card.ex @@ -0,0 +1,25 @@ +defmodule PearlWeb.App.GamesLive.Components.GameCard do + @moduledoc """ + Minigame Card. + """ + use PearlWeb, :component + + def game_card(assigns) do + ~H""" + <.link + patch={~p"/app/games/#{@path}"} + class="flex flex-col h-full group gap-6 rounded-2xl border border-white/10 bg-black/20 p-8 backdrop-blur-md transition-all duration-500 hover:border-white/20 hover:bg-black/30 hover:shadow-2xl hover:shadow-primary/10" + > + +
+

{@game}

+

{@desc}

+
+
+

Play Now

+ <.icon name="hero-arrow-right" class="size-4" /> +
+ + """ + end +end diff --git a/lib/pearl_web/live/app/games_live/index.ex b/lib/pearl_web/live/app/games_live/index.ex new file mode 100644 index 0000000..d28d4ff --- /dev/null +++ b/lib/pearl_web/live/app/games_live/index.ex @@ -0,0 +1,25 @@ +defmodule PearlWeb.App.GamesLive.Index do + use PearlWeb, :app_view + + import PearlWeb.App.GamesLive.Components.GameCard + + @impl true + def mount(_params, _session, socket) do + games = [ + %{ + name: "Lucky Whell", + icon: "wheel.svg", + path: "wheel", + desc: "Spin the wheel and win exciting prizes" + }, + %{name: "Slots", icon: "slots.svg", path: "slots", desc: "..."}, + %{name: "Coin Flip", icon: "coin-flip.svg", path: "coin_flip", desc: "..."}, + %{name: "Scratch Card", icon: "wheel.svg", path: "scratch_card", desc: "..."} + ] + + {:ok, + socket + |> assign(current_page: :games) + |> assign(games: games)} + end +end diff --git a/lib/pearl_web/live/app/games_live/index.html.heex b/lib/pearl_web/live/app/games_live/index.html.heex new file mode 100644 index 0000000..232826c --- /dev/null +++ b/lib/pearl_web/live/app/games_live/index.html.heex @@ -0,0 +1,15 @@ +<.page + title="Minigames" + size={:xl} + title_class="font-terminal uppercase" +> +
+ <.game_card + :for={game <- @games} + icon={game.icon} + path={game.path} + game={game.name} + desc={game.desc} + /> +
+ diff --git a/lib/pearl_web/live/app/scratch_card_live/index.ex b/lib/pearl_web/live/app/scratch_card_live/index.ex new file mode 100644 index 0000000..4a06cde --- /dev/null +++ b/lib/pearl_web/live/app/scratch_card_live/index.ex @@ -0,0 +1,10 @@ +defmodule PearlWeb.App.ScratchCardLive.Index do + use PearlWeb, :app_view + + @impl true + def mount(_params, _session, socket) do + {:ok, + socket + |> assign(current_page: :scrath_card)} + end +end diff --git a/lib/pearl_web/live/app/scratch_card_live/index.html.heex b/lib/pearl_web/live/app/scratch_card_live/index.html.heex new file mode 100644 index 0000000..6e61cd8 --- /dev/null +++ b/lib/pearl_web/live/app/scratch_card_live/index.html.heex @@ -0,0 +1,7 @@ +<.page + title="Scratch Card" + size={:xl} + title_class="font-terminal uppercase" +> +
Hello World
+ diff --git a/lib/pearl_web/router.ex b/lib/pearl_web/router.ex index 7c82390..2226331 100644 --- a/lib/pearl_web/router.ex +++ b/lib/pearl_web/router.ex @@ -109,16 +109,20 @@ defmodule PearlWeb.Router do live "/credential", CredentialLive.Index, :index - live "/wheel", WheelLive.Index, :index + live "/games", GamesLive.Index, :index - live "/coin_flip", CoinFlipLive.Index, :index + live "/games/wheel", WheelLive.Index, :index + + live "/games/coin_flip", CoinFlipLive.Index, :index + + live "/games/scratch_card", ScratchCardLive.Index, :index scope "/badges", BadgeLive do live "/", Index, :index live "/:id", Show, :show end - scope "/slots", SlotsLive do + scope "/games/slots", SlotsLive do live "/", Index, :index live "/paytable", Index, :show_paytable end From 42d0388c6f5ebcade758c31201e7d4afa5b5219d Mon Sep 17 00:00:00 2001 From: gxnca Date: Thu, 27 Nov 2025 17:44:19 +0000 Subject: [PATCH 2/4] fix: format --- lib/pearl_web/config.ex | 1 + lib/pearl_web/live/app/games_live/index.ex | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/pearl_web/config.ex b/lib/pearl_web/config.ex index 7b5d9a1..e95fcce 100644 --- a/lib/pearl_web/config.ex +++ b/lib/pearl_web/config.ex @@ -63,6 +63,7 @@ defmodule PearlWeb.Config do %{ key: :games, title: "Games", + # Fix: Change icon icon: "hero-play", url: "/app/games", enabled: attendee_eligible? diff --git a/lib/pearl_web/live/app/games_live/index.ex b/lib/pearl_web/live/app/games_live/index.ex index d28d4ff..1f03713 100644 --- a/lib/pearl_web/live/app/games_live/index.ex +++ b/lib/pearl_web/live/app/games_live/index.ex @@ -12,9 +12,25 @@ defmodule PearlWeb.App.GamesLive.Index do path: "wheel", desc: "Spin the wheel and win exciting prizes" }, - %{name: "Slots", icon: "slots.svg", path: "slots", desc: "..."}, - %{name: "Coin Flip", icon: "coin-flip.svg", path: "coin_flip", desc: "..."}, - %{name: "Scratch Card", icon: "wheel.svg", path: "scratch_card", desc: "..."} + %{ + name: "Slots", + icon: "slots.svg", + path: "slots", + desc: "Test your luck with classic slot machines" + }, + %{ + name: "Coin Flip", + icon: "coin-flip.svg", + path: "coin_flip", + desc: "Heads or tails? Make your choice against other users" + }, + %{ + name: "Scratch Card", + # Fix: change icon + icon: "wheel.svg", + path: "scratch_card", + desc: "Scratch scratch scratch, and reveal your fortune" + } ] {:ok, From f1c7a955c912d242f63b25d8d7755fae95fe292e Mon Sep 17 00:00:00 2001 From: gxnca Date: Thu, 27 Nov 2025 18:53:03 +0000 Subject: [PATCH 3/4] fix: warnings --- .../live/app/games_live/components/game_card.ex | 10 ++++++++-- lib/pearl_web/live/app/games_live/index.html.heex | 2 +- lib/pearl_web/live/app/slots_live/index.html.heex | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/pearl_web/live/app/games_live/components/game_card.ex b/lib/pearl_web/live/app/games_live/components/game_card.ex index 2f4f492..507e8f1 100644 --- a/lib/pearl_web/live/app/games_live/components/game_card.ex +++ b/lib/pearl_web/live/app/games_live/components/game_card.ex @@ -4,15 +4,21 @@ defmodule PearlWeb.App.GamesLive.Components.GameCard do """ use PearlWeb, :component + attr :name, :string, required: true + attr :path, :string, required: true + attr :desc, :string, required: true + attr :icon, :string, required: true + + def game_card(assigns) do ~H""" <.link - patch={~p"/app/games/#{@path}"} + patch={"/app/games/#{@path}"} class="flex flex-col h-full group gap-6 rounded-2xl border border-white/10 bg-black/20 p-8 backdrop-blur-md transition-all duration-500 hover:border-white/20 hover:bg-black/30 hover:shadow-2xl hover:shadow-primary/10" >
-

{@game}

+

{@name}

{@desc}

diff --git a/lib/pearl_web/live/app/games_live/index.html.heex b/lib/pearl_web/live/app/games_live/index.html.heex index 232826c..a9e74f1 100644 --- a/lib/pearl_web/live/app/games_live/index.html.heex +++ b/lib/pearl_web/live/app/games_live/index.html.heex @@ -8,7 +8,7 @@ :for={game <- @games} icon={game.icon} path={game.path} - game={game.name} + name={game.name} desc={game.desc} />
diff --git a/lib/pearl_web/live/app/slots_live/index.html.heex b/lib/pearl_web/live/app/slots_live/index.html.heex index 0a0e28b..78ea23c 100644 --- a/lib/pearl_web/live/app/slots_live/index.html.heex +++ b/lib/pearl_web/live/app/slots_live/index.html.heex @@ -53,7 +53,7 @@ /> <.link - patch={~p"/app/slots/paytable"} + patch={~p"/app/games/slots/paytable"} class="flex items-center max-w-80 mx-auto mt-8 md:mt-20 justify-center" > <.icon name="hero-arrow-top-right-on-square" class="text-accent mr-2" /> @@ -78,5 +78,5 @@ wrapper_class="px-6" show id="paytable-modal" - on_cancel={JS.patch(~p"/app/slots")} + on_cancel={JS.patch(~p"/app/games/slots")} /> From e383d20064af750126abde9d10f3cefe3c3f65d1 Mon Sep 17 00:00:00 2001 From: gxnca Date: Thu, 27 Nov 2025 18:56:30 +0000 Subject: [PATCH 4/4] fix: format --- lib/pearl_web/live/app/games_live/components/game_card.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pearl_web/live/app/games_live/components/game_card.ex b/lib/pearl_web/live/app/games_live/components/game_card.ex index 507e8f1..a7163b3 100644 --- a/lib/pearl_web/live/app/games_live/components/game_card.ex +++ b/lib/pearl_web/live/app/games_live/components/game_card.ex @@ -9,7 +9,6 @@ defmodule PearlWeb.App.GamesLive.Components.GameCard do attr :desc, :string, required: true attr :icon, :string, required: true - def game_card(assigns) do ~H""" <.link