Skip to content

Commit

Permalink
fix: style fixes and misc clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz authored and muhammad-ammar committed Mar 24, 2021
1 parent f57f57d commit 296b1e2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 78 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"react-dom": "^17.0.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"redux": "4.0.5",
"redux": "^4.0.5",
"@fortawesome/free-solid-svg-icons": "^5.8.1",
"@fortawesome/react-fontawesome": "^0.1.4",
"algoliasearch": "^4.8.5",
Expand All @@ -96,6 +96,5 @@
"react-instantsearch-dom": "^6.8.3",
"react-loading-skeleton": "^2.1.1",
"lodash.debounce": "^4.0.8"
},
"dependencies": {}
}
}
9 changes: 2 additions & 7 deletions src/course-search/FacetDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ const FacetDropdown = ({
<div className="facet-list">
<Dropdown className={classNames('mb-0 mr-md-3', type)}>
<Dropdown.Toggle
className={
classNames(
'bg-white', 'text-capitalize', 'rounded-0', 'border-0',
'd-flex', 'justify-content-between', 'align-items-center', 'text-dark',
{ 'font-weight-bold': isBold },
)
}
variant="inverse-primary"
className={classNames({ 'font-weight-bold': isBold })}
>
{title}
</Dropdown.Toggle>
Expand Down
7 changes: 2 additions & 5 deletions src/course-search/FacetItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import classNames from 'classnames';
const FacetItem = ({
handleInputOnChange, item, isChecked,
}) => (
<Dropdown.Item
key={item.label}
as="label"
className="mb-0 py-3"
>
<Dropdown.Item as="label" className="mb-0 py-3">
<Input
type="checkbox"
checked={isChecked}
onChange={() => handleInputOnChange(item)}
className="position-relative mr-2"
/>
<span className={classNames('facet-item-label', { 'is-refined': isChecked })}>
{item.label}
Expand Down
4 changes: 2 additions & 2 deletions src/course-search/FacetListBase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const FacetListBase = ({

const renderItems = useCallback(
() => {
if (!items || !items.length) {
return <span className="py-2 px-2 no-options-found">{NO_OPTIONS_FOUND}</span>;
if (!items?.length) {
return <span className="p-2 d-block">{NO_OPTIONS_FOUND}</span>;
}

return items.map(item => {
Expand Down
2 changes: 1 addition & 1 deletion src/course-search/MobileFilterMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const MobileFilterMenuBase = ({ children, className, items }) => {
</div>
<div className="modal-footer py-3">
<div className="col">
<ClearCurrentRefinements className="bg-white btn-block text-dark" variant="link" />
<ClearCurrentRefinements className="btn-block" variant="inverse-primary" />
</div>
<div className="col">
<Button
Expand Down
4 changes: 1 addition & 3 deletions src/course-search/SearchHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const SearchHeader = () => {
/>
</Col>
<Col xs={12}>
<SearchFilters
className="mb-3"
/>
<SearchFilters className="mb-3" />
</Col>
</Row>
</Container>
Expand Down
21 changes: 12 additions & 9 deletions src/course-search/TypeaheadFacetDropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Input } from '@edx/paragon';
import debounce from 'lodash.debounce';
import { Input } from '@edx/paragon';

import FacetDropdown from './FacetDropdown';

const TypeaheadFacetDropdown = ({
Expand All @@ -20,14 +21,16 @@ const TypeaheadFacetDropdown = ({

const transformMenuOptions = menuOptions => (
<>
<Input
autoFocus
type="search"
className="typeahead-dropdown-input"
placeholder={options.placeholder}
aria-label={options.ariaLabel}
onChange={(event) => handleSearch(event.currentTarget.value)}
/>
<div className="p-2">
<Input
autoFocus
type="search"
className="typeahead-dropdown-input"
onChange={event => handleSearch(event.currentTarget.value)}
placeholder={options.placeholder}
aria-label={options.ariaLabel}
/>
</div>
<div className="typeahead-dropdown-menu-scrollable-items">
{menuOptions}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/course-search/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const SEARCH_FACET_FILTERS = [
attribute: 'skill_names',
title: 'Skills',
typeaheadOptions: {
placeholder: 'Find a skill',
placeholder: 'Find a skill...',
ariaLabel: 'Type to find a skill',
minLength: 3,
},
Expand Down
46 changes: 7 additions & 39 deletions src/course-search/styles/_FacetList.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
$facet-dropdown-max-height: 250px;

.facet-list {
.dropdown {
@extend .mb-3;

.dropdown-toggle {
text-align: left;
padding-left: 10px;
padding-right: 10px;

&:before {
border-radius: 0;
}

&:after {
margin-left: 10px;
}
}

.facet-item-label {
font-weight: normal;

Expand All @@ -29,8 +17,8 @@
}

.dropdown-menu {
max-height: 250px;
overflow: scroll;
max-height: $facet-dropdown-max-height;
overflow-y: scroll;
max-width: 420px;
width: max-content;

Expand All @@ -43,31 +31,11 @@

.typeahead {
.dropdown-menu {
.facet-list & {
padding: 50px 0 0;
max-height: none;
overflow: visible;
width: 420px;
}
max-height: unset;

.typeahead-dropdown-menu-scrollable-items {
position: relative;
max-height: 200px;
overflow: auto;

.no-options-found {
display: block;
}
}

.typeahead-dropdown-input {
position: absolute;
top: 0;
left: 0;
width: 98%;
background: white;
padding: 5px;
margin: 4px;
max-height: $facet-dropdown-max-height;
overflow-y: scroll;
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/course-search/styles/_MobileSearchFilters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@
@extend .border-bottom;
@extend .py-3;
width: 100%;

&:after {
position: table;
float: right;
height: 100%;
vertical-align: middle;
}
}

&:first-child {
Expand Down
2 changes: 1 addition & 1 deletion src/course-search/tests/FacetListBase.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('<FacetListBase />', () => {

// input some search text
await act(async () => {
fireEvent.change(screen.queryByPlaceholderText('Find a skill'), { target: { value: 'Blockchain' } });
fireEvent.change(screen.queryByPlaceholderText('Find a skill...'), { target: { value: 'Blockchain' } });
});

await new Promise((r) => setTimeout(r, 210));
Expand Down

0 comments on commit 296b1e2

Please sign in to comment.