-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathlayout.ex
More file actions
87 lines (76 loc) · 2.64 KB
/
Copy pathlayout.ex
File metadata and controls
87 lines (76 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
defmodule LiveDebuggerWeb.Layout do
@moduledoc """
Inspiration was taken from Phoenix LiveDashboard
https://github.com/phoenixframework/phoenix_live_dashboard/blob/main/lib/phoenix/live_dashboard/layout_view.ex
https://github.com/phoenixframework/phoenix_live_dashboard/blob/main/lib/phoenix/live_dashboard/layouts/dash.html.heex
"""
use Phoenix.Component
import LiveDebuggerWeb.Components
@doc false
def render(template, assigns)
def render("root.html", assigns) do
~H"""
<!DOCTYPE html>
<html lang="en">
<head>
<%= custom_head_tags(assigns, :after_opening_head_tag) %>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, shrink-to-fit=no, user-scalable=no"
/>
<meta name="csrf-token" content={Phoenix.Controller.get_csrf_token()} />
<title>LiveDebugger</title>
<link rel="stylesheet" href="/assets/live_debugger/app.css" />
<%= custom_head_tags(assigns, :before_closing_head_tag) %>
</head>
<body class="theme-light dark:theme-dark text-primary-text bg-main-bg text-xs font-normal">
<script src="/assets/phoenix/phoenix.js">
</script>
<script src="/assets/phoenix_live_view/phoenix_live_view.js">
</script>
<script src="/assets/live_debugger/hooks.js">
</script>
<script>
let liveSocket = new window.LiveView.LiveSocket('/live', window.Phoenix.Socket, {
longPollFallbackMs: 2500,
params: { _csrf_token: window.getCsrfToken() },
hooks: window.createHooks(),
dom: {
onBeforeElUpdated: window.saveDialogAndDetailsState(),
},
});
window.setTheme();
liveSocket.connect();
window.liveSocket = liveSocket;
</script>
<span id="tooltip" class="absolute hidden p-1 text-xs bg-surface-0-bg rounded-md shadow-md">
</span>
<%= @inner_content %>
</body>
</html>
"""
end
def render("app.html", assigns) do
~H"""
<main class="h-screen w-screen max-w-full">
<.flash flash={@flash} />
<%= @inner_content %>
</main>
"""
end
defp custom_head_tags(assigns, key) do
case assigns do
%{^key => components} when is_list(components) ->
assigns = assign(assigns, :components, components)
~H"""
<%= for component <- @components do %>
<%= component.(assigns) %>
<% end %>
"""
_ ->
nil
end
end
end