1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-10 16:05:22 +02:00

Fix chat overflow on mobile

This commit is contained in:
Zach Gollwitzer 2025-04-30 22:14:57 -04:00
parent 6e453f38bd
commit a0abb78876
9 changed files with 28 additions and 17 deletions

View file

@ -1,4 +1,4 @@
<turbo-frame id="<%= frame %>"> <%= 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.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_outer_classes do %>
<%= tag.div class: dialog_inner_classes, data: { dialog_target: "content" } do %> <%= tag.div class: dialog_inner_classes, data: { dialog_target: "content" } do %>
@ -35,4 +35,4 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
</turbo-frame> <% end %>

View file

@ -33,7 +33,7 @@ class DialogComponent < ViewComponent::Base
end end
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 VARIANTS = %w[modal drawer].freeze
WIDTHS = { WIDTHS = {
@ -43,17 +43,22 @@ class DialogComponent < ViewComponent::Base
full: "lg:max-w-full" full: "lg:max-w-full"
}.freeze }.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 @variant = variant.to_sym
@auto_open = auto_open @auto_open = auto_open
@reload_on_close = reload_on_close @reload_on_close = reload_on_close
@frame = frame
@width = width.to_sym @width = width.to_sym
@disable_frame = disable_frame
@opts = opts @opts = opts
end end
def frame # Caller must "opt-out" of using the default turbo-frame based on the variant
@frame || variant def wrapper_element(&block)
if disable_frame
content_tag(:div, &block)
else
content_tag("turbo-frame", id: variant, &block)
end
end end
def dialog_outer_classes def dialog_outer_classes
@ -80,7 +85,7 @@ class DialogComponent < ViewComponent::Base
end end
class_names( 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 variant_classes
) )
end end

View file

@ -11,13 +11,13 @@
<%= render "layouts/shared/htmldoc" do %> <%= render "layouts/shared/htmldoc" do %>
<div <div
class="flex flex-col lg:flex-row h-dvh lg:h-full bg-surface" class="flex flex-col lg:flex-row h-full bg-surface"
data-controller="app-layout" data-controller="app-layout"
data-app-layout-expanded-sidebar-class="<%= expanded_sidebar_class %>" data-app-layout-expanded-sidebar-class="<%= expanded_sidebar_class %>"
data-app-layout-collapsed-sidebar-class="<%= collapsed_sidebar_class %>" data-app-layout-collapsed-sidebar-class="<%= collapsed_sidebar_class %>"
data-app-layout-user-id-value="<%= Current.user.id %>"> data-app-layout-user-id-value="<%= Current.user.id %>">
<div <div
class="hidden fixed inset-0 bg-surface z-20 h-dvh w-full p-3 overflow-y-auto transition-all duration-300" class="hidden fixed inset-0 bg-surface z-20 h-full w-full p-3 overflow-y-auto transition-all duration-300"
data-app-layout-target="mobileSidebar"> data-app-layout-target="mobileSidebar">
<div class="mb-2"> <div class="mb-2">
<%= icon("x", as_button: true, data: { action: "app-layout#closeMobileSidebar" }) %> <%= icon("x", as_button: true, data: { action: "app-layout#closeMobileSidebar" }) %>

View file

@ -1,6 +1,6 @@
<%= render "layouts/shared/htmldoc" do %> <%= render "layouts/shared/htmldoc" do %>
<div class="flex flex-col h-dvh"> <div class="flex flex-col h-full">
<div class="flex flex-col h-screen px-6 py-12 bg-surface"> <div class="flex flex-col h-full px-6 py-12 bg-surface">
<div class="grow flex flex-col justify-center"> <div class="grow flex flex-col justify-center">
<div class="sm:mx-auto sm:w-full sm:max-w-md"> <div class="sm:mx-auto sm:w-full sm:max-w-md">
<div class="flex justify-center mt-2 md:mb-6"> <div class="flex justify-center mt-2 md:mb-6">

View file

@ -1,5 +1,5 @@
<%= render "layouts/shared/htmldoc" do %> <%= render "layouts/shared/htmldoc" do %>
<div class="flex flex-col h-dvh bg-container"> <div class="flex flex-col h-full bg-container">
<header class="flex items-center justify-between p-8"> <header class="flex items-center justify-between p-8">
<%= render LinkComponent.new( <%= render LinkComponent.new(
variant: "icon", variant: "icon",

View file

@ -1,6 +1,6 @@
<%# This dialog is used as an override to the browser's confirm API when submitting forms with data-turbo-confirm %> <%# This dialog is used as an override to the browser's confirm API when submitting forms with data-turbo-confirm %>
<%# See confirm_dialog_controller.js and _htmldoc.html.erb %> <%# See confirm_dialog_controller.js and _htmldoc.html.erb %>
<%= render DialogComponent.new(id: "confirm-dialog", auto_open: false, data: { controller: "confirm-dialog" }, width: "sm") do |dialog| %> <%= render DialogComponent.new(id: "confirm-dialog", auto_open: false, data: { controller: "confirm-dialog" }, width: "sm", disable_frame: true) do |dialog| %>
<% dialog.with_body do %> <% dialog.with_body do %>
<form method="dialog" class="space-y-4"> <form method="dialog" class="space-y-4">
<div class="space-y-2"> <div class="space-y-2">

View file

@ -1,5 +1,5 @@
<%= render "layouts/shared/htmldoc" do %> <%= render "layouts/shared/htmldoc" do %>
<div class="bg-container flex flex-col h-dvh"> <div class="bg-container flex flex-col h-full">
<header class="flex items-center justify-between p-8"> <header class="flex items-center justify-between p-8">
<%= render LinkComponent.new( <%= render LinkComponent.new(
variant: "icon", variant: "icon",

View file

@ -146,7 +146,7 @@
</li> </li>
<%= button_to session_path(Current.session), method: :delete, class: "flex items-center gap-2 px-3 py-2 rounded-lg text-sm text-destructive hover:bg-surface-hover w-full" do %> <%= button_to session_path(Current.session), method: :delete, class: "flex items-center gap-2 px-3 py-2 rounded-lg text-sm text-destructive hover:bg-surface-hover w-full" do %>
<%= icon("log-out") %> <%= icon("log-out", color: "current") %>
<span><%= t(".logout") %></span> <span><%= t(".logout") %></span>
<% end %> <% end %>

View file

@ -136,7 +136,13 @@
variant: "destructive", variant: "destructive",
href: reset_user_path(@user), href: reset_user_path(@user),
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("Account", high_severity: true) confirm: CustomConfirm.new(
title: "Reset account?",
body: "This will delete all data associated with your account. Your user profile will remain active.",
btn_text: "Reset account",
destructive: true,
high_severity: true
)
) %> ) %>
</div> </div>
<% end %> <% end %>