Skip to content

Commit

Permalink
Edm 363 update lce UI (#33304)
Browse files Browse the repository at this point in the history
* Align header for mobile | display result count beside to keyword suggestion

* Align cancel icon styles with search input | reduce number of typeahed suggestions dipslayed

* touchup styles | change license state if it differs from name selection

* slot conditional alert into dropdown label

* set state filter field to all when switching to certification category type

* filter typeahead suggestions based on filter options

* update filter options based on typeahead suggestion selected

* rename functions more clearly |  correct state managment for filters when clearing input

* cleanup

* update results to va-card component

* enable routing for new lce result info page

* align breadcrumbs with result details url

* cleanup

* delete unit test for unused component

* update unit test for helper function
  • Loading branch information
nicholashibbits authored Dec 3, 2024
1 parent f915ff9 commit 213f2a8
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 222 deletions.
3 changes: 3 additions & 0 deletions src/applications/gi/components/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Dropdown = ({
value,
visible,
required,
children,
}) => {
if (!visible) {
return null;
Expand All @@ -28,6 +29,7 @@ const Dropdown = ({
<label htmlFor={name}>
{label}{' '}
{required ? <span className="required-label">(*Required)</span> : null}{' '}
{children}
</label>
);

Expand Down Expand Up @@ -91,6 +93,7 @@ Dropdown.propTypes = {
visible: PropTypes.bool,
onFocus: PropTypes.func,
required: PropTypes.bool,
children: PropTypes.node,
};

Dropdown.defaultProps = {
Expand Down
11 changes: 10 additions & 1 deletion src/applications/gi/components/GiBillBreadcrumbs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const GiBillBreadcrumbs = () => {
const compareMatch = useRouteMatch('/compare');
const lcMatch = useRouteMatch('/lc-search');
const lcResultsMatch = useRouteMatch('/lc-search/results');
const lcResultInfoMatch = useRouteMatch('/lc-search/:type/:id');
const crumbLiEnding = giDocumentTitle();
const formatedProgramType = formatProgramType(
ProgramsTypeMatch?.params?.programType,
Expand Down Expand Up @@ -55,7 +56,7 @@ const GiBillBreadcrumbs = () => {
if (lcMatch) {
crumbs.push({
href: '/education/gi-bill-comparison-tool/lc-search',
label: 'Licensces and Certifications',
label: 'Licensces & Certifications',
});
}
if (lcResultsMatch) {
Expand All @@ -64,6 +65,14 @@ const GiBillBreadcrumbs = () => {
label: 'Search Results',
});
}
if (lcResultInfoMatch) {
crumbs.push({
href: `/education/gi-bill-comparison-tool/lc-search/results/${
lcResultInfoMatch.params.type
}/${lcResultInfoMatch.params.id}`,
label: 'Result Details',
});
}

return (
<div className="row">
Expand Down
67 changes: 43 additions & 24 deletions src/applications/gi/components/LcKeywordSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ export default function LcKeywordSearch({
suggestions,
onSelection,
onUpdateAutocompleteSearchTerm,
handleClearInput,
}) {
const handleChange = e => {
const { value } = e.target;
onUpdateAutocompleteSearchTerm(value);
};

const handleSuggestionSelected = selected => {
onUpdateAutocompleteSearchTerm(selected.label);
const { name, type } = selected;

if (onSelection) {
onSelection(selected);
}
};
onUpdateAutocompleteSearchTerm(name);

const handleClearInput = () => {
onUpdateAutocompleteSearchTerm('');
onSelection({ type, state: type === 'license' ? 'FL' : 'all' }); // remove hardcoded state
};

return (
Expand Down Expand Up @@ -56,6 +53,11 @@ export default function LcKeywordSearch({
</label>
<div className="lc-name-search-container vads-u-display--flex">
<input
style={
inputValue === ''
? { maxWidth: '30rem' }
: { width: '100%', borderRight: 'none' }
}
aria-controls="lcKeywordSearch"
className="lc-name-search-input"
{...getInputProps({
Expand All @@ -70,7 +72,7 @@ export default function LcKeywordSearch({
size={3}
icon="cancel"
id="clear-input"
class="vads-u-display--flex vads-u-align-items--center"
class="lc-clear vads-u-display--flex vads-u-align-items--center"
onClick={handleClearInput}
/>
)}
Expand All @@ -83,21 +85,38 @@ export default function LcKeywordSearch({
id="lcKeywordSearch"
style={{ maxWidth: '30rem' }}
>
{suggestions.map((item, index) => (
<div
key={index}
role="option"
aria-selected={
selectedItem === item.label ? 'true' : 'false'
}
className={classNames('suggestion', {
'suggestion-highlighted': highlightedIndex === index,
})}
{...getItemProps({ item })}
>
{item.name}
</div>
))}
{suggestions
.map((item, index) => (
<div
key={index}
role="option"
aria-selected={
selectedItem === item.label ? 'true' : 'false'
}
className={classNames('suggestion', {
'suggestion-highlighted': highlightedIndex === index,
})}
{...getItemProps({ item })}
>
{index !== 0 ? (
item.name
) : (
<div className="keyword-suggestion-container">
<span className="vads-u-padding-right--1">
{item.name}
</span>
<span>
{`(${
suggestions.length > 1
? suggestions.length
: 'No'
} results)`}
</span>
</div>
)}
</div>
))
.slice(0, 6)}
</div>
)}
</div>
Expand All @@ -108,8 +127,8 @@ export default function LcKeywordSearch({
}

LcKeywordSearch.propTypes = {
onSelection: PropTypes.func.isRequired,
inputValue: PropTypes.string,
suggestions: PropTypes.array,
onSelection: PropTypes.func,
onUpdateAutocompleteSearchTerm: PropTypes.func,
};
72 changes: 0 additions & 72 deletions src/applications/gi/components/LicenseCertificationResultInfo.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function LicenseCertificationSearch({
<div>
<section className="vads-u-display--flex vads-u-flex-direction--column vads-u-padding-x--2p5 mobile-lg:vads-u-padding-x--2">
<div className="row">
<h1 className="vads-u-text-align--center mobile-lg:vads-u-text-align--left">
<h1 className=" mobile-lg:vads-u-text-align--left">
Licenses and Certifications
</h1>
<p className="vads-u-font-size--h3 vads-u-color--gray-dark">
Expand Down
Loading

0 comments on commit 213f2a8

Please sign in to comment.