- The callback dialog switches its copy outside business hours (shared/business-hours.ts); such leads get a "нерабочее время" tag, a marker in the deal name and a line in the note in amoCRM. - utm_*, yclid and gclid are read on page load and kept for 30 days (src/lib/attribution.ts), last tagged visit wins, and are sent with every lead. - The callback dialog is rebuilt: focus trap, focus return, phone masking and a full-number check. - fitnes drops the floating MobileCta; header and mobile bars follow the new dialog state in the other three. - Add the latest design mockups under legacy/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
import { useEffect, useState, type MouseEvent } from 'react'
|
|
import { isWithinBusinessHours } from '../../shared/business-hours'
|
|
import { contacts } from '../data/content'
|
|
import { cx } from '../lib/cx'
|
|
import { reportCallClick } from '../lib/lead'
|
|
import { ButtonLink, buttonClass } from './Button'
|
|
import { PhoneIcon } from './Icons'
|
|
|
|
/**
|
|
* The primary CTA's home below 760px, where the header cannot hold it without
|
|
* crushing the logo. See `SiteHeader`.
|
|
*
|
|
* It waits for the hero — whose own two buttons say the same thing — to scroll
|
|
* away, and steps back down while the form is on screen, so it never sits on
|
|
* top of the fields it points at. That also keeps it clear of the submit
|
|
* button, which is the one control it could plausibly be mistaken for.
|
|
*/
|
|
export function MobileActionBar({ onAfterHoursCall }: { onAfterHoursCall: () => void }) {
|
|
const [shown, setShown] = useState(false)
|
|
|
|
// Nobody answers out of hours, so the number opens the callback form instead
|
|
// of the dialler — and is not reported as a call, since none happens.
|
|
const onPhoneClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
|
if (isWithinBusinessHours()) {
|
|
reportCallClick()
|
|
return
|
|
}
|
|
event.preventDefault()
|
|
onAfterHoursCall()
|
|
}
|
|
|
|
useEffect(() => {
|
|
const hero = document.getElementById('top')
|
|
const form = document.getElementById('proposal')
|
|
if (!hero || !form) return
|
|
|
|
let heroOnScreen = true
|
|
let formOnScreen = false
|
|
|
|
const observer = new IntersectionObserver((entries) => {
|
|
for (const entry of entries) {
|
|
if (entry.target === hero) heroOnScreen = entry.isIntersecting
|
|
if (entry.target === form) formOnScreen = entry.isIntersecting
|
|
}
|
|
setShown(!heroOnScreen && !formOnScreen)
|
|
})
|
|
|
|
observer.observe(hero)
|
|
observer.observe(form)
|
|
return () => observer.disconnect()
|
|
}, [])
|
|
|
|
return (
|
|
<div
|
|
/* Not `hidden` when down: it is off-screen, and `inert` already takes it
|
|
out of the tab order, so the slide stays animatable both ways. */
|
|
inert={!shown || undefined}
|
|
className={cx(
|
|
'fixed inset-x-0 bottom-0 z-[55] border-t border-white/[0.1] bg-navy-deep/[0.94] backdrop-blur-[18px] md:hidden',
|
|
'px-[16px] pt-[12px] pb-[max(12px,env(safe-area-inset-bottom))]',
|
|
'transition-transform duration-300 ease-[cubic-bezier(0.2,0.65,0.3,1)]',
|
|
shown ? 'translate-y-0' : 'translate-y-full',
|
|
)}
|
|
>
|
|
<div className="flex items-center gap-[10px]">
|
|
<a
|
|
href={contacts.phoneHref}
|
|
onClick={onPhoneClick}
|
|
aria-label={`Позвонить в Экзо Групп по номеру ${contacts.phone}`}
|
|
className={buttonClass('call', 'shrink-0', 'min-h-[52px] w-[52px] px-0')}
|
|
>
|
|
<PhoneIcon />
|
|
</a>
|
|
<ButtonLink href="#proposal" className="flex-1">
|
|
Получить предложение
|
|
</ButtonLink>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|