diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 6e7adc32..cb728da7 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -15,6 +15,7 @@ @import "./map.css"; @import "./modal.css"; @import "./radio_slider.css"; +@import "./show-only-if-inside-space-open-in-sidebar.css"; @import "./space_index.css"; @import "./star_picker.css"; @import "./tom_select.css"; diff --git a/app/assets/stylesheets/show-only-if-inside-space-open-in-sidebar.css b/app/assets/stylesheets/show-only-if-inside-space-open-in-sidebar.css new file mode 100644 index 00000000..eb53d896 --- /dev/null +++ b/app/assets/stylesheets/show-only-if-inside-space-open-in-sidebar.css @@ -0,0 +1,7 @@ +.show-only-if-inside-space-open-in-sidebar { + display: none; +} + +.space-open-in-sidebar .show-only-if-inside-space-open-in-sidebar { + display: inherit; +} diff --git a/app/javascript/controllers/mapbox_controller.js b/app/javascript/controllers/mapbox_controller.js index fe4cc4a4..fe17002f 100644 --- a/app/javascript/controllers/mapbox_controller.js +++ b/app/javascript/controllers/mapbox_controller.js @@ -18,12 +18,6 @@ export default class extends Controller { mapboxgl.accessToken = this.element.dataset.apiKey; await this.parseUrl(); - - // When you hit the back button, the page will reload. - // Even if the history was set with replaceState or pushState. - window.onpopstate = () => { - location.reload(); - }; } showSearchBox() { @@ -55,9 +49,16 @@ export default class extends Controller { this.map = new mapboxgl.Map({ container: 'map-frame', style: 'mapbox://styles/mapbox/streets-v11', + trackResize: true, ...options, }); + // Set up a resize observer as well + const resizeObserver = new ResizeObserver(() => { + this.map.resize(); + }); + resizeObserver.observe(document.getElementById('map-frame')); + this.setupEventCallbacks(); // Hash for storing markers, based on @@ -362,7 +363,7 @@ export default class extends Controller { moveMapToFitBounds(bounds) { console.log(bounds) this.map.fitBounds(bounds, { - padding: 10, + padding: 0, animate: false }, { wasZoom: true, diff --git a/app/models/image.rb b/app/models/image.rb index 5d829d5f..73ed5b4d 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -8,6 +8,9 @@ class Image < ApplicationRecord before_destroy :delete_image + # Default to order by newest first. TODO: Add some way to order images manually + default_scope { order(created_at: :desc) } + def url Rails.application.routes.url_helpers.url_for(image) end diff --git a/app/views/space_images/_image_slider.html.erb b/app/views/space_images/_image_slider.html.erb index e0c8b202..b7d19a3b 100644 --- a/app/views/space_images/_image_slider.html.erb +++ b/app/views/space_images/_image_slider.html.erb @@ -23,10 +23,10 @@ <% end %> > -
+
<% if defined?(show_caption_credits) && show_caption_credits %> <% if image.caption&.present? %> -
+
<%= image.caption %>
<% end %> diff --git a/app/views/spaces/_back_to_search_button.html.erb b/app/views/spaces/_back_to_search_button.html.erb new file mode 100644 index 00000000..05936ff3 --- /dev/null +++ b/app/views/spaces/_back_to_search_button.html.erb @@ -0,0 +1,25 @@ + diff --git a/app/views/spaces/index.html.erb b/app/views/spaces/index.html.erb index 0661bffb..cbc88f14 100644 --- a/app/views/spaces/index.html.erb +++ b/app/views/spaces/index.html.erb @@ -9,7 +9,9 @@ <%= render 'spaces/index/filters' %>
-
-
- <%= render 'spaces/index/map' %> + <%= turbo_frame_tag "spaces-open-here", + target: "_top", + class: "empty:hidden + peer/space + space-open-in-sidebar + fixed inset-0 bottom-24 z-5 + md:absolute md:inset-0 md:z-3 + 3xl:w-1/2 3xl:right-auto + 3xl:shadow-2xl + 3xl:px-4 + overscroll-contain + overflow-y-auto + bg-white" + %> + <%= render "spaces/index/map" %>
diff --git a/app/views/spaces/index/_map.html.erb b/app/views/spaces/index/_map.html.erb index 7e6a512e..6dd71529 100644 --- a/app/views/spaces/index/_map.html.erb +++ b/app/views/spaces/index/_map.html.erb @@ -1,4 +1,4 @@ -
+
diff --git a/app/views/spaces/index/_space_listing.html.erb b/app/views/spaces/index/_space_listing.html.erb index d7202f12..8474cdfd 100644 --- a/app/views/spaces/index/_space_listing.html.erb +++ b/app/views/spaces/index/_space_listing.html.erb @@ -2,7 +2,12 @@ Partial for rendering a space listing in the search results. %> -<%= link_to space_path(space), class: "unstyled-link space-listing" do %> +<%= link_to space_path(space), + class: "unstyled-link space-listing", + data: { + "turbo-frame": "spaces-open-here", # This updates the spaces-open-here frame + "turbo-action": "advance" # And updates browser history + } do %>
diff --git a/app/views/spaces/show.html.erb b/app/views/spaces/show.html.erb index f2510e8e..1b688aca 100644 --- a/app/views/spaces/show.html.erb +++ b/app/views/spaces/show.html.erb @@ -5,59 +5,64 @@ Styled in part by content.scss %> -
- <%= render partial: "spaces/show/image_header" %> +<%= turbo_frame_tag "spaces-open-here", target: "_top" do %> + <%= render 'back_to_search_button' %> +
+ <%= render partial: "spaces/show/image_header" %> -
- <%= render partial: 'spaces/show/basics' %> +
-
+ <%= render partial: 'spaces/show/basics' %> - <%= inline_editable :how_to_book do %> - <%= render_space_and_group_field @space, :how_to_book %> - <% end %> - <%= render 'space_contacts/index' %> +
-
+ <%= inline_editable :how_to_book do %> + <%= render_space_and_group_field @space, :how_to_book %> + <% end %> + <%= render 'space_contacts/index' %> - <%= render partial: 'spaces/show/facilities' %> -
+
- <%= inline_editable :who_can_use do %> - <%= render_space_and_group_field @space, :who_can_use %> - <% end %> -
+ <%= render partial: 'spaces/show/facilities' %> +
- <%= inline_editable :pricing do %> - <%= render_space_and_group_field @space, :pricing %> - <% end %> -
+ <%= inline_editable :who_can_use do %> + <%= render_space_and_group_field @space, :who_can_use %> + <% end %> +
- <%= render partial: 'spaces/show/where' %> -
+ <%= inline_editable :pricing do %> + <%= render_space_and_group_field @space, :pricing %> + <% end %> +
- <%= inline_editable :more_info do %> - <%= render_space_and_group_field @space, :more_info %> - <% end %> -
+ <%= render partial: 'spaces/show/where' %> +
- <%= inline_editable :terms do %> - <%= render_space_and_group_field @space, :terms %> - <% end %> -
+ <%= inline_editable :more_info do %> + <%= render_space_and_group_field @space, :more_info %> + <% end %> +
- <%= render partial: 'spaces/show/reviews' %> + <%= inline_editable :terms do %> + <%= render_space_and_group_field @space, :terms %> + <% end %> +
- <% if current_user&.admin? %> -
-
-

Admin:

-

- <%= link_to t("space_show.show_changelog"), admin_history_path(@space) %> -

-
- <% end %> + <%= render partial: 'spaces/show/reviews' %> + + <% if current_user&.admin? %> +
+
+

Admin:

+

+ <%= link_to t("space_show.show_changelog"), admin_history_path(@space) %> +

+
+ <% end %> -
-
+ +
+<% end %> diff --git a/app/views/spaces/show/_image_header.html.erb b/app/views/spaces/show/_image_header.html.erb index 80bd4bb1..1918a1e4 100644 --- a/app/views/spaces/show/_image_header.html.erb +++ b/app/views/spaces/show/_image_header.html.erb @@ -8,12 +8,12 @@ link_to_fullscreen: true, show_caption_credits: true } %> -
+
<%= render partial: 'spaces/show/image_header_upload_button' %>
-
+
<%= render partial: 'spaces/show/image_header_edit_button' %>
diff --git a/tailwind.config.js b/tailwind.config.js index f9d39934..b9311ddb 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -32,7 +32,8 @@ module.exports = { }, extend: { screens: { - 'xs': '360px' + 'xs': '360px', + '3xl': '1792px' }, cursor: { zoom: 'zoom-in'