-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement mobile responsiveness on all pages #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| <div class="card shadow-sm w-full border border-base-300 p-4 bg-base-200 bg-opacity-70 | ||
| <div class="card shadow-sm w-full border border-base-300 p-2 sm:p-4 bg-base-200 bg-opacity-70 | ||
| [background-color:var(--color-base-200)] | ||
| [background-image:radial-gradient(color-mix(in_srgb,var(--color-primary)_25%,transparent)_0.5px,transparent_0.5px)] | ||
| [background-size:10px_10px]"> | ||
| <div class="card-body"> | ||
| <div class="card-body p-2 sm:p-4"> | ||
| <%= content %> | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,29 +17,51 @@ | |
| <!-- Construct columns sizes string from individual col_size parameters --> | ||
| <% column_sizes = columns.map { |c| c.col_size || "minmax(0, 1fr)" }.join(" ") %> | ||
|
|
||
| <!-- Each row (including header) is its own rounded box --> | ||
| <div class="mb-2"> | ||
| <div class="card bg-neutral rounded-lg"> | ||
| <div class="p-4 grid items-center gap-4" style="grid-template-columns: <%= column_sizes %>"> | ||
| <% columns.each do |column| %> | ||
| <div class="text-sm font-semibold text-neutral-content"><%= column.header %></div> | ||
| <% end %> | ||
| <!-- Desktop view: Grid layout --> | ||
| <div class="hidden md:block"> | ||
| <!-- Each row (including header) is its own rounded box --> | ||
| <div class="mb-2"> | ||
| <div class="card bg-neutral rounded-lg"> | ||
| <div class="p-4 grid items-center gap-4" style="grid-template-columns: <%= column_sizes %>"> | ||
| <% columns.each do |column| %> | ||
| <div class="text-sm font-semibold text-neutral-content"><%= column.header %></div> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="space-y-2"> | ||
| <% records.each_with_index do |record, index| %> | ||
| <div data-index-table-component-target="row" class="card bg-white rounded-lg shadow-sm"> | ||
| <div class="p-3 grid items-center gap-4" style="grid-template-columns: <%= column_sizes %>"> | ||
| <% columns.each do |column| %> | ||
| <div class="text-sm text-base-content"><%= render_cell_content(record, column) %></div> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
|
Comment on lines
+34
to
+42
|
||
| <div data-index-table-component-target="emptyRow" class="card bg-white rounded-lg shadow-sm <%= "hidden" unless empty? %>"> | ||
| <div class="flex justify-center p-3 items-center"> | ||
| <div class="text-sm text-base-content/40 font-bold"><%= t("shared.index_table_component.no_entries") %></div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="space-y-2"> | ||
| <!-- Mobile view: Stacked cards --> | ||
| <div class="md:hidden space-y-3"> | ||
| <% records.each_with_index do |record, index| %> | ||
| <div data-index-table-component-target="row" class="card bg-white rounded-lg shadow-sm"> | ||
| <div class="p-3 grid items-center gap-4" style="grid-template-columns: <%= column_sizes %>"> | ||
| <% columns.each do |column| %> | ||
| <div data-index-table-component-target="row" class="card bg-white rounded-lg shadow-sm p-4"> | ||
| <% columns.each do |column| %> | ||
| <div class="flex flex-col py-2 border-b border-base-200 last:border-0"> | ||
| <div class="text-xs font-semibold text-base-content mb-1"><%= column.header %></div> | ||
| <div class="text-sm text-base-content"><%= render_cell_content(record, column) %></div> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| <% end %> | ||
|
Comment on lines
+34
to
62
|
||
| <div data-index-table-component-target="emptyRow" class="card bg-white rounded-lg shadow-sm <%= "hidden" unless empty? %>"> | ||
| <div class="flex justify-center p-3 items-center"> | ||
| <div class="flex justify-center p-4 items-center"> | ||
| <div class="text-sm text-base-content/40 font-bold"><%= t("shared.index_table_component.no_entries") %></div> | ||
| </div> | ||
| </div> | ||
|
Comment on lines
+20
to
67
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| <ul class="menu shadow-lg bg-base-200 w-64 min-h-screen tracking-wide justify-between"> | ||
| <ul data-mobile-menu-target="sidebar" role="navigation" aria-label="Main navigation" class="menu shadow-lg bg-base-200 w-64 min-h-screen tracking-wide justify-between fixed md:sticky top-0 left-0 z-40 transition-transform duration-300 -translate-x-full md:translate-x-0"> | ||
| <div> | ||
| <div class="px-4 py-4 border-b border-base-300"> | ||
| <%= link_to root_path do %> | ||
|
|
@@ -10,12 +10,12 @@ | |
| </div> | ||
| <% end %> | ||
| </div> | ||
| <li class="py-6"> | ||
| <li class="py-6 overflow-y-auto max-h-[calc(100vh-200px)]"> | ||
|
||
| <% sections.each do |section| %> | ||
| <h2 class="menu-title uppercase"> <%= section.title %></h2> | ||
| <ul> | ||
| <% section.items.each do |item| %> | ||
| <li> <%= link_to item.path do %> | ||
| <li> <%= link_to item.path, data: { action: "click->mobile-menu#close" } do %> | ||
| <%= render IconComponent.new(icon: item.icon, size: :md, classes: "w-5 h-5") %> | ||
| <span class="truncate text-base-content"><%= item.name %></span> | ||
| <% end %> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||
| import { Controller } from "@hotwired/stimulus"; | ||||||||
|
|
||||||||
| // Mobile menu controller for toggling sidebar on mobile devices | ||||||||
| export default class extends Controller { | ||||||||
| static targets = ["sidebar", "overlay", "menuButton"]; | ||||||||
|
|
||||||||
| connect() { | ||||||||
| // Close menu on window resize if screen becomes larger | ||||||||
| this.handleResize = this.handleResize.bind(this); | ||||||||
| window.addEventListener("resize", this.handleResize); | ||||||||
| } | ||||||||
|
|
||||||||
| disconnect() { | ||||||||
|
||||||||
| disconnect() { | |
| disconnect() { | |
| this.close(); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,10 +24,28 @@ | |||||||
| </head> | ||||||||
|
|
||||||||
| <body class="min-h-screen bg-base-100"> | ||||||||
| <div class="flex min-h-screen"> | ||||||||
| <div class="flex min-h-screen" <%= "data-controller=\"mobile-menu\"".html_safe unless current_page?(login_path) %>> | ||||||||
|
||||||||
| <!-- Mobile Menu Button (visible only on mobile and when not on login page) --> | ||||||||
| <% unless current_page?(login_path) %> | ||||||||
| <button | ||||||||
| data-mobile-menu-target="menuButton" | ||||||||
| data-action="click->mobile-menu#toggle" | ||||||||
| class="md:hidden fixed top-4 left-4 z-50 btn btn-circle btn-primary shadow-lg"> | ||||||||
| <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="inline-block h-5 w-5 stroke-current"> | ||||||||
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path> | ||||||||
| </svg> | ||||||||
| </button> | ||||||||
|
|
||||||||
| <!-- Overlay (for mobile when menu is open) --> | ||||||||
| <div | ||||||||
| data-mobile-menu-target="overlay" | ||||||||
| data-action="click->mobile-menu#close" | ||||||||
|
||||||||
| data-action="click->mobile-menu#close" | |
| data-action="click->mobile-menu#close" | |
| aria-hidden="true" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,8 +1,9 @@ | ||||||
| <div class="mx-8 my-10"> | ||||||
| <div class="flex items-center justify-between mb-5"> | ||||||
| <h1 class="text-4xl font-bold"><%= t(".title") %></h1> | ||||||
| <div class="mx-4 sm:mx-8 my-6 sm:my-10"> | ||||||
| <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-5"> | ||||||
| <h1 class="text-2xl sm:text-3xl lg:text-4xl font-bold"><%= t(".title") %></h1> | ||||||
| <%= render ActionButtonComponent.new(to: new_region_path, icon: "add", colour: :primary, size: :large, turbo_stream: true) do %> | ||||||
| <%= t(".actions.create") %> | ||||||
| <span class="hidden sm:inline"><%= t(".actions.create") %></span> | ||||||
| <span class="sm:hidden">New</span> | ||||||
|
||||||
| <span class="sm:hidden">New</span> | |
| <span class="sm:hidden"><%= t(".actions.create_short") %></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
transition-colorsclass is added without a correspondinghover:effect already existing on the element. Whilehover:bg-base-400is added, thetransition-colorsclass would provide a smoother transition. However, this is only effective if there are color changes to transition. Consider also adding a transition duration class likeduration-200orduration-300for a more polished hover effect.