// Shared chrome — Header, Footer, WhatsApp float, router hook // Loaded as text/babel. const WHATSAPP_URL = 'https://wa.me/5511999905029?text=Ol%C3%A1!%20Gostaria%20de%20um%20or%C3%A7amento.'; // Clean-URL routing (History API). Legacy #/ URLs are rewritten to paths in index.html. function currentPath() { return window.FaukoSEO.route(); } function useHashRoute() { const [route, setRoute] = React.useState(currentPath()); React.useEffect(() => { const onNav = () => setRoute(currentPath()); window.addEventListener('popstate', onNav); window.addEventListener('fauko:route', onNav); return () => { window.removeEventListener('popstate', onNav); window.removeEventListener('fauko:route', onNav); }; }, []); return route; } function navigate(path) { if (currentPath() !== path) { window.history.pushState(null, '', window.FaukoSEO.href(path)); window.dispatchEvent(new Event('fauko:route')); window.scrollTo({ top: 0, behavior: 'instant' }); } } function Link({ to, children, className, onClick, ...rest }) { return ( { // let the browser handle new-tab / new-window clicks if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return; e.preventDefault(); navigate(to); onClick && onClick(e); }} {...rest} > {children} ); } const NAV_ITEMS = [ { to: '/', label: 'Home' }, { to: '/produtos', label: 'Produtos' }, { to: '/quem-somos', label: 'Quem Somos' }, ]; function Header() { const route = useHashRoute(); const [open, setOpen] = React.useState(false); const isActive = (to) => { if (to === '/') return route === '/' || route === ''; return route.startsWith(to); }; return (
Fauko Import
Orçamento
setOpen(false)} isActive={isActive} />
); } function MobileMenu({ open, onClose, isActive }) { return (
Fauko
{NAV_ITEMS.map(item => ( {item.label} ))} Falar no WhatsApp
Av. Padre Arlindo Vieira, 213 - 12
Vila Vermelha, São Paulo - SP
); } function Footer() { return ( ); } function WhatsIcon() { return ( ); } function WhatsFloat() { return ( ); } // Scroll to top on route change function ScrollToTop() { const route = useHashRoute(); React.useEffect(() => { window.scrollTo({ top: 0, behavior: 'instant' }); }, [route]); return null; } // Spec value formatter: "70.0" → "70", "1.5" → "1.5", "1/3 HP" / "110/220" / texts pass through untouched. function formatSpec(v) { if (v == null) return v; const s = String(v).trim(); return /^-?\d+([.,]\d+)?$/.test(s) ? String(parseFloat(s.replace(',', '.'))) : v; } // Split a "combustível compatível" field into clean, capitalized chips. // Collapses newlines, keeps parenthetical qualifiers attached to their term // (e.g. "Solventes (sob consulta)") and never splits on " e " inside parentheses. function parseFluids(raw) { if (!raw) return []; let s = String(raw).replace(/\s+/g, ' ').replace(/\s*\(/g, ' (').trim(); const held = []; s = s.replace(/\([^)]*\)/g, m => { held.push(m); return '\u0000' + (held.length - 1) + '\u0000'; }); return s.split(/[,;·]|\se\s/i) .map(t => t.replace(/\u0000(\d+)\u0000/g, (_, i) => held[+i]).trim()) .map(t => t.replace(/^[.–-]+|[.]+$/g, '').trim()) .filter(t => t && t !== '(' && t.length > 1) .map(t => t.charAt(0).toUpperCase() + t.slice(1)); } window.FaukoChrome = { Header, Footer, WhatsFloat, Link, navigate, useHashRoute, ScrollToTop, WhatsIcon, WHATSAPP_URL, formatSpec, parseFluids };