studio-engine 0.82.1 → 0.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Studio
4
+ # The site footer and the booking primitives, as view helpers. See
5
+ # docs/SITE_FOOTER.md.
6
+ #
7
+ # <%= studio_site_footer %> the footer, where it should show
8
+ # <%= studio_booking_frame %> Google's booking page, inline
9
+ # <%= studio_booking_link "Book a call", class: "btn btn-primary" %>
10
+ # <%= studio_booking_popup %> the dialog those links open
11
+ # <%= studio_footer_map %> the map alone, e.g. on a contact page
12
+ #
13
+ # Every one of them renders NOTHING when its configuration is absent
14
+ # (Studio.site_footer, Studio.booking_url), so a layout or a shared view can
15
+ # call them before an app has declared anything.
16
+ #
17
+ # Prefixed names for the reason Studio::GeoHelper gives: every helper module is
18
+ # included into every view.
19
+ module SiteFooterHelper
20
+ # The resolved facts (Studio::SiteFooter.resolve), or nil. Resolved once per
21
+ # request.
22
+ #
23
+ # A callable that RAISES must not take every page down with it, because the
24
+ # footer is in the layout. In production the error is logged once per process
25
+ # and the page renders with no footer; locally it raises, so whoever wrote the
26
+ # callable sees it.
27
+ def studio_site_footer_facts
28
+ return @_studio_site_footer_facts if defined?(@_studio_site_footer_facts)
29
+
30
+ @_studio_site_footer_facts =
31
+ begin
32
+ Studio.site_footer_for(self)
33
+ rescue StandardError => error
34
+ raise if studio_site_footer_raise?
35
+
36
+ studio_site_footer_report(error)
37
+ nil
38
+ end
39
+ end
40
+
41
+ # Where the footer shows: Studio.site_footer_visible, asked of this view. By
42
+ # default that is every page for a visitor and, for a signed-in viewer, only
43
+ # the controllers in Studio.site_footer_controllers (plus the engine's booking
44
+ # page). Always false for an app that declared no footer.
45
+ def studio_show_site_footer?
46
+ return false if studio_site_footer_facts.nil?
47
+
48
+ Studio.site_footer_visible.call(self) ? true : false
49
+ end
50
+
51
+ # The one layout line. Renders the footer (and, with a booking_url, the
52
+ # booking popup) where studio_show_site_footer? says it belongs.
53
+ def studio_site_footer
54
+ return unless studio_show_site_footer?
55
+
56
+ render "studio/site_footer/footer", facts: studio_site_footer_facts
57
+ end
58
+
59
+ # The live map alone. With no arguments it maps the footer's address;
60
+ # pass lat:/lng: (and street:/city_line:/directions_url:) to map another.
61
+ # `class:` and `style:` size it: the element has no height of its own.
62
+ def studio_footer_map(address = nil, **options)
63
+ address = address ? Studio::SiteFooter.address(Studio::SiteFooter.symbolize(address)) : studio_site_footer_facts&.dig(:address)
64
+ return unless address && address[:map]
65
+
66
+ render "studio/site_footer/map", address: address, classes: options[:class], style: options[:style],
67
+ zoom: options[:zoom], controls: options.fetch(:controls, true)
68
+ end
69
+
70
+ # ---- booking ------------------------------------------------------------
71
+
72
+ def studio_booking? = Studio.booking_url.present?
73
+
74
+ # Google's embeddable page for the configured schedule (with gv=true).
75
+ def studio_booking_embed_url = Studio::Booking.embed_url(Studio.booking_url)
76
+
77
+ # Where a booking link goes when the popup cannot open (scripts off, a
78
+ # modified click, a page with no dialog): the app's booking page when the
79
+ # engine draws it, else Google's own page.
80
+ def studio_booking_fallback_path
81
+ return studio_booking_path if Studio.draw_booking_routes && respond_to?(:studio_booking_path)
82
+
83
+ Studio.booking_url
84
+ end
85
+
86
+ # The frame's accessible name.
87
+ def studio_booking_title(title = nil)
88
+ title.presence || studio_site_footer_facts&.dig(:booking_title) ||
89
+ "#{studio_booking_label} with #{studio_site_footer_name}"
90
+ end
91
+
92
+ # What the booking links, the popup and the booking page call the act.
93
+ def studio_booking_label
94
+ studio_site_footer_facts&.dig(:booking_label) || Studio::SiteFooter::DEFAULT_BOOKING_LABEL
95
+ end
96
+
97
+ # The site's name: the footer's, else the site identity's title.
98
+ def studio_site_footer_name
99
+ studio_site_footer_facts&.dig(:name) || Studio.site_identity[:title]
100
+ end
101
+
102
+ # The inline booking frame. `crop: false` shows Google's whole page at rest.
103
+ def studio_booking_frame(title: nil, crop: true)
104
+ return unless studio_booking?
105
+
106
+ render "studio/booking/frame", title: studio_booking_title(title), crop: crop
107
+ end
108
+
109
+ # The booking dialog, once per page however often it is asked for. The
110
+ # footer renders it; call this yourself only on a page that has booking
111
+ # links and no footer.
112
+ def studio_booking_popup(label: nil, title: nil)
113
+ return unless studio_booking?
114
+ return if @_studio_booking_popup_rendered
115
+
116
+ @_studio_booking_popup_rendered = true
117
+ render "studio/booking/popup",
118
+ label: label.presence || studio_booking_label,
119
+ title: studio_booking_title(title)
120
+ end
121
+
122
+ # A link that opens the booking popup in place. Its href is the fallback, so
123
+ # it is an ordinary link wherever the popup is unavailable. With no
124
+ # booking_url and no href there is nowhere to go, and it renders nothing.
125
+ #
126
+ # <%= studio_booking_link %> "Schedule a call"
127
+ # <%= studio_booking_link "Book a call", class: "btn btn-primary" %>
128
+ # <%= studio_booking_link "Book a call", contact_path %> your own fallback
129
+ def studio_booking_link(name = nil, href = nil, html_options = nil, **options, &block)
130
+ html_options, href = href, nil if href.is_a?(Hash)
131
+ html_options, name = name, nil if name.is_a?(Hash)
132
+ html_options = (html_options || {}).merge(options)
133
+ href ||= studio_booking_fallback_path
134
+ return if href.blank?
135
+
136
+ html_options[:data] = { booking_popup: true, studio_booking: true }.merge(html_options[:data] || {}) if studio_booking?
137
+ content = block ? capture(&block) : (name || studio_booking_label)
138
+ link_to(content, href, html_options)
139
+ end
140
+
141
+ # ---- once-per-page assets -----------------------------------------------
142
+
143
+ def studio_site_footer_assets
144
+ return if @_studio_site_footer_assets_rendered
145
+
146
+ @_studio_site_footer_assets_rendered = true
147
+ render "studio/site_footer/assets"
148
+ end
149
+
150
+ def studio_booking_assets
151
+ return if @_studio_booking_assets_rendered
152
+
153
+ @_studio_booking_assets_rendered = true
154
+ render "studio/booking/assets"
155
+ end
156
+
157
+ private
158
+
159
+ def studio_site_footer_raise?
160
+ defined?(Rails) && Rails.respond_to?(:env) && (Rails.env.development? || Rails.env.test?)
161
+ end
162
+
163
+ def studio_site_footer_report(error)
164
+ return if Studio::SiteFooterHelper.reported
165
+
166
+ Studio::SiteFooterHelper.reported = true
167
+ if defined?(::ErrorLog) && ::ErrorLog.respond_to?(:capture!)
168
+ ::ErrorLog.capture!(error)
169
+ elsif defined?(Rails.logger) && Rails.logger
170
+ Rails.logger.error("[studio.site_footer] #{error.class}: #{error.message}")
171
+ end
172
+ rescue StandardError
173
+ nil
174
+ end
175
+
176
+ class << self
177
+ attr_accessor :reported
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,162 @@
1
+ <%# Styles and scripts for the booking frame and the booking popup. Rendered
2
+ once per page, by `studio_booking_assets` (the frame and the popup both ask).
3
+ Scoped CSS for the reason studio/site_footer/_assets gives. %>
4
+ <style>
5
+ /* The inline frame. Google's page cannot be themed, so the panel is white. */
6
+ /* content-box, so the heights below are the WINDOW onto the frame whatever
7
+ reset the host runs: under border-box the border would eat 2px of the crop. */
8
+ .booking-frame { box-sizing: content-box; margin-inline: auto; overflow: hidden; background: #fff; border-radius: .75rem;
9
+ border: 1px solid var(--color-border, rgb(127 127 127 / .25));
10
+ /* A booking link on this page scrolls here; land below the pinned navbar. */
11
+ scroll-margin-top: calc(var(--nav-bottom, 4rem) + 1rem); }
12
+ .booking-frame iframe { display: block; width: 100%; border: 0; height: 1200px; }
13
+ @media (min-width: 640px) {
14
+ .booking-frame iframe { height: 732px; }
15
+ .booking-frame-cropped { height: 414px; transition: height .25s ease; }
16
+ .booking-frame-cropped iframe { margin-top: -205px; transition: margin-top .25s ease; }
17
+ .booking-frame-cropped.is-open { height: 732px; }
18
+ .booking-frame-cropped.is-open iframe { margin-top: 0; }
19
+ }
20
+ /* Scripts off: the frame never gets its src, so it is hidden and a plain link
21
+ stands in its place (the <noscript> in studio/booking/_frame). */
22
+ .booking-frame-noscript { margin: 0; padding: 3rem 1.5rem; text-align: center; color: #111; }
23
+ .booking-frame-noscript a { color: #4338ca; font-weight: 700; text-decoration: underline; }
24
+ .booking-frame-note { margin: 1rem 0 0; text-align: center; font-size: .875rem; color: var(--color-text-muted, inherit); }
25
+ .booking-frame-note a { color: var(--color-primary, #8b5cf6); }
26
+ .booking-frame-note a:hover { text-decoration: underline; }
27
+
28
+ /* The popup. */
29
+ .booking-popup { width: min(960px, calc(100vw - 2rem)); height: min(800px, calc(100vh - 3rem)); height: min(800px, calc(100dvh - 3rem)); max-width: none; max-height: none;
30
+ /* Tailwind's reset zeroes a dialog's margin, which is what centres it. */
31
+ margin: auto; inset: 0;
32
+ padding: 0; border: 1px solid rgb(127 127 127 / .3); border-radius: .75rem; overflow: hidden;
33
+ background: var(--color-surface, #fff); color: var(--color-text-body, inherit); }
34
+ .booking-popup[open] { display: flex; flex-direction: column; }
35
+ .booking-popup::backdrop { background: rgb(15 12 31 / .72); backdrop-filter: blur(3px); }
36
+ .booking-popup-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0;
37
+ padding: .6rem .75rem .6rem 1.1rem; }
38
+ .booking-popup-title { font-weight: 700; color: var(--color-text, inherit); }
39
+ /* THE WAY OUT HAS TO BE UNMISSABLE. Once focus is inside Google's frame the
40
+ Escape key goes to Google, not to this dialog, and nothing here can change
41
+ that. So Close is a solid, full-size button, not a quiet glyph, and a click
42
+ anywhere on the backdrop closes too. */
43
+ /* Ink on surface, inverted: the theme's text colour as the fill and its
44
+ surface as the label. That pair is the theme's own highest contrast in both
45
+ modes (white on the primary measured 3.10:1, under the 4.5:1 a label needs). */
46
+ .booking-popup-close { flex: none; min-height: 2.75rem; padding: .5rem 1.1rem; border-radius: .5rem; border: 0;
47
+ background: var(--color-text, #111827); color: var(--color-surface, #fff); font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer; }
48
+ .booking-popup-close:hover { filter: brightness(1.12); }
49
+ .booking-popup-close:focus-visible { outline: 3px solid var(--color-primary, #8b5cf6); outline-offset: 2px; }
50
+ /* The page behind does not scroll while the dialog is open. Pure CSS, so every
51
+ way of closing it (the button, the backdrop, Escape) lifts the lock. On html
52
+ rather than body for the reason studio/modals/_host gives. */
53
+ html:has(dialog[data-booking-dialog][open]) { overflow: hidden; }
54
+ .booking-popup iframe { flex: 1; width: 100%; border: 0; background: #fff; }
55
+ @media (prefers-reduced-motion: reduce) { .booking-frame, .booking-frame iframe { transition: none; } }
56
+ </style>
57
+
58
+ <script>
59
+ // The inline frame: assign src after `load`, once the frame is near the
60
+ // viewport, and open the crop when focus moves into the frame.
61
+ //
62
+ // THE GUARDS ARE THE ENGINE'S OWN NAMES, AND THE ELEMENTS ARE THE ENGINE'S OWN
63
+ // (data-studio-booking), for the reason studio/site_footer/_assets gives for
64
+ // the map: an app that still renders a local booking script guards it with
65
+ // the unprefixed names and marks its frame, dialog and links with the same
66
+ // data-booking-* attributes. Sharing either lets one script stand the other
67
+ // down across a Turbo visit, or act on elements that are not its own.
68
+ (function () {
69
+ if (window.__studioBookingFramesArmed) return;
70
+ window.__studioBookingFramesArmed = true;
71
+
72
+ function arm() {
73
+ document.querySelectorAll('iframe[data-booking-frame][data-studio-booking][data-src]').forEach(function (frame) {
74
+ if (frame.__bookingArmed) return;
75
+ frame.__bookingArmed = true;
76
+ if (typeof IntersectionObserver !== 'function') { frame.src = frame.dataset.src; return; }
77
+ var watcher = new IntersectionObserver(function (entries) {
78
+ if (!entries.some(function (entry) { return entry.isIntersecting; })) return;
79
+ watcher.disconnect();
80
+ frame.src = frame.dataset.src;
81
+ }, { rootMargin: '200px' });
82
+ watcher.observe(frame);
83
+ });
84
+ }
85
+
86
+ function armAfterLoad() {
87
+ if (document.readyState === 'complete') arm();
88
+ else window.addEventListener('load', arm, { once: true });
89
+ }
90
+
91
+ // Focus moving into the frame is the one signal a cross-origin frame gives
92
+ // its parent. It means the visitor has started using the calendar.
93
+ window.addEventListener('blur', function () {
94
+ var active = document.activeElement;
95
+ if (!active || !active.matches || !active.matches('iframe[data-booking-frame][data-studio-booking]')) return;
96
+ var wrap = active.closest('[data-booking-wrap][data-studio-booking]');
97
+ if (wrap) wrap.classList.add('is-open');
98
+ });
99
+
100
+ document.addEventListener('turbo:load', armAfterLoad);
101
+ armAfterLoad();
102
+ })();
103
+ </script>
104
+
105
+ <script>
106
+ // Any a[data-booking-popup] link opens the booking dialog instead of leaving
107
+ // the page. Delegated from document, so it survives Turbo body swaps. A
108
+ // modified click (new tab, new window) is left alone, and so is everything
109
+ // when the dialog is missing or <dialog> is unsupported: the link's own href
110
+ // then takes the visitor to the booking page.
111
+ //
112
+ // ON A PAGE THAT ALREADY SHOWS THE INLINE FRAME the link goes to that frame
113
+ // instead: it scrolls there, opens the crop and moves focus in. A popup would
114
+ // be a second copy of the calendar on top of the first.
115
+ (function () {
116
+ if (window.__studioBookingPopupArmed) return;
117
+ window.__studioBookingPopupArmed = true;
118
+
119
+ document.addEventListener('click', function (event) {
120
+ var link = event.target.closest && event.target.closest('a[data-booking-popup][data-studio-booking]');
121
+ if (!link) return;
122
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
123
+
124
+ var inline = document.querySelector('iframe[data-booking-frame][data-studio-booking]');
125
+ if (inline) {
126
+ event.preventDefault();
127
+ var wrap = inline.closest('[data-booking-wrap][data-studio-booking]');
128
+ if (wrap) wrap.classList.add('is-open');
129
+ // Before `load` the frame keeps waiting: its own script assigns src then.
130
+ if (!inline.getAttribute('src') && document.readyState === 'complete') inline.src = inline.dataset.src;
131
+ var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
132
+ (wrap || inline).scrollIntoView({ behavior: calm ? 'auto' : 'smooth', block: 'start' });
133
+ inline.focus({ preventScroll: true });
134
+ return;
135
+ }
136
+
137
+ var dialog = document.querySelector('dialog[data-booking-dialog][data-studio-booking]');
138
+ if (!dialog || typeof dialog.showModal !== 'function') return;
139
+
140
+ event.preventDefault();
141
+ var frame = dialog.querySelector('iframe[data-booking-popup-frame]');
142
+ if (frame && !frame.getAttribute('src')) frame.src = frame.dataset.src;
143
+ if (!dialog.open) dialog.showModal();
144
+ });
145
+
146
+ // A click on the backdrop lands on the dialog element itself.
147
+ document.addEventListener('click', function (event) {
148
+ if (event.target.matches && event.target.matches('dialog[data-booking-dialog][data-studio-booking]')) event.target.close();
149
+ });
150
+
151
+ // Never snapshot the dialog open: a restored page would show it stuck. And
152
+ // never snapshot its frame loaded: a restored page would ask Google for a
153
+ // popup nobody has opened. The src goes back to waiting in data-src.
154
+ document.addEventListener('turbo:before-cache', function () {
155
+ var dialog = document.querySelector('dialog[data-booking-dialog][data-studio-booking]');
156
+ if (!dialog) return;
157
+ if (dialog.open) dialog.close();
158
+ var frame = dialog.querySelector('iframe[data-booking-popup-frame]');
159
+ if (frame) frame.removeAttribute('src');
160
+ });
161
+ })();
162
+ </script>
@@ -0,0 +1,41 @@
1
+ <%# Google's inline booking page for the app's appointment schedule
2
+ (Studio.booking_url). Rendered by `studio_booking_frame`. It fills its
3
+ container, so it lines up with the cards around it. Google lays it out by
4
+ width: month beside the slots from about 600px, stacked below that. It
5
+ cannot be themed, so it sits on a white panel in both themes.
6
+
7
+ CROPPED AT REST, WHOLE IN USE. From 640px up the wrapper shows only the
8
+ "Select an appointment time" box: Google's header above it and its credit
9
+ lines below are clipped (measured in the frame at 640-862px wide: the box
10
+ spans 211-613px of a 732px page). The crop cannot stay on, because the form
11
+ that opens when a slot is picked is a dialog centred in the frame's FULL
12
+ height (93-640px), so a cropped frame cuts off its title and its Book
13
+ button. A cross-origin frame reports no clicks, but the parent window does
14
+ lose focus to it; on that signal the wrapper opens to the full frame.
15
+ Below 640px Google stacks the month above the slots and nothing is cropped.
16
+ Those numbers are Google's layout, measured 2026-09-30; `crop: false` drops
17
+ the crop if that layout moves.
18
+
19
+ THE SRC IS DEFERRED, and not with loading="lazy". The frame is a third
20
+ party, and a frame that starts loading before the window's `load` event
21
+ holds that event open for as long as Google takes to answer. So the URL
22
+ waits in data-src and the script in studio/booking/_assets assigns it only
23
+ AFTER `load`, once the frame is near the viewport.
24
+
25
+ WITH SCRIPTS OFF nothing ever assigns the src, so the <noscript> hides the
26
+ empty frame and puts a plain link to Google's booking page in its place. %>
27
+ <%= studio_booking_assets %>
28
+ <div class="booking-frame<%= " booking-frame-cropped" if crop %>" data-booking-wrap data-studio-booking>
29
+ <iframe data-booking-frame data-studio-booking
30
+ data-src="<%= studio_booking_embed_url %>"
31
+ title="<%= title %>"
32
+ width="100%" frameborder="0"></iframe>
33
+ <noscript>
34
+ <style>.booking-frame { height: auto !important; } .booking-frame iframe { display: none !important; }</style>
35
+ <p class="booking-frame-noscript"><a href="<%= Studio.booking_url %>" target="_blank" rel="noopener">Open the booking page to pick a time</a></p>
36
+ </noscript>
37
+ </div>
38
+ <p class="booking-frame-note">
39
+ Scheduling by Google Calendar. Trouble seeing it?
40
+ <a href="<%= Studio.booking_url %>" target="_blank" rel="noopener">Open the booking page</a>.
41
+ </p>
@@ -0,0 +1,34 @@
1
+ <%# The booking popup: Google's appointment page in a dialog, opened by any
2
+ a[data-booking-popup] link on the page (studio/booking/_assets carries the
3
+ script). Rendered once per page by `studio_booking_popup`; the site footer
4
+ calls it.
5
+
6
+ It does what Google's own scheduling-button script does, without loading
7
+ that script, its stylesheet and its icon font on every public page: the
8
+ frame is requested only when the dialog first opens. The links keep their
9
+ own href, so with scripts off, or on a modified click, they are ordinary
10
+ links to the booking page.
11
+
12
+ A NATIVE <dialog>, NOT THE MODAL HOST (studio/modals/_host), on purpose. The
13
+ host needs Alpine, its store, and each modal registered inside the host's
14
+ block in the layout, so the footer would stop being one layout line and an
15
+ app with no host would have no popup. Its card is padded and scrolls, where
16
+ this body is a full-bleed frame. And it mounts content through
17
+ <template x-if>, which would build a new frame, and ask Google again, on
18
+ every open; this dialog keeps the loaded one. showModal() gives the top
19
+ layer, the inert page and the focus trap without any of that.
20
+
21
+ ESCAPE HAS A LIMIT NOTHING HERE CAN LIFT. Once focus is inside Google's
22
+ frame, key presses go to Google (it is another origin), so Escape no longer
23
+ reaches the dialog. The Close button and a click on the backdrop always
24
+ work, which is why the button is a solid one. %>
25
+ <%= studio_booking_assets %>
26
+ <dialog class="booking-popup" data-booking-dialog data-studio-booking aria-label="<%= label %>">
27
+ <form method="dialog" class="booking-popup-bar">
28
+ <span class="booking-popup-title"><%= label %></span>
29
+ <button type="submit" class="booking-popup-close" data-booking-close>Close ✕</button>
30
+ </form>
31
+ <iframe data-booking-popup-frame
32
+ data-src="<%= studio_booking_embed_url %>"
33
+ title="<%= title %>" frameborder="0"></iframe>
34
+ </dialog>
@@ -0,0 +1,20 @@
1
+ <%# /schedule — the booking page (Studio::BookingsController), drawn by
2
+ Studio.draw_booking_routes. It is where a booking link lands when the popup
3
+ cannot open. An app that wants different words around the frame renders
4
+ `studio_booking_frame` in a view of its own instead. %>
5
+ <% label = studio_booking_label %>
6
+ <% content_for(:title, "#{label} · #{studio_site_footer_name}") %>
7
+ <% content_for(:full_width, true) %>
8
+
9
+ <section class="booking-page" data-booking-page>
10
+ <h1 class="booking-page-title"><%= label %></h1>
11
+ <p class="booking-page-lede">Pick a time that works and it goes straight on the calendar.</p>
12
+ <%= studio_booking_frame %>
13
+ </section>
14
+
15
+ <style>
16
+ .booking-page { max-width: 56rem; margin-inline: auto; padding: 4rem 1rem; }
17
+ .booking-page-title { margin: 0; text-align: center; font-size: 2.25rem; font-weight: 800; letter-spacing: -.025em;
18
+ color: var(--color-text, inherit); }
19
+ .booking-page-lede { margin: .75rem 0 2rem; text-align: center; font-size: 1.125rem; color: var(--color-text-secondary, inherit); }
20
+ </style>
@@ -0,0 +1,209 @@
1
+ <%# The site footer's styles and its map mount. Rendered once per page, by
2
+ `studio_site_footer_assets` (the footer and the map partial both ask).
3
+
4
+ SCOPED CSS, NOT UTILITIES. Everything the footer needs to lay out is here,
5
+ reading the theme's custom properties with a fallback beside each, so it
6
+ renders the same in an app whose Tailwind build has never seen these views. %>
7
+ <style>
8
+ .ftr { --ftr-primary: var(--color-primary, #8b5cf6); --ftr-primary-rgb: var(--color-primary-500-rgb, 139 92 246);
9
+ --ftr-line: var(--color-border, rgb(127 127 127 / .25)); --ftr-ink: var(--color-text, inherit);
10
+ background: var(--color-surface-alt, transparent); color: var(--color-text-body, inherit);
11
+ border-top: 1px solid var(--ftr-line); }
12
+ .ftr a { transition: color .15s ease, opacity .15s ease; }
13
+ .ftr-wrap { max-width: 72rem; margin-inline: auto; padding-inline: 1rem; }
14
+ .ftr-link { color: inherit; opacity: .78; text-decoration: none; overflow-wrap: anywhere; }
15
+ .ftr-link-disabled { opacity: .38; cursor: not-allowed; }
16
+ .ftr-link-plain { opacity: .78; }
17
+ .ftr-link:hover, .ftr-link:focus-visible { opacity: 1; color: var(--ftr-primary); }
18
+
19
+ /* Brand, then the link columns. Two tracks on a phone with the brand across
20
+ both; from 768px the links sit in one row (at most four across); from
21
+ 1024px the brand joins that row. --ftr-n is the number of link columns. */
22
+ .ftr-cols { display: grid; gap: 3rem 2rem; padding-block: 4rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
23
+ .ftr-brand { grid-column: 1 / -1; }
24
+ @media (min-width: 768px) { .ftr-cols { grid-template-columns: repeat(var(--ftr-n-md, 4), minmax(0, 1fr)); } }
25
+ @media (min-width: 1024px) {
26
+ .ftr-cols { grid-template-columns: minmax(0, 1.7fr) repeat(var(--ftr-n, 4), minmax(0, 1fr)); }
27
+ .ftr-brand { grid-column: auto; }
28
+ }
29
+ .ftr-home { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
30
+ .ftr-logo { width: 3rem; height: 3rem; object-fit: contain; }
31
+ /* A dark mark on a light page: inverted in light mode, as drawn in dark. */
32
+ .ftr-logo-invert { filter: invert(1); }
33
+ .dark .ftr-logo-invert { filter: none; }
34
+ .ftr-wordmark { font-size: 1.5rem; font-weight: 800; line-height: 1.25; letter-spacing: .14em;
35
+ text-transform: uppercase; color: var(--ftr-ink); }
36
+ .ftr-wordmark span { display: block; }
37
+ .ftr-wordmark-accent { color: var(--ftr-primary); }
38
+ .ftr-tagline { margin: 1.5rem 0 0; line-height: 1.625; color: var(--color-text-secondary, inherit); }
39
+ .ftr-email { margin: .75rem 0 0; }
40
+ .ftr-socials { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 2rem 0 0; padding: 0; list-style: none; }
41
+ .ftr-social { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem;
42
+ border-radius: 9999px; background: var(--ftr-primary); color: #fff; transition: transform .15s ease, filter .15s ease; }
43
+ a.ftr-social:hover { transform: translateY(-2px); filter: brightness(1.12); }
44
+ .ftr-social[data-pending] { background: transparent; color: inherit; opacity: .5; border: 1px dashed currentColor; }
45
+ .ftr-social-letter { font-weight: 700; font-size: .95rem; line-height: 1; }
46
+ .ftr-heading { margin: 0 0 1rem; font-size: 1rem; font-weight: 700; color: var(--ftr-ink); }
47
+ .ftr-list { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
48
+
49
+ .ftr-location { border-top: 1px solid var(--ftr-line); padding-block: 3.5rem 2rem; text-align: center; }
50
+ .ftr-location-title { margin: 0; font-size: 1.875rem; font-weight: 800; letter-spacing: -.025em; color: var(--ftr-ink); }
51
+ .ftr-address { margin-top: 1rem; font-style: normal; line-height: 1.625; }
52
+ .ftr-legal { padding-block: 2rem; text-align: center; font-size: .875rem; }
53
+ .ftr-legal p { margin: 0; }
54
+ .ftr-legal .ftr-copyright { margin-top: .5rem; color: var(--color-text-muted, inherit); }
55
+ /* With no map between them, a rule separates the legal line from what is above. */
56
+ .ftr-legal-ruled { border-top: 1px solid var(--ftr-line); }
57
+
58
+ /* The map. isolation keeps Leaflet's internal z-indexes (up to 1000) under
59
+ the pinned navbar and every modal. It reads the same properties outside
60
+ the footer, where .ftr has not set them. */
61
+ .ftr-map { position: relative; isolation: isolate; overflow: hidden;
62
+ background: rgb(var(--ftr-primary-rgb, var(--color-primary-500-rgb, 139 92 246)) / .08); }
63
+ /* One keyless basemap for both themes: in dark mode the light tiles are
64
+ inverted and pulled toward the site's violet rather than swapped. */
65
+ .dark .ftr-map .leaflet-tile-pane { filter: invert(1) hue-rotate(205deg) saturate(.55) brightness(.9) contrast(.92); }
66
+ .ftr-map-wide { width: 100%; height: clamp(16rem, 26vw, 26rem);
67
+ border-block: 1px solid var(--ftr-line, var(--color-border, rgb(127 127 127 / .25))); }
68
+ .ftr-map-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
69
+ padding: 1rem; text-align: center; font-size: .85rem; color: inherit; }
70
+ /* Leaflet puts .leaflet-container on the [data-footer-map] element ITSELF, so
71
+ this is a compound selector, not a descendant one. It keeps the tint behind
72
+ the tiles (Leaflet's own is #ddd) and the page's font in the controls. */
73
+ .ftr-map.leaflet-container { background: rgb(var(--ftr-primary-rgb, var(--color-primary-500-rgb, 139 92 246)) / .08); font: inherit; }
74
+ .ftr-map .leaflet-control-attribution { font-size: 9px; background: rgb(0 0 0 / .45); color: #ddd; }
75
+ .ftr-map .leaflet-control-attribution a { color: #fff; }
76
+ .ftr-map .leaflet-bar a { background: var(--color-surface, #fff); color: var(--color-text, #111); border-color: rgb(127 127 127 / .3); }
77
+ .ftr-pin { position: relative; width: 18px; height: 18px; }
78
+ .ftr-pin::before, .ftr-pin::after { content: ""; position: absolute; inset: 0; border-radius: 9999px;
79
+ background: var(--ftr-primary, var(--color-primary, #8b5cf6)); }
80
+ .ftr-pin::before { animation: ftr-ping 2.2s cubic-bezier(0, 0, .2, 1) infinite; opacity: .6; }
81
+ .ftr-pin::after { border: 3px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .45); }
82
+ @keyframes ftr-ping { 75%, 100% { transform: scale(3.2); opacity: 0; } }
83
+ @media (prefers-reduced-motion: reduce) { .ftr-pin::before { animation: none; } .ftr a, .ftr-social { transition: none; } }
84
+ </style>
85
+
86
+ <script>
87
+ // Mounts a Leaflet map on every [data-footer-map]. Leaflet (script and
88
+ // stylesheet) is fetched once, on demand, from the URLs the element carries,
89
+ // so a page with no map pays nothing for it. The basemap follows the site
90
+ // theme in CSS (see .dark .leaflet-tile-pane above). Tiles are OpenStreetMap's
91
+ // keyless ones; a basemap that needs an API key does not belong in a gem.
92
+ //
93
+ // NOTHING STARTS BEFORE THE WINDOW'S `load`, AND NOTHING UNTIL THE MAP IS NEAR
94
+ // THE VIEWPORT. The tiles are a third party's, and a request that starts
95
+ // before `load` holds that event open for as long as the third party takes to
96
+ // answer. The map is also at the bottom of every public page, where most
97
+ // visits never reach: those pay for neither Leaflet nor a single tile.
98
+ //
99
+ // THE GUARD IS THE ENGINE'S OWN NAME, AND THE ELEMENTS ARE THE ENGINE'S OWN. An
100
+ // app that still renders a local footer script (mcritchie-studio, until it
101
+ // adopts this one) guards it with the unprefixed name and marks its map
102
+ // [data-footer-map] too. Sharing either would let whichever script ran first
103
+ // in a Turbo session stand the other down and then fail on its elements: that
104
+ // app's map carries no data-leaflet-js, so there is nothing here to fetch.
105
+ (function () {
106
+ if (window.__studioFooterMapsArmed) return;
107
+ window.__studioFooterMapsArmed = true;
108
+
109
+ var TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
110
+ var ATTRIBUTION = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>';
111
+ var maps = [];
112
+ var loading = null;
113
+
114
+ // Checked on every mount, not once: a page visit that rebuilds the head
115
+ // must not leave a mounted map without its stylesheet.
116
+ function ensureStylesheet(href) {
117
+ if (!href || document.querySelector('link[data-studio-leaflet]')) return;
118
+ var link = document.createElement('link');
119
+ link.rel = 'stylesheet';
120
+ link.href = href;
121
+ link.setAttribute('data-studio-leaflet', '');
122
+ document.head.appendChild(link);
123
+ }
124
+
125
+ function loadLeaflet(src) {
126
+ if (window.L) return Promise.resolve();
127
+ if (loading) return loading;
128
+ loading = new Promise(function (resolve, reject) {
129
+ var s = document.createElement('script');
130
+ s.src = src;
131
+ s.onload = resolve;
132
+ // A failed fetch must not be remembered: the next visit tries again.
133
+ s.onerror = function () { loading = null; s.remove(); reject(new Error('leaflet failed to load')); };
134
+ document.head.appendChild(s);
135
+ });
136
+ return loading;
137
+ }
138
+
139
+ function mount(el) {
140
+ if (el.__footerMap) return;
141
+ var at = [parseFloat(el.dataset.lat), parseFloat(el.dataset.lng)];
142
+ if (isNaN(at[0]) || isNaN(at[1])) return;
143
+ // NO ONE-FINGER DRAG ON A TOUCH DEVICE. The map runs edge to edge, so on a
144
+ // phone a swipe that starts on it would pan the map instead of scrolling
145
+ // the page, and there is no gutter to scroll by. With dragging off Leaflet
146
+ // leaves touch-action at pan-x pan-y: one finger scrolls the page, and a
147
+ // pinch still zooms the map (touchZoom stays on, and moves it under the
148
+ // fingers). The zoom buttons and the directions link do the rest.
149
+ var map = L.map(el, { center: at, zoom: parseInt(el.dataset.zoom, 10) || 15,
150
+ scrollWheelZoom: false, attributionControl: true,
151
+ dragging: !L.Browser.mobile, touchZoom: true,
152
+ zoomControl: el.dataset.controls !== 'false' });
153
+ map.attributionControl.setPrefix(false);
154
+ L.tileLayer(TILES, { attribution: ATTRIBUTION, maxZoom: 19 }).addTo(map);
155
+ L.marker(at, { icon: L.divIcon({ className: '', html: '<div class="ftr-pin"></div>', iconSize: [18, 18], iconAnchor: [9, 9] }),
156
+ keyboard: false }).addTo(map);
157
+ // Page scroll stays page scroll until the visitor commits to the map.
158
+ map.on('click', function () { map.scrollWheelZoom.enable(); });
159
+ map.on('mouseout', function () { map.scrollWheelZoom.disable(); });
160
+ var fallback = el.querySelector('.ftr-map-fallback');
161
+ if (fallback) { el.__footerFallback = fallback; fallback.remove(); }
162
+ el.__footerMap = map;
163
+ maps.push(el);
164
+ }
165
+
166
+ function fetchAndMount(el) {
167
+ ensureStylesheet(el.dataset.leafletCss);
168
+ loadLeaflet(el.dataset.leafletJs)
169
+ .then(function () { if (el.isConnected) mount(el); })
170
+ .catch(function () { /* the fallback link stays */ });
171
+ }
172
+
173
+ // One observer per map: it fires once, when the map comes within 400px of
174
+ // the viewport, and is then dropped.
175
+ function watch(el) {
176
+ if (el.__footerMap || el.__footerWatch) return;
177
+ if (typeof IntersectionObserver !== 'function') { fetchAndMount(el); return; }
178
+ var watcher = new IntersectionObserver(function (entries) {
179
+ if (!entries.some(function (entry) { return entry.isIntersecting; })) return;
180
+ watcher.disconnect();
181
+ el.__footerWatch = null;
182
+ fetchAndMount(el);
183
+ }, { rootMargin: '400px' });
184
+ el.__footerWatch = watcher;
185
+ watcher.observe(el);
186
+ }
187
+
188
+ function armAll() { document.querySelectorAll('[data-footer-map][data-leaflet-js]').forEach(watch); }
189
+
190
+ function armAfterLoad() {
191
+ if (document.readyState === 'complete') armAll();
192
+ else window.addEventListener('load', armAll, { once: true });
193
+ }
194
+
195
+ // A cached Turbo snapshot would restore Leaflet's DOM without its state, so
196
+ // the map is taken down and its fallback link put back before the snapshot.
197
+ document.addEventListener('turbo:before-cache', function () {
198
+ maps.forEach(function (el) {
199
+ var fallback = el.__footerFallback;
200
+ el.__footerMap.remove();
201
+ el.__footerMap = null;
202
+ if (fallback && !el.querySelector('.ftr-map-fallback')) el.appendChild(fallback);
203
+ });
204
+ maps = [];
205
+ });
206
+ document.addEventListener('turbo:load', armAfterLoad);
207
+ armAfterLoad();
208
+ })();
209
+ </script>