-
Notifications
You must be signed in to change notification settings - Fork 63
Conversation
Comments from #591:
Answering @sarayourfriend question, content switcher and filter buttons should be a group that is always aligned to the right, like on desktop.
|
fb23e7b
to
ef989f4
Compare
0d967c1
to
910d7f0
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.
This is looking really good! It's noticeable that these components are broad in functionality and styles variants. I want to check some files in more detail to learn more from your approach :) but at a first glance seems pretty complete.
I'm just seeing that the VPageMenu
doesn't close after clicking on a link, it effectively navigates but the popover/full page modal keeps open, one has to click outside/close the modal to see the target page.
src/composables/use-scroll.js
Outdated
}) | ||
} | ||
|
||
return { y, isScrolled } |
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.
Doesn't this file serve the same purpose as use-window-scroll.js
?
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.
Their purposes are similar. At first, we were scrolling the whole window, but then we updated the layout so that it consists of a grid, in which the main content and the sidebar can be scrolled separately. This means that we can no longer detect if the header has scrolled or not by using window
's scroll offset, and need to get the main content scrollTop
instead. I did not remove the use-window-scroll.js
just yet. But if it turns out after all the redesign work that we don't, we should delete use-window-scroll.js
.
910d7f0
to
f701e65
Compare
827b20c
to
3407175
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.
Just one blocker on the areQueriesEqual
function and an invalid object literal comparison, but otherwise tests well and LGTM! Nice work!
emit('select', item) | ||
} | ||
|
||
const isLinkExternal = (item) => !item.link.startsWith('/') |
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.
Nice! This would be something we could add to the VButton
component as well 😮
audio: audioIcon, | ||
image: imageIcon, | ||
} | ||
export default function useContentType() { |
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 really like this way of encapsulating parts of Vuex into a composable. It feels really clean and creates a much nicer API for the components to work with. As a bonus I suspect this would make it easier to switch to pinia in the future.
src/store/search.js
Outdated
@@ -346,7 +346,9 @@ const actions = { | |||
} | |||
commit(CLEAR_OTHER_MEDIA_TYPE_FILTERS, { searchType }) | |||
} | |||
await dispatch(UPDATE_QUERY_FROM_FILTERS, queryParams) | |||
if (queryParams !== {}) { |
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.
This python-ism won't work in JavaScript 😢 If we need to test for an empty object there are two ways we could do it. Either we could test Object.keys(...).length
and check it for 0
(which I'm assuming has some caveats that I can't think of, it seems like it should work fine) or we could use the lodash.isEmpty
function.
export const areQueriesEqual = (oldQuery, newQuery) => { | ||
for (let key of Object.keys(oldQuery)) { | ||
if (oldQuery[key] !== newQuery[key]) { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
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.
Maybe this doesn't matter for queries but this wouldn't work if newQuery
has keys that aren't present in oldQuery
. For example, this will return true
for:
areQueriesEqual({}, { foo: 'bar' })
We could use lodash.isEqual
or else do something like is described in this SO answer after converting both arguments to Map objects or adapting that solution to just work on regular objects and avoid the conversion.
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.
@sarayourfriend, I added lodash.isEqual
. I was using this comparison because the queries were supposed to have the same structure, and the same number of properties. In fact, we probably won't need this comparison after the All content page is actually different from the Image page.
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.
Gotcha! I figured that maybe this specific consideration didn't matter for queries for that reason. Either way works for me!
Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
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.
LGTM!
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.
Works perfectly on a desktop layout! This is an incredible work 🌟
I noticed some issues on mobile, like the label of the content switcher button not changing, or the Openverse logo text not hiding on non-search pages, but I think those can be safely addressed in separate PR.
CleanShot.2022-01-18.at.12.33.15.mp4
# Conflicts: # src/locales/scripts/wp-locales.json
* Open filters in sidebar or modal from the header * Add layout changes from add/content_switcher * Add content switcher and internal page menu * Simplify header menu component * Remove NuxtLink from content type popover * Make ContentSwitcher more flexible * Set active content type using prop * Reuse components * Fix close button style * Small fixes to imports * Remove unused props * Update src/components/VContentSwitcher/VContentTypes.vue Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> * Fix query comparisons * Fix mobile content switcher button not changing Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
Fixes
Fixes #485 by @zackkrida
This PR adds the Content Switcher to the Header. This is a new version of #591 that does not have merge conflicts. It is also based off of the
filter_sidebar
branch, so it shouldn't be merged before that.Description
The
VContentSwitcher
component combines the Internal Page menu and the Content type switcher.There is also a
VPageMenu
component used on internal pages (eg.About
), where only the page menu, and not content switcher, are used.This component turned out to be very complex.
On mobile screens and on initial SSR, the page menu button does not show, and clicking the content switcher button opens a modal with the Content types menu and the Pages menu.
On larger screens, clicking the Pages menu button (ellipsis icon) opens up a Popover with links to internal pages, and clicking the Content type button opens up a Popover with different content types available. Clicking on the items changes the search content type, and closes the popover.
Issues
There is a problem with tabbing through the items in the mobile modal. I am not sure why they can't be tabbed through, it worked previously.
Testing Instructions
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin