diff --git a/imports/ui/components/Navigation/Navigation.js b/imports/ui/components/Navigation/Navigation.js index 36ecdb9..569bb5e 100644 --- a/imports/ui/components/Navigation/Navigation.js +++ b/imports/ui/components/Navigation/Navigation.js @@ -9,17 +9,36 @@ import { translate } from 'react-i18next'; import './Navigation.scss'; const Navigation = props => ( - - - - {props.t('AppName')} - - - - - {!props.authenticated ? : } - - + + + ); Navigation.defaultProps = { diff --git a/imports/ui/pages/Index/Index.js b/imports/ui/pages/Index/Index.js index 517041b..5cd1792 100644 --- a/imports/ui/pages/Index/Index.js +++ b/imports/ui/pages/Index/Index.js @@ -1,16 +1,58 @@ -import React from 'react'; +import React, {Component} from 'react'; import { Button } from 'react-bootstrap'; 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-custom.scss'; -const Index = (props) => { - const { t } = props; - return ( +class Index extends Component { + // Debounce by David Walsch + // 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 (
{/* https://v4-alpha.getbootstrap.com/components/carousel/ */}
+
  1. @@ -66,7 +108,7 @@ const Index = (props) => {
    -

    {props.t('AppName')}

    +

    {this.props.t('AppName')}

    Siempre alerta a los fuegos en nuestro vecindario

    @@ -74,46 +116,7 @@ const Index = (props) => {
); -}; - -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); diff --git a/package.json b/package.json index 6e260fd..5a6dda7 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "react-bootstrap": "^0.31.2", "react-dom": "^15.6.1", "react-i18next": "^6.1.0", + "react-resize-detector": "^1.1.0", "react-router-bootstrap": "^0.24.3", "react-router-dom": "^4.2.2", "reactstrap": "^5.0.0-alpha.3",