diff --git a/lib/plausible/billing/subscription.ex b/lib/plausible/billing/subscription.ex index b2dcfcca2..148e00daa 100644 --- a/lib/plausible/billing/subscription.ex +++ b/lib/plausible/billing/subscription.ex @@ -48,7 +48,8 @@ defmodule Plausible.Billing.Subscription do %__MODULE__{ paddle_plan_id: "free_10k", status: "active", - next_bill_amount: "0" + next_bill_amount: "0", + currency_code: "EUR" } |> cast(attrs, @required_fields) |> validate_required([:user_id]) diff --git a/lib/plausible_web.ex b/lib/plausible_web.ex index 8c7765e41..4af57885a 100644 --- a/lib/plausible_web.ex +++ b/lib/plausible_web.ex @@ -24,6 +24,7 @@ defmodule PlausibleWeb do import PlausibleWeb.ErrorHelpers import PlausibleWeb.FormHelpers + import PlausibleWeb.Components.Generic alias PlausibleWeb.Router.Helpers, as: Routes end end diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index dbef2a419..6a7407c2d 100644 --- a/lib/plausible_web/components/generic.ex +++ b/lib/plausible_web/components/generic.ex @@ -41,4 +41,50 @@ defmodule PlausibleWeb.Components.Generic do """ end + + attr :href, :string, required: true + attr :new_tab, :boolean + attr :class, :string, default: "" + slot :inner_block + + def styled_link(assigns) do + if assigns[:new_tab] do + assigns = assign(assigns, :icon_class, icon_class(assigns)) + + ~H""" + <.link + class={[ + "inline-flex items-center gap-x-0.5 text-indigo-600 hover:text-indigo-700 dark:text-indigo-500 dark:hover:text-indigo-600", + @class + ]} + href={@href} + target="_blank" + rel="noopener noreferrer" + > + <%= render_slot(@inner_block) %> + + + """ + else + ~H""" + <.link + class={[ + "text-indigo-600 hover:text-indigo-700 dark:text-indigo-500 dark:hover:text-indigo-600", + @class + ]} + href={@href} + > + <%= render_slot(@inner_block) %> + + """ + end + end + + defp icon_class(link_assigns) do + if String.contains?(link_assigns[:class], "text-sm") do + ["w-3 h-3"] + else + ["w-4 h-4"] + end + end end diff --git a/lib/plausible_web/templates/auth/user_settings.html.heex b/lib/plausible_web/templates/auth/user_settings.html.heex index 289bc91a5..7ac84ef52 100644 --- a/lib/plausible_web/templates/auth/user_settings.html.heex +++ b/lib/plausible_web/templates/auth/user_settings.html.heex @@ -60,13 +60,13 @@ <%= subscription_quota(@subscription) %> pageviews - <.link + <.styled_link :if={@subscription.status == "active"} href={Routes.billing_path(@conn, :change_plan_form)} - class="text-sm text-indigo-500 font-medium" + class="text-sm font-medium" > Change plan - + <% else %>
Free trial
- <.link - href={Routes.billing_path(@conn, :upgrade)} - class="text-sm text-indigo-500 font-medium" - > + <.styled_link class="text-sm font-medium" href={Routes.billing_path(@conn, :upgrade)}> Upgrade - + <% end %>
- <%= form_for @changeset, Routes.site_path(@conn, :change_domain_submit, @site.domain), [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %> -

Change your website domain

- -
- <%= label f, :domain, class: "block text-sm font-medium text-gray-700 dark:text-gray-300" %> -

Just the naked domain or subdomain without 'www'

-
- - https:// - - <%= text_input f, :domain, class: "focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-800 flex-1 block w-full px-3 py-2 rounded-none rounded-r-md sm:text-sm border-gray-300 dark:border-gray-500 dark:bg-gray-900 dark:text-gray-300", placeholder: "example.com" %> -
- <%= error_tag f, :domain %> -
- -

- Once you change your domain, you must update the JavaScript snippet on your site within 72 hours to guarantee continuous tracking. If you're using the API, please also make sure to update your API credentials.

-

- Visit our documentation for details. -

- - <%= submit "Change Domain and add new Snippet →", class: "button mt-4 w-full" %> - -
- <%= link "Back to Site Settings", to: Routes.site_path(@conn, :settings_general, @site.domain), class: "text-indigo-500 w-full text-center" %> -
- <% end %> -
diff --git a/lib/plausible_web/templates/site/change_domain.html.heex b/lib/plausible_web/templates/site/change_domain.html.heex new file mode 100644 index 000000000..8ea758763 --- /dev/null +++ b/lib/plausible_web/templates/site/change_domain.html.heex @@ -0,0 +1,45 @@ +
+ <%= form_for @changeset, Routes.site_path(@conn, :change_domain_submit, @site.domain), [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %> +

Change your website domain

+ +
+ <%= label(f, :domain, class: "block text-sm font-medium text-gray-700 dark:text-gray-300") %> +

+ Just the naked domain or subdomain without 'www' +

+
+ + https:// + + <%= text_input(f, :domain, + class: + "focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-800 flex-1 block w-full px-3 py-2 rounded-none rounded-r-md sm:text-sm border-gray-300 dark:border-gray-500 dark:bg-gray-900 dark:text-gray-300", + placeholder: "example.com" + ) %> +
+ <%= error_tag(f, :domain) %> +
+ +

+ Once you change your domain, you must update the JavaScript snippet on your site within 72 hours to guarantee continuous tracking. If you're using the API, please also make sure to update your API credentials. +

+

+ Visit our + <.styled_link new_tab class="text-sm" href="https://plausible.io/docs/change-domain-name/"> + documentation + + for details. +

+ + <%= submit("Change Domain and add new Snippet →", class: "button mt-4 w-full") %> + +
+ <.styled_link + href={Routes.site_path(@conn, :settings_general, @site.domain)} + class="w-full text-center" + > + Back to Site Settings + +
+ <% end %> +
diff --git a/lib/plausible_web/templates/site/snippet.html.eex b/lib/plausible_web/templates/site/snippet.html.eex deleted file mode 100644 index c46cea547..000000000 --- a/lib/plausible_web/templates/site/snippet.html.eex +++ /dev/null @@ -1,22 +0,0 @@ -
- <%= form_for @conn, "/", [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %> -

Add JavaScript snippet

-
-

Paste this snippet in the <head> of your website.

- -
- <%= textarea f, :domain, id: "snippet_code", class: "transition overflow-hidden bg-gray-100 dark:bg-gray-900 appearance-none border border-transparent rounded w-full p-2 pr-6 text-gray-700 dark:text-gray-300 leading-normal appearance-none focus:outline-none focus:bg-white dark:focus:bg-gray-800 focus:border-gray-400 dark:focus:border-gray-500 text-xs mt-4 resize-none", value: render_snippet(@site), rows: 3, readonly: "readonly" %> - - - -
-
- <%= link("Start collecting data →", class: "button mt-4 w-full", to: "/#{URI.encode_www_form(@site.domain)}") %> - <% end %> - - <%= if @is_first_site do %> - - <% end %> -
diff --git a/lib/plausible_web/templates/site/snippet.html.heex b/lib/plausible_web/templates/site/snippet.html.heex new file mode 100644 index 000000000..6f93026c3 --- /dev/null +++ b/lib/plausible_web/templates/site/snippet.html.heex @@ -0,0 +1,73 @@ +
+ <%= form_for @conn, "/", [class: "max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %> +

Add JavaScript snippet

+
+

+ Paste this snippet in the <head> of your website. +

+ +
+ <%= textarea(f, :domain, + id: "snippet_code", + class: + "transition overflow-hidden bg-gray-100 dark:bg-gray-900 appearance-none border border-transparent rounded w-full p-2 pr-6 text-gray-700 dark:text-gray-300 leading-normal appearance-none focus:outline-none focus:bg-white dark:focus:bg-gray-800 focus:border-gray-400 dark:focus:border-gray-500 text-xs mt-4 resize-none", + value: render_snippet(@site), + rows: 3, + readonly: "readonly" + ) %> + + + + + + +
+
+ +
+

+ On WordPress? We have + <.styled_link + new_tab + class="text-sm" + href="https://plausible.io/wordpress-analytics-plugin" + > + a plugin + +

+ +

+ See more + <.styled_link new_tab class="text-sm" href="https://plausible.io/docs/integration-guides"> + integration guides + +

+
+ <%= link("Start collecting data →", + class: "button mt-4 w-full", + to: "/#{URI.encode_www_form(@site.domain)}" + ) %> + <% end %> + + <%= if @is_first_site do %> + + <% end %> +