Skip to content

Commit 40dea76

Browse files
authored
[Reco] Unify layout to be similar to the Broadcaster (#23)
1 parent af42e4a commit 40dea76

File tree

21 files changed

+250
-331
lines changed

21 files changed

+250
-331
lines changed

reco/assets/css/app.css

+10
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
@import "tailwindcss/utilities";
44

55
/* This file is for your main application CSS */
6+
7+
/* Hiding scrollbar for IE, Edge and Firefox */
8+
main {
9+
scrollbar-width: none; /* Firefox */
10+
-ms-overflow-style: none; /* IE and Edge */
11+
}
12+
13+
main::-webkit-scrollbar {
14+
display: none;
15+
}

reco/assets/js/app.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ import { Socket } from "phoenix"
2222
import { LiveSocket } from "phoenix_live_view"
2323
import topbar from "../vendor/topbar"
2424

25+
import { Room } from "./room.js"
26+
27+
let Hooks = {}
28+
Hooks.Room = Room
29+
2530
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
26-
let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken } })
31+
let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken }, hooks: Hooks })
2732

2833
// Show progress bar on live navigation and form submits
2934
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" })

reco/assets/js/reco.js renamed to reco/assets/js/room.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ let socket;
1616
let channel;
1717
let pc;
1818

19-
async function run() {
20-
console.log("Starting");
19+
async function connect() {
20+
console.log("Connecting");
21+
button.onclick = disconnect;
2122

2223
localStream = await navigator.mediaDevices.getUserMedia({
2324
audio: true,
@@ -34,13 +35,13 @@ async function run() {
3435
socket.connect();
3536

3637
channel = socket.channel("room:" + roomId, {});
37-
channel.onClose(_ => { window.location.href = "/reco" });
38+
channel.onClose(_ => { window.location.href = "/" });
3839

3940
channel.join()
4041
.receive("ok", resp => { console.log("Joined successfully", resp) })
4142
.receive("error", resp => {
4243
console.log("Unable to join", resp);
43-
window.location.href = "/reco";
44+
window.location.href = "/";
4445
})
4546

4647
channel.on("signaling", msg => {
@@ -56,7 +57,7 @@ async function run() {
5657
channel.on("imgReco", msg => {
5758
const pred = msg['predictions'][0];
5859
imgpred.innerText = pred['label'];
59-
imgscore.innerText = pred['score'];
60+
imgscore.innerText = pred['score'].toFixed(3);
6061
})
6162

6263
channel.on("sessionTime", msg => {
@@ -75,8 +76,8 @@ async function run() {
7576
channel.push("signaling", JSON.stringify(offer));
7677
}
7778

78-
button.onclick = () => {
79-
console.log("Leaving");
79+
function disconnect() {
80+
console.log("Disconnecting");
8081
localStream.getTracks().forEach(track => track.stop());
8182
videoPlayer.srcObject = null;
8283

@@ -93,4 +94,8 @@ button.onclick = () => {
9394
}
9495
}
9596

96-
run();
97+
export const Room = {
98+
mounted() {
99+
connect();
100+
}
101+
}

reco/assets/tailwind.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
theme: {
1515
extend: {
1616
colors: {
17-
brand: "#FD4F00",
17+
brand: "#4339AC",
1818
}
1919
},
2020
},

reco/config/config.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ config :esbuild,
2626
version: "0.17.11",
2727
default: [
2828
args:
29-
~w(js/app.js js/reco.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
29+
~w(js/app.js js/room.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
3030
cd: Path.expand("../assets", __DIR__),
3131
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
3232
]
3333

3434
# Configure tailwind (the version is required)
3535
config :tailwind,
36-
version: "3.3.2",
36+
version: "3.4.4",
3737
default: [
3838
args: ~w(
3939
--config=tailwind.config.js

reco/lib/reco/application.ex

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ defmodule Reco.Application do
88

99
@max_rooms Application.compile_env!(:reco, :max_rooms)
1010

11+
@version Mix.Project.config()[:version]
12+
13+
@spec version() :: String.t()
14+
def version() do
15+
"v#{@version} #{commit()}"
16+
end
17+
18+
defp commit() do
19+
case System.cmd("git", ["rev-parse", "--short", "HEAD"]) do
20+
{hash, 0} -> "(#{String.trim(hash)})"
21+
_ -> ""
22+
end
23+
end
24+
1125
@impl true
1226
def start(_type, _args) do
1327
children = [
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
<header class="px-4 sm:px-6 lg:px-8">
2-
<div class="flex items-center justify-center border-b border-zinc-100 py-4 text-sm">
2+
<div class="flex flex-col lg:flex-row items-center justify-between border-b border-brand/15 py-3 text-sm">
33
<div class="flex items-center gap-4">
4-
<a href="https://github.com/elixir-webrtc/ex_webrtc">
5-
<img src={~p"/images/logo.svg"} width="36" />
4+
<a href="/">
5+
<img src={~p"/images/logo.svg"} width="225" />
66
</a>
77
</div>
8-
<div class="flex items-center content-center gap-4 font-semibold leading-6 text-zinc-900">
9-
<a href="https://github.com/elixir-webrtc/ex_webrtc" class="hover:text-zinc-700">
10-
GitHub
11-
</a>
12-
<a href="https://hexdocs.pm/ex_webrtc/" class="hover:text-zinc-700">
13-
Documentation
14-
</a>
8+
<div class="flex">
9+
<div class="flex items-center gap-4 font-semibold leading-6 text-brand/80">
10+
<a href="https://github.com/elixir-webrtc/ex_webrtc" class="hover:text-brand">
11+
GitHub
12+
</a>
13+
<a
14+
href="https://hexdocs.pm/ex_webrtc/readme.html"
15+
class="rounded-lg bg-brand/10 px-2 py-1 hover:bg-brand/20"
16+
>
17+
Docs <span aria-hidden="true">&rarr;</span>
18+
</a>
19+
</div>
1520
</div>
1621
</div>
1722
</header>
18-
<main class="p-72 px-4 py-8 sm:px-6 lg:px-8">
19-
<div class="mx-auto max-w-2xl">
23+
<main class="flex flex-1 justify-center overflow-scroll">
24+
<div class="h-full py-7 px-7 w-[800px]">
2025
<.flash_group flash={@flash} />
2126
<%= @inner_content %>
2227
</div>
2328
</main>
29+
<footer class="flex flex-row px-4 py-2 lg:justify-start justify-center font-semibold text-brand/80">
30+
<%= Reco.Application.version() %>
31+
</footer>

reco/lib/reco_web/components/layouts/root.html.heex

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
66
<meta name="csrf-token" content={get_csrf_token()} />
7-
<.live_title suffix=" · Phoenix Framework">
8-
<%= assigns[:page_title] || "Reco" %>
7+
<.live_title suffix=" · Reco">
8+
<%= assigns[:page_title] %>
99
</.live_title>
1010
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
1111
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
1212
</script>
1313
</head>
14-
<body class="bg-white antialiased">
14+
<body class="bg-white antialiased h-svh flex flex-col">
1515
<%= @inner_content %>
1616
</body>
1717
</html>

reco/lib/reco_web/controllers/page_controller.ex

-9
This file was deleted.

reco/lib/reco_web/controllers/page_html.ex

-5
This file was deleted.

0 commit comments

Comments
 (0)