Skip to content

Commit

Permalink
Merge pull request #2574 from fecgov/feature/update-boolean-search-box
Browse files Browse the repository at this point in the history
Update boolean search box and add tooltips for AO,MUR, Statutes
  • Loading branch information
lbeaufort authored Dec 17, 2018
2 parents 4dfbfe0 + d53bd31 commit 1513942
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 76 deletions.
7 changes: 7 additions & 0 deletions fec/fec/static/js/legal/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ function Filters(props) {
handleChange={props.setQuery}
getResults={props.getResults}
keywordModal={true}
TooltipHelp={{
addTooltip: true,
message:
'Refine a keyword search by using AND, OR, “ ”, -, to expand or limit results.',
verticalPosition: 'above',
horizontalPosition: 'left'
}}
/>
<CheckboxFilter
key="ao_is_pending"
Expand Down
81 changes: 49 additions & 32 deletions fec/fec/static/js/legal/filters/TextFilter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const React = require('react');
const PropTypes = require('prop-types');
const TooltipHelp = require('./TooltipHelp');

function TextFilter(props) {
function handleKeydown(e) {
Expand All @@ -9,48 +10,63 @@ function TextFilter(props) {
}

return (
<div className="filter">
<label className="label" htmlFor={props.name + '-filter'}>
{props.label}
</label>
<div className="combo combo--search--mini">
<input
id={props.name + '-filter'}
type="text"
name={props.name}
className="combo__input"
value={props.value || ''}
onChange={props.handleChange}
onKeyDown={handleKeydown}
/>
<button
className="combo__button button--search button--standard"
onClick={props.getResults}
<div>
<div className="filter">
<label
className="label t-inline-block"
htmlFor={props.name + '-filter'}
>
<span className="u-visually-hidden">Search</span>
</button>
{props.label}
</label>
{props.TooltipHelp.addTooltip && (
<TooltipHelp
message={props.TooltipHelp.message}
verticalPosition={props.TooltipHelp.verticalPosition}
horizontalPosition={props.TooltipHelp.horizontalPosition}
/>
)}
<div className="combo combo--search--mini">
<input
id={props.name + '-filter'}
type="text"
name={props.name}
className="combo__input"
value={props.value || ''}
onChange={props.handleChange}
onKeyDown={handleKeydown}
/>
<button
className="combo__button button--search button--standard"
onClick={props.getResults}
>
<span className="u-visually-hidden">Search</span>
</button>
</div>
{props.keywordModal && (
<button
className="button--keywords"
aria-controls="keyword-modal"
data-a11y-dialog-show="keyword-modal"
>
More keyword options
</button>
)}
{props.helpText && (
<span className="t-note t-sans search__example">
{props.helpText}
</span>
)}
</div>
{props.keywordModal && (
<button
className="button--keywords"
aria-controls="keyword-modal"
data-a11y-dialog-show="keyword-modal"
>
More keyword options
</button>
)}
{props.helpText && (
<span className="t-note t-sans search__example">{props.helpText}</span>
)}
</div>
);
}

TextFilter.defaultProps = {
getResults: function() {},
handleChange: function() {},
helpText: 'help',
helpText: '',
keywordModal: true,
TooltipHelp: {},
name: 'name',
value: ''
};
Expand All @@ -60,6 +76,7 @@ TextFilter.propTypes = {
handleChange: PropTypes.func,
helpText: PropTypes.string,
keywordModal: PropTypes.bool,
TooltipHelp: PropTypes.object,
name: PropTypes.string,
value: PropTypes.string
};
Expand Down
25 changes: 25 additions & 0 deletions fec/fec/static/js/legal/filters/TooltipHelp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const React = require('react');
const PropTypes = require('prop-types');

class TooltipHelp extends React.Component {
render() {
return (
<div className="tooltip__container">
<button className="tooltip__trigger">
<span className="u-visually-hidden">Learn more</span>
</button>
<div
className={`tooltip tooltip--${
this.props.verticalPosition
} tooltip--${this.props.horizontalPosition}`}
>
<p className="tooltip__content tooltip__content">
{this.props.message}
</p>
</div>
</div>
);
}
}

module.exports = TooltipHelp;
9 changes: 9 additions & 0 deletions fec/fec/static/scss/components/_modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@include media($lg) {
margin-left: u(-40rem);
width: u(80rem);
max-height:650px;
}
}

Expand All @@ -52,3 +53,11 @@
@include shift(1);
padding-top: u(1rem);
}

.keyword-modal {
.simple-table{
border-width: 0 0;
}

}

52 changes: 51 additions & 1 deletion fec/fec/static/scss/components/_search-controls.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Search Controls
//
// Used at the top of election lookup page
// Used on:
// election lookup page
// embedded searches (MUR, AUDIT)
// keyword modals
//

.search-controls__row {
Expand Down Expand Up @@ -87,6 +90,7 @@
background: $gray-lightest;
}

//For data/election search boxes
.election-search {

.search--container {
Expand Down Expand Up @@ -122,6 +126,23 @@
}
}

//for keyword-options modals on AO, MUR, Statues searches
.keyword-modal{
.modal__tips, modal__form {
display:table-row;
width:100%;
}
.modal__tips {
margin-left:0;
}

.search-controls__or--vertical {
width: 100%;
display:inline-grid;
}
}


@include media($med) {
.search-controls__row {
padding: u(2rem 0);
Expand Down Expand Up @@ -225,6 +246,35 @@
}
}

//for keyword-options modals on AO, MUR, Statues searches
.keyword-modal{
.modal__tips, .modal__form {
display:table-cell;
width:44%;
}
.modal__tips {
margin-left: u(1rem);
padding-top: 0;
}
.search-controls__or--vertical {
margin: u(22.5rem 0);
width: u(3.5rem);
display:table-cell;

&::before,
&::after {
height: u(22.5rem);
}
&::before {
top: u(-22.5rem);
}

&::after {
top: auto;
bottom: u(-22.5rem);
}
}
}

}/*end MED breakpoint*/

Expand Down
Loading

0 comments on commit 1513942

Please sign in to comment.