Lint fixes

This commit is contained in:
vjrj 2017-12-14 10:14:38 +01:00
parent ccf0716d3e
commit 45c6727bec
3 changed files with 164 additions and 159 deletions

View file

@ -1,13 +1,14 @@
/* eslint-disable import/no-absolute-path */
/* eslint-disable react/jsx-indent-props */
import React from 'react';
import PropTypes from 'prop-types';
import { Row, Col } from 'react-bootstrap';
import { Trans, translate } from 'react-i18next';
import DistanceSlider from '/imports/ui/components/DistanceSlider/DistanceSlider';
import SelectionMap from '/imports/ui/components/SelectionMap/SelectionMap';
import update from 'immutability-helper';
import Gkeys from '/imports/startup/client/Gkeys';
import SubsAutocomplete from './SubsAutocomplete';
import CenterInMyPosition from '/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js';
import SubsAutocomplete from './SubsAutocomplete';
class FireSubscription extends React.Component {
constructor(props) {
@ -18,26 +19,27 @@ class FireSubscription extends React.Component {
// console.log(this.props.location.state);
}
componentDidMount = () => {
Gkeys.load(function (err, key) {
this.setState({ init: true });
}.bind(this));
}
centerOnUserLocation(value) {
this.setState(update(this.state, {$merge: {lat: value.center[0], lng: value.center[1]}}));
componentDidMount() {
const self = this;
Gkeys.load(() => {
self.setState({ init: true });
});
}
onAutocompleteChange(value) {
this.setState(update(this.state, {$merge: {lat: value.lat, lng: value.lng}}));
this.setState({ lat: value.lat, lng: value.lng });
}
onSliderChange(value) {
this.setState(update(this.state, {$merge: {distance: value}}));
this.setState({ distance: value });
}
onSelection(value) {
this.setState(update(this.state, {$merge: {lat: value.lat, lng: value.lng, distance: value.distance}}));
this.setState({ lat: value.lat, lng: value.lng, distance: value.distance });
}
centerOnUserLocation(value) {
this.setState({ lat: value.center[0], lng: value.center[1] });
}
render() {
@ -45,37 +47,37 @@ class FireSubscription extends React.Component {
// https://github.com/kenny-hibino/react-places-autocomplete/blob/master/demo/Demo.js
if (!this.state.init) {
return <div/>
} else {
return (
<div>
<Row>
<Col xs={12} sm={12} md={6} lg={6} >
<div>
<h4 className="page-header"><Trans parent="span">Suscríbete a alertas de fuegos</Trans></h4>
<SubsAutocomplete
focusInput={this.props.focusInput}
onChange={ (value) => this.onAutocompleteChange(value) }/>
</div>
</Col>
<Col xs={12} sm={12} md={6} lg={6} >
<DistanceSlider onChange={(value) => this.onSliderChange(value)} />
<Row className="align-items-center justify-content-center">
<CenterInMyPosition onClick={(viewport) => this.centerOnUserLocation(viewport)} />
</Row>
</Col>
</Row>
<Row className="align-items-center justify-content-center">
<SelectionMap
center={[this.state.lat, this.state.lng]}
distance={this.state.distance}
history={this.props.history}
onSelection={(state) => this.onSelection(state)}
/>
</Row>
</div>
);
return <div />;
}
return (
<div>
<Row>
<Col xs={12} sm={12} md={6} lg={6} >
<div>
<h4 className="page-header"><Trans parent="span">Suscríbete a alertas de fuegos</Trans></h4>
<SubsAutocomplete
focusInput={this.props.focusInput}
onChange={value => this.onAutocompleteChange(value)}
/>
</div>
</Col>
<Col xs={12} sm={12} md={6} lg={6} >
<DistanceSlider onChange={value => this.onSliderChange(value)} />
<Row className="align-items-center justify-content-center">
<CenterInMyPosition onClick={viewport => this.centerOnUserLocation(viewport)} />
</Row>
</Col>
</Row>
<Row className="align-items-center justify-content-center">
<SelectionMap
center={[this.state.lat, this.state.lng]}
distance={this.state.distance}
history={this.props.history}
onSelection={state => this.onSelection(state)}
/>
</Row>
</div>
);
}
}

View file

@ -1,35 +1,36 @@
/* eslint-disable react/jsx-indent-props */
import React from 'react';
import PropTypes from 'prop-types';
import { Trans, translate } from 'react-i18next';
import PlacesAutocomplete, { geocodeByAddress, geocodeByPlaceId, getLatLng } from 'react-places-autocomplete';
import PlacesAutocomplete, { geocodeByAddress, getLatLng } from 'react-places-autocomplete';
import { FormGroup, ControlLabel, HelpBlock } from 'react-bootstrap';
class SubsAutocomplete extends React.Component {
constructor(props) {
super(props);
this.state = {
address: '',
address: ''
};
}
onChange = (address) => { this.setState({ address }); }
onChange(address) { this.setState({ address }); }
handleSelect = (address) => {
handleSelect(address) {
const self = this;
geocodeByAddress(address)
.then((results) => getLatLng(results[0]))
.then(results => getLatLng(results[0]))
.then(({ lat, lng }) => {
// console.log('Success Yay', { lat, lng })
// const newState = update(this.state, {$merge: {lat: lat, lng: lng}});
// console.log(newState);
// this.setState(newState);
self.props.onChange({lat: lat, lng: lng});
self.props.onChange({ lat, lng });
// console.log(this.state);
})
.catch(error => {
.catch((error) => {
console.log(error);
if (error === 'ZERO_RESULTS') {
console.log("No results");
console.log('No results');
}
});
}
@ -43,17 +44,17 @@ class SubsAutocomplete extends React.Component {
backgroundSize: 'auto 12px',
backgroundPosition: 'bottom left 10px',
backgroundRepeat: 'no-repeat',
backgroundImage: "url('https://maps.gstatic.com/mapfiles/api-3/images/powered-by-google-on-white3_hdpi.png')",
},
}
backgroundImage: "url('https://maps.gstatic.com/mapfiles/api-3/images/powered-by-google-on-white3_hdpi.png')"
}
};
// http://simplelineicons.com/
const AutocompleteItem = ({ formattedSuggestion }) => (
<div className="suggestion-item">
<i className="icons icon-location-pin suggestion-icon"/>{' '}
<i className="icons icon-location-pin suggestion-icon" />{' '}
<strong>{formattedSuggestion.mainText}</strong>{' '}
<small className="text-muted">{formattedSuggestion.secondaryText}</small>
</div>)
</div>);
return (
<form>
@ -67,11 +68,12 @@ class SubsAutocomplete extends React.Component {
classNames={{
root: 'form-group',
input: 'form-control',
autocompleteContainer: 'autocomplete-container'}}
autocompleteContainer: 'autocomplete-container'
}}
googleLogo={false}
highlightFirstSuggestion={true}
onSelect={(address) => this.handleSelect(address)}
onEnterKeyDown={(address) => this.handleSelect(address)}
highlightFirstSuggestion
onSelect={address => this.handleSelect(address)}
onEnterKeyDown={address => this.handleSelect(address)}
options={{
// location: new google.maps.LatLng(-34, 151),
// radius: 2000,
@ -81,21 +83,24 @@ class SubsAutocomplete extends React.Component {
inputProps={
{
value: this.state.address,
onChange: (address) => this.onChange(address),
placeholder: this.props.t("Escribe aquí un lugar "),
onBlur:() => { /* console.log('Blur event!'); */ },
onFocus:() => { /* console.log('Focused!'); */ },
onChange: address => this.onChange(address),
placeholder: this.props.t('Escribe aquí un lugar'),
onBlur: () => { /* console.log('Blur event!'); */ },
onFocus: () => { /* console.log('Focused!'); */ },
autoFocus: this.props.focusInput
}} />
}}
/>
<HelpBlock><Trans parent="span">También puedes seleccionar el lugar en el mapa arrastrando el puntero naranja.</Trans></HelpBlock>
</FormGroup>
</form>
)
);
}
}
SubsAutocomplete.propTypes = {
focusInput: PropTypes.bool.isRequired
focusInput: PropTypes.bool.isRequired,
t: PropTypes.func.isRequired,
i18n: PropTypes.object.isRequired
};
export default translate([], { wait: true }) (SubsAutocomplete);
export default translate([], { wait: true })(SubsAutocomplete);

View file

@ -1,15 +1,19 @@
import React, {Component} from 'react';
import { Button } from 'react-bootstrap';
/* eslint-disable import/no-absolute-path */
/* eslint-disable react/jsx-indent-props */
/* eslint-disable key-spacing */
/* eslint-env jquery */
import React, { Component } from 'react';
import { translate, Trans } from 'react-i18next';
import {render} from 'react-dom';
import PropTypes from 'prop-types';
// import { HashLink as Link } from 'react-router-hash-link';
// import { Link } from 'react-router-dom';
// https://www.npmjs.com/package/react-resize-detector
import ReactResizeDetector from 'react-resize-detector';
import {ScrollToTopOnMount, SectionsContainer, Section} from 'react-fullpage';
import FiresMap from '../FiresMap/FiresMap';
import FireSubscription from '/imports/ui/pages/FireSubscription/FireSubscription';
import _ from 'lodash';
import { ScrollToTopOnMount, SectionsContainer, Section } from 'react-fullpage';
import 'html5-device-mockups/dist/device-mockups.min.css';
import FireSubscription from '/imports/ui/pages/FireSubscription/FireSubscription';
import FiresMap from '../FiresMap/FiresMap';
import './Index.scss';
import './Index-custom.scss';
@ -20,53 +24,39 @@ class Index extends Component {
constructor(props) {
super(props);
const self = this;
this.myScaleFunction = _.debounce(() => {
self.scaleHeader();
}, 250);
this.onResize = this.onResize.bind(this);
}
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();
};
componentDidMount = () => {
componentDidMount() {
$('.carousel').carousel();
}
handleBtnClick = (event) => {
onResize() {
this.myScaleFunction();
}
scaleHeader() {
const scalable = document.getElementById('tcefh1');
const margin = 10;
const scalableContainer = scalable.parentNode;
scalable.style.transform = 'scale(1)';
const scalableContainerWidth = scalableContainer.offsetWidth - margin;
const scalableWidth = scalable.offsetWidth;
scalable.style.transform = `scale(${scalableContainerWidth / scalableWidth})`;
scalableContainer.style.height = `${scalable.getBoundingClientRect().height}px`;
}
handleBtnClick() {
window.open('https://t.me/TodosContraElFuego_bot', '_blank');
}
render() {
// https://github.com/subtirelumihail/react-fullpage
let fullPageOptions = {
const fullPageOptions = {
activeClass: 'active', // the class that is appended to the sections links
anchors: ['home', 'crowdsourcing', 'platforms', 'participe', 'fires'], // the anchors for each sections
arrowNavigation: false, // use arrow keys (true after development)
@ -88,67 +78,70 @@ class Index extends Component {
<SectionsContainer className="container" {...fullPageOptions}>
<Section>
<header>
<ReactResizeDetector handleWidth handleHeight onResize={this._onResize} />
<div id="carouselExampleIndicators" className="carousel slide"
ref="slides">
<ReactResizeDetector handleWidth handleHeight onResize={this.onResize} />
<div
id="carouselExampleIndicators"
className="carousel slide"
ref={(ref) => { this.slides = ref; }}
>
<ol className="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" className="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="3"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="0" className="active" />
<li data-target="#carouselExampleIndicators" data-slide-to="1" />
<li data-target="#carouselExampleIndicators" data-slide-to="2" />
<li data-target="#carouselExampleIndicators" data-slide-to="3" />
</ol>
<div className="carousel-inner" role="listbox">
<div className="carousel-item carousel-item-1 active">
<div className="slide-1-icon"></div>
<div className="slide-1-icon" />
<div className="carousel-caption">
<h3><i className="fa fa-map-pointer" aria-hidden="true"></i>Elige un lugar</h3>
<p></p>
<h3><i className="fa fa-map-pointer" aria-hidden="true" />Elige un lugar</h3>
<p />
</div>
</div>
<div className="carousel-item carousel-item-2">
<div className="slide-2-icon"></div>
<div className="slide-2-icon" />
<div className="carousel-caption">
<h3><i className="fa fa-dot-circle-o" aria-hidden="true"></i>Elige un radio de vigilancia</h3>
<p></p>
<h3><i className="fa fa-dot-circle-o" aria-hidden="true" />Elige un radio de vigilancia</h3>
<p />
</div>
</div>
<div className="carousel-item carousel-item-3">
<div className="slide-3-icon"></div>
<div className="slide-3-icon" />
<div className="carousel-caption">
<h3><i className="fa fa-podcast" aria-hidden="true"></i>Recibe alertas de fuegos en esa zona</h3>
<p></p>
<h3><i className="fa fa-podcast" aria-hidden="true" />Recibe alertas de fuegos en esa zona</h3>
<p />
</div>
</div>
<div className="carousel-item carousel-item-4">
<div className="slide-4-icon"></div>
<div className="slide-4-icon" />
<div className="carousel-caption">
<h3><i className="fa fa-bell-o" aria-hidden="true"></i>Alerta cuando hay un fuego</h3>
<p></p>
<h3><i className="fa fa-bell-o" aria-hidden="true" />Alerta cuando hay un fuego</h3>
<p />
</div>
</div>
</div>
<a className="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span className="carousel-control-prev-icon" aria-hidden="true"></span>
<span className="carousel-control-prev-icon" aria-hidden="true" />
<span className="sr-only">Previous</span>
</a>
<a className="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span className="carousel-control-next-icon" aria-hidden="true"></span>
<span className="carousel-control-next-icon" aria-hidden="true" />
<span className="sr-only">Next</span>
</a>
</div>
</header>
<section className="py-5">
<div className="container">
<div className="scale__container--js">
<h1 id="tcefh1" className="scale--js">{this.props.t('AppName')}</h1>
<div className="container">
<div className="scale__container--js">
<h1 id="tcefh1" className="scale--js">{this.props.t('AppName')}</h1>
</div>
<p>Siempre alerta a los fuegos en nuestro vecindario</p>
{/* <Link className="participe-btn btn btn-lg btn-warning" role="button" to="/#platforms">{this.props.t('Participa')}</Link> */}
</div>
<p>Siempre alerta a los fuegos en nuestro vecindario</p>
{/* <Link className="participe-btn btn btn-lg btn-warning" role="button" to="/#platforms">{this.props.t('Participa')}</Link> */}
</div>
</section>
</Section>
@ -162,40 +155,40 @@ class Index extends Component {
</div>
</div>
</Section>
<a id="join" name="join"></a>
<Section className="platf">
<div className="container">
<div className="section-heading text-center">
<h2><Trans>Somos muchos ojos</Trans></h2>
<p className="text-muted"><Trans>Usamos diferentes fuentes de datos para notificarte de fuegos activos en tus zonas de interés</Trans></p>
<hr/>
<hr />
</div>
<div className="row">
<div className="col-lg-4 my-auto">
<div className="device-wrapper">
<div className="device" data-device="iPhone6" data-orientation="portrait" data-color="white">
<div className="screen">
{/* Demo image for screen mockup, you can put an image here, some HTML, an animation, video, or anything else! */}
<img src="/telegram-screen.png" className="img-fluid" alt=""/>
</div>
<div className="button" onClick={(event) => this.handleBtnClick(event)}></div>
<div className="device-wrapper">
<div className="device" data-device="iPhone6" data-orientation="portrait" data-color="white">
<div className="screen">
{/* Demo image for screen mockup, you can put an image here, some HTML, an animation, video, or anything else! */}
<img src="/telegram-screen.png" className="img-fluid" alt="" />
</div>
<div className="button" tabIndex="-1" onKeyDown={() => {}} role="button" onClick={() => this.handleBtnClick()} />
</div>
</div>
</div>
<div className="col-lg-8 my-auto">
<div className="container-fluid">
<div className="row">
<div className="col-lg-6">
<a className="feature-link"target="_blank" href="https://t.me/TodosContraElFuego_bot"><div className="feature-item">
<i className="fa fa-telegram text-primary"></i>
<h3>Telegram</h3>
<p className="text-muted"><Trans>Usa nuestro bot de Telegram para estar al tanto de los fuegos en tus área</Trans></p>
</div></a>
<a className="feature-link" rel="noopener noreferrer" target="_blank" href="https://t.me/TodosContraElFuego_bot">
<div className="feature-item">
<i className="fa fa-telegram text-primary" />
<h3>Telegram</h3>
<p className="text-muted"><Trans>Usa nuestro bot de Telegram para estar al tanto de los fuegos en tus área</Trans></p>
</div>
</a>
</div>
<div className="col-lg-6">
<div className="feature-item">
<i className="icon-envelope-open text-primary"></i>
<i className="icon-envelope-open text-primary" />
<h3><Trans>Correo electronico</Trans></h3>
<p className="text-muted"><Trans>Recibe nuestras notificaciones de fuegos por correo</Trans></p>
</div>
@ -204,16 +197,16 @@ class Index extends Component {
<div className="row">
<div className="col-lg-6">
<div className="feature-item">
<i className="icon-screen-smartphone text-primary"></i>
<i className="icon-screen-smartphone text-primary" />
<h3><Trans>Otros dispositivos</Trans></h3>
<p className="text-muted"><Trans i18nKey="support-us-home">Estamos desarrollando nuestras herramientas para otros dispositivos. Puedes <a href="https://comunes.org/donate">contribuir a hacerlo posible.</a></Trans></p>
</div>
</div>
<div className="col-lg-6">
<div className="feature-item">
<i className="icon-lock-open text-primary"></i>
<i className="icon-lock-open text-primary" />
<h3><Trans>Software Libre</Trans></h3>
<p className="text-muted"><Trans i18nKey="dev-with-us-home">Todo nuestro trabajo es sofware libre. <a href="https://github.com/comunes/todos-contra-el-fuego" target="_blank">Traductoræs y desarrolladoræs siempre bienvenid@s</a>.</Trans></p>
<p className="text-muted"><Trans i18nKey="dev-with-us-home">Todo nuestro trabajo es sofware libre. <a href="https://github.com/comunes/todos-contra-el-fuego" rel="noopener noreferrer" target="_blank">Traductoræs y desarrolladoræs siempre bienvenid@s</a>.</Trans></p>
</div>
</div>
</div>
@ -227,7 +220,7 @@ class Index extends Component {
<div className="container">
<FireSubscription history={this.props.history} focusInput={false} />
</div>
<div className="overlay"></div>
<div className="overlay" />
</Section>
<Section className="">
@ -238,7 +231,12 @@ class Index extends Component {
</SectionsContainer>
</div>
);
};
}
}
Index.propTypes = {
history: PropTypes.object.isRequired,
t: PropTypes.func.isRequired
};
export default translate([], { wait: true })(Index);