Feat/filter list display#686
Conversation
Cloudflare Pages preview
|
…tion-Commons/lang-nav into feat/filter-list-display # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
conradarcturus
left a comment
There was a problem hiding this comment.
Great! Looking really good. I'm glad the strange errors resolved with the new base. There are just some minor edits so I'll approve it so you can edit it and merge the code after you're ready rather than waiting for another review.
Also, you see the screenshot tests are failing -- after you make your updates add a tag to your PR update-baselines and it will update the screenshot tests with the new screenshots.
| // For FilterList: collapse to first N items unless expanded | ||
| const isFilterList = display === SelectorDisplay.FilterList; | ||
| const filterListCollapsed = | ||
| isFilterList && !expanded && options.length > FILTER_LIST_INITIAL_COUNT; |
There was a problem hiding this comment.
When there are 5 options, showing the first 4 and keeping the 5th hidden under this is a funny restriction, so let's only collapse the list when there are more than 5 options.
Funny thing, 3 of the 4 enum lists have 5 elements >_< in the future that won't always be the case! but yea it's funny today.
| isFilterList && !expanded && options.length > FILTER_LIST_INITIAL_COUNT; | |
| isFilterList && !expanded && options.length > FILTER_LIST_INITIAL_COUNT. +1; |
| toggle, | ||
| }) => { | ||
| const { display } = useSelectorDisplay(); | ||
| if (display !== SelectorDisplay.FilterList || totalCount <= FILTER_LIST_INITIAL_COUNT) |
There was a problem hiding this comment.
In line with the prior feedback, allow for 5 items -- only hide them if we're hiding 2 or more.
| if (display !== SelectorDisplay.FilterList || totalCount <= FILTER_LIST_INITIAL_COUNT) | |
| if (display !== SelectorDisplay.FilterList || totalCount <= FILTER_LIST_INITIAL_COUNT + 1) |
| width: fit-content; | ||
| border-width: 0.2em; | ||
| border-radius: 0.35em; | ||
| color: inherit; | ||
| cursor: pointer; | ||
| font-size: 0.9em; | ||
| padding: 0.25em 3.5em; |
There was a problem hiding this comment.
We can let this mostly match the global button default style. I think width and cursor are redundant. I'm not sure about the color -- I do like that it is black, but now it does not respond to the hover styling.
| width: fit-content; | |
| border-width: 0.2em; | |
| border-radius: 0.35em; | |
| color: inherit; | |
| cursor: pointer; | |
| font-size: 0.9em; | |
| padding: 0.25em 3.5em; | |
| font-size: 0.9em; | |
| padding: 0.25em 3.5em; |
| lineHeight: '1em', | ||
| lineHeight: '2.25em', // more spacing for visibility | ||
| alignItems: 'center', | ||
| fontWeight: 'bold', | ||
| fontWeight: '800', // adjusted font weight for easier visibility | ||
| padding: '0.5em', | ||
| margin: 'auto 0', // Vertically center | ||
| whiteSpace: 'nowrap', | ||
| borderRadius: '1em', | ||
| marginBottom: '-0.5em', // adjusted to have selector buttons closer to their label |
There was a problem hiding this comment.
You are affecting the selector buttons for other display types (for example, see the view options in the top-right gear menu).
Move the lineHeight and marginBottom styles down to case SelectorDisplay.FilterList:
Fixes #671
Summary: Replaced dropdown/button displays for enum filters with a new Filter List display mode that shows options as a compact vertical list, showing the first 4 with an "Expand All" toggle when there are 5 or more.
Out of scope/Future work: The dual meaning of expanded state (dropdown open vs filter list expanded) could be split into two separate state variables for clarity.
Test Plan and Screenshots
How to test the changes in this PR: Run npm run dev, open the Filter panel, then verify enum filters show as vertical lists and "Expand All" works.
Checklist
Feel free to check off or just delete items in this section as you have completed them.
Summary
Testing
npm run lintnpm run buildnpm run testnpm run dev-- tried out the website directlyChanges
Visual changes
Data changes
public/data/public/data/src/features/data/including how we aggregate data or compute derived valuesInternal changes
Docs