From d8cf35eca750812faa21a835f18a19e3b6f1d377 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Wed, 30 Apr 2025 22:24:13 -0400 Subject: [PATCH] Mobile layout fixes (#2179) * Consolidate safe area padding * Fix chat overflow on mobile --- app/assets/tailwind/application.css | 12 ------------ app/assets/tailwind/maybe-design-system.css | 5 +++++ app/components/dialog_component.html.erb | 4 ++-- app/components/dialog_component.rb | 17 +++++++++++------ app/views/layouts/application.html.erb | 6 +++--- app/views/layouts/auth.html.erb | 4 ++-- app/views/layouts/imports.html.erb | 2 +- .../layouts/shared/_confirm_dialog.html.erb | 2 +- app/views/layouts/wizard.html.erb | 2 +- app/views/onboardings/_header.html.erb | 2 +- app/views/pages/dashboard.html.erb | 6 +++--- app/views/settings/_settings_nav.html.erb | 4 ++-- app/views/settings/profiles/show.html.erb | 8 +++++++- 13 files changed, 39 insertions(+), 35 deletions(-) diff --git a/app/assets/tailwind/application.css b/app/assets/tailwind/application.css index cb3d5852..f97f63a5 100644 --- a/app/assets/tailwind/application.css +++ b/app/assets/tailwind/application.css @@ -165,16 +165,4 @@ &::-webkit-scrollbar-thumb:hover { background: #a6a6a6; } -} - -.mt-safe { - margin-top: env(safe-area-inset-top); -} - -.pt-safe { - padding-top: env(safe-area-inset-top); -} - -.pb-safe { - padding-bottom: env(safe-area-inset-bottom); } \ No newline at end of file diff --git a/app/assets/tailwind/maybe-design-system.css b/app/assets/tailwind/maybe-design-system.css index d29b5c04..a7d5b89c 100644 --- a/app/assets/tailwind/maybe-design-system.css +++ b/app/assets/tailwind/maybe-design-system.css @@ -257,6 +257,11 @@ --shadow-xl: 0px 20px 24px -4px --alpha(var(--color-white) / 8%); } + html { + padding-top: env(safe-area-inset-top); + padding-bottom: env(safe-area-inset-bottom); + } + button { @apply cursor-pointer focus-visible:outline-gray-900; } diff --git a/app/components/dialog_component.html.erb b/app/components/dialog_component.html.erb index 8b2a67be..5f2ef647 100644 --- a/app/components/dialog_component.html.erb +++ b/app/components/dialog_component.html.erb @@ -1,4 +1,4 @@ - +<%= wrapper_element do %> <%= tag.dialog class: "w-full h-full bg-transparent theme-dark:backdrop:bg-alpha-black-900 backdrop:bg-overlay #{drawer? ? "lg:p-3" : "lg:p-1"}", **merged_opts do %> <%= tag.div class: dialog_outer_classes do %> <%= tag.div class: dialog_inner_classes, data: { dialog_target: "content" } do %> @@ -35,4 +35,4 @@ <% end %> <% end %> <% end %> - +<% end %> diff --git a/app/components/dialog_component.rb b/app/components/dialog_component.rb index 16f04bdc..97788691 100644 --- a/app/components/dialog_component.rb +++ b/app/components/dialog_component.rb @@ -33,7 +33,7 @@ class DialogComponent < ViewComponent::Base end end - attr_reader :variant, :auto_open, :reload_on_close, :frame, :width, :opts + attr_reader :variant, :auto_open, :reload_on_close, :width, :disable_frame, :opts VARIANTS = %w[modal drawer].freeze WIDTHS = { @@ -43,17 +43,22 @@ class DialogComponent < ViewComponent::Base full: "lg:max-w-full" }.freeze - def initialize(variant: "modal", auto_open: true, reload_on_close: false, frame: nil, width: "md", **opts) + def initialize(variant: "modal", auto_open: true, reload_on_close: false, width: "md", disable_frame: false, **opts) @variant = variant.to_sym @auto_open = auto_open @reload_on_close = reload_on_close - @frame = frame @width = width.to_sym + @disable_frame = disable_frame @opts = opts end - def frame - @frame || variant + # Caller must "opt-out" of using the default turbo-frame based on the variant + def wrapper_element(&block) + if disable_frame + content_tag(:div, &block) + else + content_tag("turbo-frame", id: variant, &block) + end end def dialog_outer_classes @@ -80,7 +85,7 @@ class DialogComponent < ViewComponent::Base end class_names( - "flex flex-col bg-container lg:rounded-xl lg:shadow-border-xs w-full overflow-hidden", + "flex flex-col bg-container rounded-xl shadow-border-xs mx-3 lg:mx-0 w-full overflow-hidden", variant_classes ) end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 42275c90..6766bb0b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,13 +11,13 @@ <%= render "layouts/shared/htmldoc" do %>