Improved navigation
This commit is contained in:
parent
60fcd48140
commit
6a6015ae4d
3 changed files with 79 additions and 56 deletions
|
|
@ -9,17 +9,36 @@ import { translate } from 'react-i18next';
|
||||||
import './Navigation.scss';
|
import './Navigation.scss';
|
||||||
|
|
||||||
const Navigation = props => (
|
const Navigation = props => (
|
||||||
<Navbar>
|
<ul className="nav justify-content-end">
|
||||||
<Navbar.Header>
|
<li className="nav-item">
|
||||||
<Navbar.Brand>
|
<a className="nav-link active" href="/#">{props.t('Inicio')}</a>
|
||||||
<Link to="/">{props.t('AppName')}</Link>
|
</li>
|
||||||
</Navbar.Brand>
|
<li className="nav-item">
|
||||||
<Navbar.Toggle />
|
<a className="nav-link" href="#">{props.t('Mapa actual')}</a>
|
||||||
</Navbar.Header>
|
</li>
|
||||||
<Navbar.Collapse>
|
<li className="nav-item">
|
||||||
{!props.authenticated ? <PublicNavigation /> : <AuthenticatedNavigation {...props} />}
|
<a className="nav-link" href="#">{props.t('Contacto')}</a>
|
||||||
</Navbar.Collapse>
|
</li>
|
||||||
</Navbar>
|
<li className="nav-item">
|
||||||
|
<a className="nav-link" href="#">{props.t('Contacto')}</a>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item">
|
||||||
|
{!props.authenticated ? <PublicNavigation /> : <AuthenticatedNavigation {...props} />}
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li className="nav-item dropdown">
|
||||||
|
<a className="nav-item nav-link dropdown-toggle mr-md-2" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
{props.t('Más')}
|
||||||
|
<div className="ripple-container"></div>
|
||||||
|
</a>
|
||||||
|
<div className="dropdown-menu dropdown-menu-right" aria-labelledby="bd-versions">
|
||||||
|
<a className="dropdown-item active" href="/bootstrap-material-design/docs/4.0/">Latest (4.x)</a>
|
||||||
|
<a className="dropdown-item" href="https://cdn.rawgit.com/FezVrasta/bootstrap-material-design/gh-pages-v3/index.html">v3.x</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Navigation.defaultProps = {
|
Navigation.defaultProps = {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,58 @@
|
||||||
import React from 'react';
|
import React, {Component} from 'react';
|
||||||
import { Button } from 'react-bootstrap';
|
import { Button } from 'react-bootstrap';
|
||||||
import { translate } from 'react-i18next';
|
import { translate } from 'react-i18next';
|
||||||
|
import {render} from 'react-dom';
|
||||||
|
|
||||||
|
// https://www.npmjs.com/package/react-resize-detector
|
||||||
|
import ReactResizeDetector from 'react-resize-detector';
|
||||||
|
|
||||||
import './Index.scss';
|
import './Index.scss';
|
||||||
import './Index-custom.scss';
|
import './Index-custom.scss';
|
||||||
|
|
||||||
const Index = (props) => {
|
class Index extends Component {
|
||||||
const { t } = props;
|
// Debounce by David Walsch
|
||||||
return (
|
// https://davidwalsh.name/javascript-debounce-function
|
||||||
|
|
||||||
|
debounce = (func, wait, immediate) => {
|
||||||
|
var timeout;
|
||||||
|
return function() {
|
||||||
|
var context = this, args = arguments;
|
||||||
|
var later = function() {
|
||||||
|
timeout = null;
|
||||||
|
if (!immediate) func.apply(context, args);
|
||||||
|
};
|
||||||
|
var callNow = immediate && !timeout;
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(later, wait);
|
||||||
|
if (callNow) func.apply(context, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
scaleHeader = () => {
|
||||||
|
var scalable = document.getElementById('tcefh1');
|
||||||
|
var margin = 10;
|
||||||
|
var scalableContainer = scalable.parentNode;
|
||||||
|
scalable.style.transform = 'scale(1)';
|
||||||
|
var scalableContainerWidth = scalableContainer.offsetWidth - margin;
|
||||||
|
var scalableWidth = scalable.offsetWidth;
|
||||||
|
scalable.style.transform = 'scale(' + scalableContainerWidth / scalableWidth + ')';
|
||||||
|
scalableContainer.style.height = scalable.getBoundingClientRect().height + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
|
myScaleFunction = this.debounce(() => {
|
||||||
|
this.scaleHeader();
|
||||||
|
}, 250);
|
||||||
|
|
||||||
|
_onResize = () => {
|
||||||
|
this.myScaleFunction();
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
<div className="IndexDisabled">
|
<div className="IndexDisabled">
|
||||||
{/* https://v4-alpha.getbootstrap.com/components/carousel/ */}
|
{/* https://v4-alpha.getbootstrap.com/components/carousel/ */}
|
||||||
<header>
|
<header>
|
||||||
|
<ReactResizeDetector handleWidth handleHeight onResize={this._onResize} />
|
||||||
<div id="carouselExampleIndicators" className="carousel slide" data-ride="carousel">
|
<div id="carouselExampleIndicators" className="carousel slide" data-ride="carousel">
|
||||||
<ol className="carousel-indicators">
|
<ol className="carousel-indicators">
|
||||||
<li data-target="#carouselExampleIndicators" data-slide-to="0" className="active"></li>
|
<li data-target="#carouselExampleIndicators" data-slide-to="0" className="active"></li>
|
||||||
|
|
@ -66,7 +108,7 @@ const Index = (props) => {
|
||||||
<section className="py-5">
|
<section className="py-5">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="scale__container--js">
|
<div className="scale__container--js">
|
||||||
<h1 className="scale--js">{props.t('AppName')}</h1>
|
<h1 id="tcefh1" className="scale--js">{this.props.t('AppName')}</h1>
|
||||||
</div>
|
</div>
|
||||||
<p>Siempre alerta a los fuegos en nuestro vecindario</p>
|
<p>Siempre alerta a los fuegos en nuestro vecindario</p>
|
||||||
<button type="button" className="btn btn-raised btn-lg btn-warning">PARTICIPA</button>
|
<button type="button" className="btn btn-raised btn-lg btn-warning">PARTICIPA</button>
|
||||||
|
|
@ -74,46 +116,7 @@ const Index = (props) => {
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function scaleHeader() {
|
|
||||||
var scalable = document.querySelectorAll('.scale--js');
|
|
||||||
var margin = 10;
|
|
||||||
for (var i = 0; i < scalable.length; i++) {
|
|
||||||
var scalableContainer = scalable[i].parentNode;
|
|
||||||
scalable[i].style.transform = 'scale(1)';
|
|
||||||
var scalableContainerWidth = scalableContainer.offsetWidth - margin;
|
|
||||||
var scalableWidth = scalable[i].offsetWidth;
|
|
||||||
scalable[i].style.transform = 'scale(' + scalableContainerWidth / scalableWidth + ')';
|
|
||||||
scalableContainer.style.height = scalable[i].getBoundingClientRect().height + 'px';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Debounce by David Walsch
|
|
||||||
// https://davidwalsh.name/javascript-debounce-function
|
|
||||||
|
|
||||||
function debounce(func, wait, immediate) {
|
|
||||||
var timeout;
|
|
||||||
return function() {
|
|
||||||
var context = this, args = arguments;
|
|
||||||
var later = function() {
|
|
||||||
timeout = null;
|
|
||||||
if (!immediate) func.apply(context, args);
|
|
||||||
};
|
|
||||||
var callNow = immediate && !timeout;
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = setTimeout(later, wait);
|
|
||||||
if (callNow) func.apply(context, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var myScaleFunction = debounce(function() {
|
|
||||||
scaleHeader();
|
|
||||||
}, 250);
|
|
||||||
|
|
||||||
myScaleFunction();
|
|
||||||
|
|
||||||
window.addEventListener('resize', myScaleFunction);
|
|
||||||
|
|
||||||
export default translate([], { wait: true })(Index);
|
export default translate([], { wait: true })(Index);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
"react-bootstrap": "^0.31.2",
|
"react-bootstrap": "^0.31.2",
|
||||||
"react-dom": "^15.6.1",
|
"react-dom": "^15.6.1",
|
||||||
"react-i18next": "^6.1.0",
|
"react-i18next": "^6.1.0",
|
||||||
|
"react-resize-detector": "^1.1.0",
|
||||||
"react-router-bootstrap": "^0.24.3",
|
"react-router-bootstrap": "^0.24.3",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router-dom": "^4.2.2",
|
||||||
"reactstrap": "^5.0.0-alpha.3",
|
"reactstrap": "^5.0.0-alpha.3",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue