-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add skills filter dropdown #76
feat: add skills filter dropdown #76
Conversation
abe08be
to
ba17276
Compare
ba17276
to
7a6607d
Compare
7e5c379
to
031f423
Compare
@adamstankiewicz This is ready for review. |
031f423
to
213b0d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm super excited about these changes! I would like to split things off into separate components, though, if possible.
Here's some reasoning why from a recent fedx meeting: https://openedx.atlassian.net/wiki/spaces/BPL/pages/2277081251/Paragon+Technical+Guide
I'm approving because I don't want to hold you up by being in a different time zone, but I would like smaller components and to split up the current new test, and add some others. :)
src/course-search/FacetListBase.jsx
Outdated
@@ -69,6 +70,8 @@ const FacetListBase = ({ | |||
items={renderItems()} | |||
title={title} | |||
isBold={isBold} | |||
attribute={attribute} | |||
{...props} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly disprefer passing props this way; it can make it very confusing for future people reading the code. If we know what the props are, let's pass them explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what is the better way in this particular scenario, can you please guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.... are these extra props all coming from algolia? If yes, maybe put a note in that we're passing in all the props from algolia.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly are coming from Algolia and some are ours.
src/course-search/FacetDropdown.jsx
Outdated
<Dropdown.Menu> | ||
{ | ||
typeahead && ( | ||
<div className="search-input-wrapper"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's enough difference here that we need two separate components; a TypeaheadFacetDropdown and a FacetDropdown. What they share can go in a BaseFacetDropdown
component.
This will keep them easy to reason about and test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can this className go directly on the input instead of wrapping it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, split off the inner part of this; everything within the DropdownMenu, into a TypeaheadDropdownMenu
and a FacetDropdownMenu
(my names are probably not the best here; feel free to do what you want with them!
@raq929 Thank You for a wonderful review. Some questions:
|
|
@raq929 I have refactored the code. Please have a look. Unit test update is in progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it, it reuses code nicely, lets the FacetListDropdown not get overly complicated, and hopefully will be more straightforward to test. 🎉
3b0a6d8
to
db4cd0c
Compare
@raq929 Can you please take a final look? From my side this is ready for merge. |
@raq929 I am going merge this. Any concerns? I have tried to delete the duplicate scss files in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
package.json
Outdated
@@ -95,5 +95,7 @@ | |||
"react-instantsearch-dom": "^6.8.3", | |||
"react-loading-skeleton": "^2.1.1" | |||
}, | |||
"dependencies": {} | |||
"dependencies": { | |||
"lodash": "^4.17.21" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched everything to peerDependencies
to avoid conflicts with the various MFEs. I think we should prooobably keep it that way for now, although we're looking at better solutions for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related, do we need the full lodash
dependency? Looks like it's just debounce
being used; should we only require lodash.debounce
as a peer dependency instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raq929 This is the first time I am working with peerDependencies
. As per my understanding, I need to do the below steps
- move
"lodash": "^4.17.21"
insidepeerDependencies
inpackage.json
infrontend-enterprise
- remove
package-lock.json
changes infrontend-enterprise
for this PR - add
"lodash": "^4.17.21"
independencies
inpackage.json
infrontend-app-learner-portal-enterprise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raq929 @adamstankiewicz I have added "lodash.debounce": "^4.0.8"
in package.json
but git commit --amend
giving me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raq929 Can you help how to fix this peerDependencies
thing and what changes I need make in this repo and in frontend-app-learner-portal-enterprise
repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muhammad-ammar How are you importing lodash.debounce
? I'm confused why you would be seeing the linting error if you're no longer importing from the full lodash
package. I'd expect the import to be something like:
import debounce from 'lodash.debounce';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz lodash.debounce
issue has been fixed. Can you guide how can test styling changes for typeahead dropdown?
src/course-search/FacetListBase.jsx
Outdated
title={title} | ||
isBold={isBold} | ||
/> | ||
typeahead ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
package.json
Outdated
@@ -95,5 +95,7 @@ | |||
"react-instantsearch-dom": "^6.8.3", | |||
"react-loading-skeleton": "^2.1.1" | |||
}, | |||
"dependencies": {} | |||
"dependencies": { | |||
"lodash": "^4.17.21" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related, do we need the full lodash
dependency? Looks like it's just debounce
being used; should we only require lodash.debounce
as a peer dependency instead?
src/course-search/FacetDropdown.jsx
Outdated
@@ -24,10 +29,15 @@ const FacetDropdown = ({ title, items, isBold }) => ( | |||
</div> | |||
); | |||
|
|||
FacetDropdown.defaultProps = { | |||
type: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
as a default prop feels a bit cleaner than an empty string here.
src/course-search/FacetListBase.jsx
Outdated
title={title} | ||
isBold={isBold} | ||
/> | ||
typeahead ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit/suggestion: Rather than using a ternary conditional here, it might be slightly more readable as 2 separate return statements?
if (typeahead) {
return <TypeaheadFacetDropdown />;
}
return <FacetDropdown />
padding: 5px; | ||
margin: 4px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, we'd should be using the spacing tokens provided by Bootstrap and the Paragon theme for padding/margin styles, e.g., "m-2" and "p-3".
Is there an explicit need to use hardcoded spacing values here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad habits :(
Let me look into this.
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 98%; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious] Why does the input only take up 98% of the width?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use width: 100%
than focused border goes outside the area of menu. Please see the search input box inside menu in below screenshots. @adamstankiewicz can you suggest a good solution for this?
Width set to 100%
Width set to 98%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muhammad-ammar A few things here...
.dropdown-menu {
.facet-list & {
padding: 50px 0 0;
max-height: none;
overflow: visible;
width: 420px;
}
}
I don't believe these above styles (^^) are actually doing anything as the ordering of these nested classes are actually reversed in the DOM (i.e., .dropdown-menu
is a child of .facet-list
however these styles are written to expect the reverse and won't apply as a result).
You shouldn't need to modify the positioning of the the "Find a skill..." input to be absolute or even specify a width for it as it should naturally fill up all available width. The scrollable items can just naturally sit underneath the default positioning of the input.
Modifying your styles locally, I landed on the following:
.typeahead {
.dropdown-menu {
max-height: unset;
.typeahead-dropdown-menu-scrollable-items {
max-height: 250px;
overflow-y: scroll;
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz The above styles are not working on my side. Please see the screenshot
I am not sure how to proceed on this. This is now blocked for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz I have checked with https://www.sassmeister.com/ and
.dropdown-menu {
.facet-list & {
padding: 50px 0 0;
max-height: none;
overflow: visible;
width: 420px;
}
}
will be converted to
.facet-list .dropdown-menu {
padding: 50px 0 0;
max-height: none;
overflow: visible;
width: 420px;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muhammad-ammar, I drafted this PR (could be merged into this PR) with more concrete style suggestions to simplify things a bit here after pulling your branch down locally and testing with the local checkout of frontend-enterprise: #80
It is primarily changes in _FacetList.scss and TypeaheadFacetDropdown.jsx though there's a couple other clean up things that could happen after upgrading Paragon to latest. Largely, it removes the unneeded absolute positioning on the typeahead input
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz Thank You! Can you share how you test/view style changes in frontend-enterprise
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muhammad-ammar If you pull the latest from master
in frontend-app-learner-portal-enterprise, you'll get some style updates that @raq929 merged today to import the styles from the frontend-enterprise
package (take a look at src/index.scss
to see the styles imported).
You'll also need to npm i -s lodash.debounce
into frontend-app-learner-portal-enterprise so the peerDependency introduced in frontend-enterprise
will resolve.
Then, checkout the branch from #80 in your local frontend-enterprise
(or merge it into your branch), and use the module.config.js approach you have been doing to alias @edx/frontend-enterprise
to your local checkout of the package.
You noted earlier that you need to run make build
any time you make changes in frontend-enterprise
. You could use the src
directory instead of dist
in module.config.js to get hot reloading working as you modify frontend-enterprise
, e.g.:
{ moduleName: '@edx/frontend-enterprise', dir: '../frontend-enterprise', dist: 'src' },
src/course-search/FacetListBase.jsx
Outdated
@@ -84,6 +99,12 @@ FacetListBase.propTypes = { | |||
isCheckedField: PropTypes.string, | |||
items: PropTypes.arrayOf(PropTypes.shape()).isRequired, | |||
title: PropTypes.string.isRequired, | |||
typeahead: PropTypes.shape({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/recommendation: I wonder if typeaheadOptions
might be a bit more understandable? My first thought at the name typeahead
is that it was a boolean variable, when it's actually an object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(unless this is one of those props coming from Algolia!)
@raq929 @adamstankiewicz I am blocked on this. I wanted to merge these yesterday no luck. There are 2 issues as we are discussing above
Below is how I developed and tested all the changes.
It would be great if I can get clear guidelines to fix the above issues so that I can merge this today. Thank You! |
db4cd0c
to
f57f57d
Compare
@adamstankiewicz Any concerns on merging this now? |
a5cf87e
to
76eb9a8
Compare
76eb9a8
to
fba72b9
Compare
@adamstankiewicz I have cherry picked your comment. Can you give a final look at the changes especially the |
Once these changes are released to NPM, in frontend-app-learner-portal-enterprise, you'll need to upgrade Example: |
fba72b9
to
f670c1d
Compare
Description: Add a new dropdown with search capability to filter the options. The dropdown will show names of skills offered by courses.
JIRA: https://openedx.atlassian.net/browse/ENT-4104
skills_filter_v2.mov