Skip to content

Commit

Permalink
implemented filters
Browse files Browse the repository at this point in the history
  • Loading branch information
6foot5 committed Jul 30, 2021
1 parent fe00343 commit d244df4
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 117 deletions.
Binary file modified public/favicon.ico
Binary file not shown.
48 changes: 19 additions & 29 deletions src/Banner.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import React, { Component } from 'react';
// import './NavBar.css';
import {Link} from 'react-router-dom';
import React from 'react';

class Banner extends Component {
render() {

let navColor = 'transparent';
if ( this.props.location.pathname !== '/') {
navColor = 'black';
}

return(
<div className="container-fluid px-0">
<header title="Buncombe County Area Meal Sites" class="jumbotron jumbotron-fluid no-print">
<div class="container position-relative">
<div class="jumbotron--text">
<h1 class="text-black">Buncombe County Area Meal Sites</h1>
<p class="lead text-black sub-heading">
Find locations around Buncombe County working hard to feed our community.
</p>
<p class="lead text-black sub-heading">
<strong>FOR STUDENTS:</strong> text FOODNC to 877-877 to locate nearby free meal sites.
The texting service is also available in Spanish by texting COMIDA to 877-877.
</p>
</div>
function Banner() {
return(
<div className="container-fluid px-0">
<header title="Buncombe County Area Meal Sites" className="jumbotron jumbotron-fluid no-print">
<div className="container position-relative">
<div className="jumbotron--text">
<h1 className="text-black">Buncombe County Area Meal Sites</h1>
<p className="lead text-black sub-heading">
Find locations around Buncombe County working hard to feed our community.
</p>
<p className="lead text-black sub-heading">
<strong>FOR STUDENTS:</strong> text FOODNC to 877-877 to locate nearby free meal sites.
The texting service is also available in Spanish by texting COMIDA to 877-877.
</p>
</div>
</header>
</div>
);
}
</div>
</header>
</div>
);
}

export default Banner;
58 changes: 58 additions & 0 deletions src/FilterCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';

function FilterCard(props) {

console.log('ACTIVE FILTERS IN CARD');
let activeFilters = props.activeFilters[props.filterName];
console.log(activeFilters);
const optionList = props.filterOptions.data.map( (thisOption, i) => {
return (
<option key={i} value={thisOption.value}>{thisOption.label}</option>
);
});
let activeFiltersList = [];

let matchingLabel = '';

if (props.activeFilters.hasOwnProperty(props.filterName)) {
props.activeFilters[props.filterName].forEach( (filter, i) => {
props.filterOptions.data.forEach( (option) => {
if (option.value === filter) {
matchingLabel = option.label;
}
});

activeFiltersList.push({
text: matchingLabel,
value: filter
});
});
}

console.log(activeFiltersList);

const selectedFilters = activeFiltersList.map( (filter, i) => {
return(<li key={i} className="list-group-item filter-button" data-filter-value={filter.value} data-filter-type={props.filterName} title="Click to remove this filter" onClick={props.removeHandler}>{filter.text}</li>);
})

return(
<div className="col-lg-4 mb-3">
<div className="card inner m-3 h-100">
<div className="card-header"><h3 className="d-inline">{props.filterOptions.filterHeader}</h3></div>
<ul className="list-group list-group-flush" id={`list-group-${props.filterName}`}>
<li className={`list-group-item selected-filters-default-${props.filterName}`}>{props.filterOptions.defaultDescription}</li>
{selectedFilters}
</ul>
<div className="p-3">
<label className="select-label" htmlFor={`select-filter-${props.filterName}`}>{props.filterOptions.selectLabel}</label>
<select data-filter-type={props.filterName} name={`select-filter-${props.filterName}`} className="form-control form-control-sm mt-1" id={`filter-${props.filterName}`} onChange={props.changeHandler}>
<option></option>
{optionList}
</select>
</div>
</div>
</div>
);
}

export default FilterCard;
30 changes: 30 additions & 0 deletions src/FilterOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import FilterCard from './FilterCard';

function FilterOptions(props) {
console.log(props);
const filterKeys = Object.keys(props.options);
const filterCardSet = filterKeys.map( (key, i) => {
let thisKey = `filtercard-${i}`;
return (
<FilterCard key={thisKey} activeFilters={props.activeFilters} filterOptions={props.options[key]} filterName={key} changeHandler={props.changeHandler} removeHandler={props.removeHandler} />
);
});
return(
<section title="Filter meal sites based on geographical area, days open, or type of service provided." className="container my-5 js-dependent no-print">
<div id="object-filters" className="border rounded-lg py-4 px-1">
<div className="row">
<div className="col-12 mb-3 text-center">
<h2 className="">Refine the list with filters</h2>
<p>View meal sites by geographical area, day of the week, and/or service type offered.</p>
</div>
</div>
<div className="row selected-filters">
{filterCardSet}
</div>
</div>
</section>
);
}

export default FilterOptions;
34 changes: 17 additions & 17 deletions src/LocationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ function LocationCard(props) {
let q = encodeURIComponent(props.location.address);

return(
<div class={`col p-0 mb-5 all-objects object-${props.location.OBJECTID} ${props.location.selectors}`}>
<div class="card inner m-3 h-100">
<div class="card-header"><h3>{props.location.name}</h3></div>
<ul class="list-group list-group-flush">
<li class="list-group-item">{props.location.generalArea}</li>
<li class="list-group-item"><i class={props.location.serviceIcon}></i> {props.location.type === 'Students' ? 'Student Meals' : props.location.type}</li>
<li class="list-group-item">
<ul class="week-list" aria-label="Days of the week">
<li class={`day-of-week ${props.location.styleM}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleM === 'day-of-week--on' ? 'open' : 'closed'} on Monday`}><span class="day-label">M</span></li>
<li class={`day-of-week ${props.location.styleT}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleT === 'day-of-week--on' ? 'open' : 'closed'} on Tuesday`}><span class="day-label">T</span></li>
<li class={`day-of-week ${props.location.styleW}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleW === 'day-of-week--on' ? 'open' : 'closed'} on Wednesday`}><span class="day-label">W</span></li>
<li class={`day-of-week ${props.location.styleTh}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleTh === 'day-of-week--on' ? 'open' : 'closed'} on Thursday`}><span class="day-label">Th</span></li>
<li class={`day-of-week ${props.location.styleF}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleF === 'day-of-week--on' ? 'open' : 'closed'} on Friday`}><span class="day-label">F</span></li>
<li class={`day-of-week ${props.location.styleSa}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleSa === 'day-of-week--on' ? 'open' : 'closed'} on Saturday`}><span class="day-label">Sa</span></li>
<li class={`day-of-week ${props.location.styleSu}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleSu === 'day-of-week--on' ? 'open' : 'closed'} on Sunday`}><span class="day-label">Su</span></li>
<div className={`col p-0 mb-5 all-objects object-${props.location.OBJECTID} ${props.location.selectors}`}>
<div className="card inner m-3 h-100">
<div className="card-header"><h3>{props.location.name}</h3></div>
<ul className="list-group list-group-flush">
<li className="list-group-item">{props.location.generalArea}</li>
<li className="list-group-item"><i className={props.location.serviceIcon}></i> {props.location.type === 'Students' ? 'Student Meals' : props.location.type}</li>
<li className="list-group-item">
<ul className="week-list" aria-label="Days of the week">
<li className={`day-of-week ${props.location.styleM}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleM === 'day-of-week--on' ? 'open' : 'closed'} on Monday`}><span className="day-label">M</span></li>
<li className={`day-of-week ${props.location.styleT}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleT === 'day-of-week--on' ? 'open' : 'closed'} on Tuesday`}><span className="day-label">T</span></li>
<li className={`day-of-week ${props.location.styleW}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleW === 'day-of-week--on' ? 'open' : 'closed'} on Wednesday`}><span className="day-label">W</span></li>
<li className={`day-of-week ${props.location.styleTh}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleTh === 'day-of-week--on' ? 'open' : 'closed'} on Thursday`}><span className="day-label">Th</span></li>
<li className={`day-of-week ${props.location.styleF}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleF === 'day-of-week--on' ? 'open' : 'closed'} on Friday`}><span className="day-label">F</span></li>
<li className={`day-of-week ${props.location.styleSa}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleSa === 'day-of-week--on' ? 'open' : 'closed'} on Saturday`}><span className="day-label">Sa</span></li>
<li className={`day-of-week ${props.location.styleSu}`} title={`${props.location.name} ${props.location.type} service is ${props.location.styleSu === 'day-of-week--on' ? 'open' : 'closed'} on Sunday`}><span className="day-label">Su</span></li>
</ul>
</li>
<li class="list-group-item">{props.location.hoursOpen}<br />{props.location.daysOpen}</li>
<li class="list-group-item"><a class="map-link text-dark" href={`https://www.google.com/maps/search/${q}`} title={`View location of ${props.location.name} on a Google Map`} target="_blank" rel="noopener noreferrer">Location</a>: {props.location.address}</li>
<li className="list-group-item">{props.location.hoursOpen}<br />{props.location.daysOpen}</li>
<li className="list-group-item"><a className="map-link text-dark" href={`https://www.google.com/maps/search/${q}`} title={`View location of ${props.location.name} on a Google Map`} target="_blank" rel="noopener noreferrer">Location</a>: {props.location.address}</li>
</ul>
</div>
</div>
Expand Down
Loading

0 comments on commit d244df4

Please sign in to comment.