todos-contra-el-fuego-web/imports/ui/components/Navigation/Navigation.js
vjrj bddfb392c1 bootstrap: swap BS4 (alexwine) CSS for bootstrap@5 npm
Completes the Bootstrap 4->5 migration now that every jQuery/BS4 widget is React
(navbar, carousel, dropdowns) — plus the feedback toggle here (Feedback.js:
global `$('#feedback-form').toggle()` -> React state).

- Load Bootstrap 5 CSS from the `bootstrap` npm package in client/index.js
  (imported first so app + component styles and react-bootstrap override it).
- Remove the `alexwine:bootstrap-4` meteor package (BS4 CSS + jQuery + BS4 JS).
  jQuery for jquery-validation still comes from the npm `jquery` dep.
- Utility renames to BS5: ml-auto->ms-auto, float-right->float-end,
  btn-block->w-100, data-toggle->data-bs-toggle (FromNow tooltip).
- forms.scss `.form-label` is no longer a shim (BS5 ships it); comment updated.

Full-app build boots clean; server suite 36 passing. Needs a visual staging pass
across all pages (BS4->5 shifts grid gutters/typography); forms should improve
since react-bootstrap v2 already emitted BS5 markup.
2026-07-22 05:55:34 +02:00

69 lines
3.4 KiB
JavaScript

/* eslint-disable import/no-absolute-path */
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { LinkContainer } from 'react-router-bootstrap';
import { Trans, withTranslation } from 'react-i18next';
import { testId } from '/imports/ui/components/Utils/TestUtils';
/* import BetaRibbon from '../../components/BetaRibbon/BetaRibbon'; */
import PublicNavigation from '../PublicNavigation/PublicNavigation';
import AuthenticatedNavigation from '../AuthenticatedNavigation/AuthenticatedNavigation';
import NavItem from '../NavItem/NavItem';
import './Navigation.scss';
// removed class: fixed-top
// md instead of lg: no menu in medium
//
// Bootstrap 4→5 prep: the collapse used to be driven by Bootstrap's jQuery JS
// (`data-toggle="collapse"`), which goes away when we drop `alexwine:bootstrap-4`
// for `bootstrap@5`. Toggling the `.show` class from React state removes that
// dependency and keeps working on the current BS4 CSS (`.collapse.show` is pure
// CSS; jQuery only added the height animation). Clicking a nav link collapses the
// mobile menu again — the old per-NavItem `data-target=".navbar-collapse.show"`.
const Navigation = ({ name = '', ...props }) => {
const [open, setOpen] = React.useState(false);
const close = () => setOpen(false);
return (
<nav className="navbar navbar-expand-lg navbar-dark bg-dark">
<div style={{ overflow: 'hidden' } /* for ribbon */} className="container">
{/* <BetaRibbon /> */}
<Link to="/" className={`navbar-brand ${window.location.pathname === '/' ? 'hide-brand' : ''}`} >
{props.t('AppNameFull')}
</Link>
<button className="navbar-toggler" type="button" onClick={() => setOpen(o => !o)} aria-controls="navbarNavDropdown" aria-expanded={open} aria-label="Toggle navigation">
<span className="navbar-toggler-icon" />
</button>
<div className={`collapse navbar-collapse${open ? ' show' : ''}`} id="navbarNavDropdown">
{/* onClick closes the mobile menu when a main nav link is tapped */}
<ul className="navbar-nav ms-auto " onClick={close}>
{/* <LinkContainer className="nav-item" anchorClassName="nav-link" to="/sandbox">
<NavItem eventKey={1.1} href="/sandbox">Sandbox</NavItem>
</LinkContainer> */}
<LinkContainer id={testId('subscriptions')} className="nav-item" anchorClassName="nav-link" to="/subscriptions">
<NavItem eventKey={1.2} href="/subscriptions">
{props.authenticated ? <Trans>Mis zonas</Trans> : <Trans>Participar</Trans>}
</NavItem>
</LinkContainer>
<LinkContainer id={testId('moniZones')} className="nav-item" anchorClassName="nav-link" to="/zones">
<NavItem eventKey={2} href="/zones">{props.t('Zonas vigiladas')}</NavItem>
</LinkContainer>
<LinkContainer id={testId('activeFires')} className="nav-item" anchorClassName="nav-link" to="/fires">
<NavItem eventKey={2.1} href="/fires">{props.t('activeFires')}</NavItem>
</LinkContainer>
</ul>
{!props.authenticated ? <PublicNavigation /> : <AuthenticatedNavigation name={name} {...props} />}
</div>
</div>
</nav>
);
};
Navigation.propTypes = {
t: PropTypes.func.isRequired,
authenticated: PropTypes.bool.isRequired
};
export default withTranslation()(Navigation);