From 3ff97d27ad2eeb4b8f30577a5d294701090c4dd8 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 16 Mar 2021 10:40:25 +0200 Subject: [PATCH] Revert to native background colour control --- assets/js/app.js | 3 +-- assets/js/dashboard/historical.js | 4 +++- assets/js/dashboard/mount.js | 3 ++- assets/js/dashboard/realtime.js | 14 ++++++++------ assets/js/dashboard/stats/current-visitors.js | 7 +++++-- assets/js/embed.host.js | 10 +--------- lib/plausible_web/controllers/stats_controller.ex | 1 + lib/plausible_web/templates/layout/app.html.eex | 2 +- lib/plausible_web/templates/stats/stats.html.eex | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index bbec05061..e5a7d07b2 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -104,9 +104,8 @@ if (embedButton) { const embedLink = new URL(document.getElementById('embed-link').value) embedLink.searchParams.set('embed', 'true') embedLink.searchParams.set('theme', theme) - let backgroundAttr = '' if (background) { - backgroundAttr = `background="${background}"` + embedLink.searchParams.set('background', background) } embedCode.value = ` diff --git a/assets/js/dashboard/historical.js b/assets/js/dashboard/historical.js index bbd9f1d63..1cbb64ab8 100644 --- a/assets/js/dashboard/historical.js +++ b/assets/js/dashboard/historical.js @@ -24,10 +24,12 @@ class Historical extends React.Component { } render() { + const navClass = this.props.site.embedded ? 'relative' : 'sticky' + return (
-
+
diff --git a/assets/js/dashboard/mount.js b/assets/js/dashboard/mount.js index d50aa7fd1..c42dbc199 100644 --- a/assets/js/dashboard/mount.js +++ b/assets/js/dashboard/mount.js @@ -14,7 +14,8 @@ if (container) { offset: container.dataset.offset, hasGoals: container.dataset.hasGoals === 'true', insertedAt: container.dataset.insertedAt, - embedded: container.dataset.embedded + embedded: container.dataset.embedded, + background: container.dataset.background } const loggedIn = container.dataset.loggedIn === 'true' diff --git a/assets/js/dashboard/realtime.js b/assets/js/dashboard/realtime.js index 1036f08ef..332930b20 100644 --- a/assets/js/dashboard/realtime.js +++ b/assets/js/dashboard/realtime.js @@ -16,7 +16,7 @@ class Realtime extends React.Component { renderConversions() { if (this.props.site.hasGoals) { return ( -
+
) @@ -24,12 +24,14 @@ class Realtime extends React.Component { } render() { + const navClass = this.props.site.embedded ? 'relative' : 'sticky' + return (
-
-
-
+
+
+
@@ -37,11 +39,11 @@ class Realtime extends React.Component {
-
+
-
+
diff --git a/assets/js/dashboard/stats/current-visitors.js b/assets/js/dashboard/stats/current-visitors.js index 53eccb003..7c2b7ce32 100644 --- a/assets/js/dashboard/stats/current-visitors.js +++ b/assets/js/dashboard/stats/current-visitors.js @@ -25,11 +25,14 @@ export default class CurrentVisitors extends React.Component { render() { if (countFilters(this.props.query) !== 0) { return null } + const query = new URLSearchParams(window.location.search) + query.set('period', 'realtime') + const { currentVisitors } = this.state; if (currentVisitors !== null) { return ( - - + + {currentVisitors} current visitor{currentVisitors === 1 ? '' : 's'} diff --git a/assets/js/embed.host.js b/assets/js/embed.host.js index ff945789b..1d366566d 100644 --- a/assets/js/embed.host.js +++ b/assets/js/embed.host.js @@ -1,11 +1,3 @@ import iframeResize from 'iframe-resizer/js/iframeResizer' -const iframe = document.querySelector('[plausible-embed]') -const options = { - heightCalculationMethod: 'taggedElement' -} -if (iframe.getAttribute('background')) { - options.bodyBackground = iframe.getAttribute('background') -} - -iframeResize(options, '[plausible-embed]') +iframeResize({heightCalculationMethod: 'taggedElement'}, '[plausible-embed]') diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.ex index f4d9412d9..4287d8db2 100644 --- a/lib/plausible_web/controllers/stats_controller.ex +++ b/lib/plausible_web/controllers/stats_controller.ex @@ -139,6 +139,7 @@ defmodule PlausibleWeb.StatsController do skip_plausible_tracking: true, shared_link_auth: shared_link.slug, embedded: conn.params["embed"] == "true", + background: conn.params["background"], theme: conn.params["theme"] ) end diff --git a/lib/plausible_web/templates/layout/app.html.eex b/lib/plausible_web/templates/layout/app.html.eex index 3da7688cf..af8795294 100644 --- a/lib/plausible_web/templates/layout/app.html.eex +++ b/lib/plausible_web/templates/layout/app.html.eex @@ -12,7 +12,7 @@ <%= render("_tracking.html", assigns) %> - "> + <%= if @conn.assigns[:background], do: "background-color: #{@conn.assigns[:background]}" %>"> <%= if !@conn.assigns[:embedded] do %> <%= render("_header.html", assigns) %> <%= render("_notice.html", assigns) %> diff --git a/lib/plausible_web/templates/stats/stats.html.eex b/lib/plausible_web/templates/stats/stats.html.eex index 67bd6f14c..8fd38ad8f 100644 --- a/lib/plausible_web/templates/stats/stats.html.eex +++ b/lib/plausible_web/templates/stats/stats.html.eex @@ -5,7 +5,7 @@
<% end %>
-
+
<%= if !@conn.assigns[:current_user] && @conn.assigns[:demo] do %>