Skip to content

Commit

Permalink
Adding functionality to filter buttons (#33)
Browse files Browse the repository at this point in the history
* adding functionality to filter buttons

* adding EOF lines

* Fixing issue with color filters

* resolve issue #34, now you can click on an active filter button and remove the filter

* fixing issue where comboEnergy was active and clicking on it wouldn't remove the filter

* resolve issue #32, now generic energy cost is displayed correctly

* Deleting semicolons, refactoring the filterbox file, adding hooks

* refactoring the method to create buttons

* added changes so when a filter by same field already exist it will add it as an or into the same filter, also added changes requested by irving

* deleting semicolons
  • Loading branch information
RobertoOchoaAldana authored and Xotl committed Nov 12, 2019
1 parent 8722c46 commit 5bab290
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 318 deletions.
4 changes: 2 additions & 2 deletions web-page/src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react';
import React, { Component } from 'react'
import 'materialize-css/dist/css/materialize.min.css'
import M from "materialize-css"
import './App.css'
import FilterBox from './components/FilterBox'
import FilterBox from './components/filter-box'
import CardsContainer from './components/CardsContainer'

class App extends Component {
Expand Down
16 changes: 10 additions & 6 deletions web-page/src/components/EnergyColor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React, { Component } from 'react';
import './EnergyColor.css';
import React, { Component } from 'react'
import './EnergyColor.css'

const
reg = /[\dbugyr]+/g,
filterColors = e => e.match(reg),
iconPrinter = e => filterColors(e).map(i => {
if (!isNaN(Number(i))) {
return <span className="energy-color white">{i}</span>
let extraColors = filterColors(e).length - 1
if (i-extraColors > 0)
return <span className="energy-color white">{i-extraColors}</span>
else
return null
}

switch (i) {
Expand All @@ -26,8 +30,8 @@ const
class EnergyColor extends Component {

render() {
const { energy } = this.props;
if (!energy) return <span>{energy}</span>;
const { energy } = this.props
if (!energy) return <span>{energy}</span>

return (
<span key={energy}>
Expand All @@ -37,4 +41,4 @@ class EnergyColor extends Component {
}
}

export default EnergyColor;
export default EnergyColor
304 changes: 0 additions & 304 deletions web-page/src/components/FilterBox.js

This file was deleted.

3 changes: 3 additions & 0 deletions web-page/src/components/FilterButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.filter-on {
background-color: #ad2323;
}
14 changes: 14 additions & 0 deletions web-page/src/components/FilterButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'

import './FilterButton.css'

const FilterButton = (props) => {
const { id, fieldname, customClass, onClick } = props
return <label
id={id}
className={`${customClass ? 'filter-on' : ''} btn btn-secondary`}
onClick={ () => onClick(id, fieldname) }
>{id}</label>
}

export default FilterButton
Loading

0 comments on commit 5bab290

Please sign in to comment.