diff --git a/assets/css/app.css b/assets/css/app.css index 01246c38..641706bb 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -105,4 +105,156 @@ /* Make LiveView wrapper divs transparent for layout */ [data-phx-session], [data-phx-teleported-src] { display: contents } +/* Markdown rendered content */ +.markdown-content { + max-width: 64rem; + margin: 2rem auto; + padding: 0 1rem; + line-height: 1.75; +} + +.markdown-content h1 { + font-size: 2rem; + font-weight: 700; + margin: 2rem 0 1rem; + border-bottom: 1px solid oklch(80% 0 0); + padding-bottom: 0.5rem; +} + +.markdown-content h2 { + font-size: 1.5rem; + font-weight: 700; + margin: 1.75rem 0 0.75rem; + border-bottom: 1px solid oklch(85% 0 0); + padding-bottom: 0.25rem; +} + +.markdown-content h3 { + font-size: 1.25rem; + font-weight: 600; + margin: 1.5rem 0 0.5rem; +} + +.markdown-content h4 { + font-size: 1.1rem; + font-weight: 600; + margin: 1.25rem 0 0.5rem; +} + +.markdown-content p { + margin: 0.75rem 0; +} + +.markdown-content ul, .markdown-content ol { + margin: 0.75rem 0; + padding-left: 2rem; +} + +.markdown-content ul { list-style-type: disc; } +.markdown-content ol { list-style-type: decimal; } + +.markdown-content li { + margin: 0.25rem 0; +} + +.markdown-content code { + font-family: ui-monospace, monospace; + font-size: 0.875em; + background: oklch(92% 0 0); + padding: 0.15em 0.35em; + border-radius: 0.25rem; +} + +.markdown-content pre { + margin: 1rem 0; + padding: 1rem; + background: oklch(20% 0.01 260); + color: oklch(95% 0 0); + border-radius: 0.5rem; + overflow-x: auto; +} + +.markdown-content pre code { + background: none; + padding: 0; + font-size: 0.85em; + color: inherit; +} + +.markdown-content table { + width: 100%; + border-collapse: collapse; + margin: 1rem 0; + font-size: 0.9em; + overflow-x: auto; + display: block; +} + +.markdown-content th, .markdown-content td { + border: 1px solid oklch(80% 0 0); + padding: 0.5rem 0.75rem; + text-align: left; +} + +.markdown-content th { + background: oklch(94% 0 0); + font-weight: 600; +} + +.markdown-content tr:nth-child(even) { + background: oklch(97% 0 0); +} + +.markdown-content hr { + border: none; + border-top: 2px solid oklch(85% 0 0); + margin: 2rem 0; +} + +.markdown-content strong { + font-weight: 700; +} + +.markdown-content blockquote { + border-left: 4px solid oklch(70% 0.15 260); + margin: 1rem 0; + padding: 0.5rem 1rem; + background: oklch(96% 0.005 260); +} + +.markdown-content a { + color: oklch(55% 0.2 260); + text-decoration: underline; +} + +:where([data-theme=dark]) .markdown-content code { + background: oklch(30% 0.01 260); +} + +:where([data-theme=dark]) .markdown-content th { + background: oklch(30% 0.01 260); +} + +:where([data-theme=dark]) .markdown-content tr:nth-child(even) { + background: oklch(25% 0.01 260); +} + +:where([data-theme=dark]) .markdown-content th, +:where([data-theme=dark]) .markdown-content td { + border-color: oklch(40% 0 0); +} + +:where([data-theme=dark]) .markdown-content h1, +:where([data-theme=dark]) .markdown-content h2 { + border-color: oklch(40% 0 0); +} + +:where([data-theme=dark]) .markdown-content hr { + border-color: oklch(40% 0 0); +} + +:where([data-theme=dark]) .markdown-content blockquote { + background: oklch(25% 0.01 260); +} + /* This file is for your main application CSS */ diff --git a/assets/js/propagation_map_hook.js b/assets/js/propagation_map_hook.js index 6dd6a856..5889a140 100644 --- a/assets/js/propagation_map_hook.js +++ b/assets/js/propagation_map_hook.js @@ -1,3 +1,5 @@ +import topbar from "../vendor/topbar" + export const PropagationMap = { mounted() { this.map = L.map(this.el, { @@ -24,9 +26,13 @@ export const PropagationMap = { ] this.handleEvent("update_scores", ({ scores }) => { + topbar.hide() this.renderScores(scores) }) + // Show topbar whenever the server is processing a band change + this.el.addEventListener("show-loading", () => topbar.show(300)) + // Send bounds to server on load and on pan/zoom this.sendBounds() this.map.on("moveend", () => this.sendBounds()) @@ -168,6 +174,7 @@ export const PropagationMap = { }, sendBounds() { + topbar.show(300) const b = this.map.getBounds() this.pushEvent("map_bounds", { south: b.getSouth(), diff --git a/lib/microwaveprop_web/live/algo_live.ex b/lib/microwaveprop_web/live/algo_live.ex new file mode 100644 index 00000000..3ed9a763 --- /dev/null +++ b/lib/microwaveprop_web/live/algo_live.ex @@ -0,0 +1,25 @@ +defmodule MicrowavepropWeb.AlgoLive do + @moduledoc false + use MicrowavepropWeb, :live_view + + @algo_path Path.join(:code.priv_dir(:microwaveprop), "../algo.md") + + @impl true + def mount(_params, _session, socket) do + content = + @algo_path + |> File.read!() + |> Earmark.as_html!() + + {:ok, assign(socket, page_title: "Algorithm", content: content)} + end + + @impl true + def render(assigns) do + ~H""" +
+ {raw(@content)} +
+ """ + end +end diff --git a/lib/microwaveprop_web/live/map_live.ex b/lib/microwaveprop_web/live/map_live.ex index 5143ffc1..0ddc0c66 100644 --- a/lib/microwaveprop_web/live/map_live.ex +++ b/lib/microwaveprop_web/live/map_live.ex @@ -117,7 +117,8 @@ defmodule MicrowavepropWeb.MapLive do