-
Notifications
You must be signed in to change notification settings - Fork 116
feat(theme): support navigating to nested categories in mobile side menu #709
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
Conversation
|
|
325114a to
86367f4
Compare
packages/theme/modules/catalog/category/components/sidebar/CategorySidebar.vue
Show resolved
Hide resolved
| @@ -0,0 +1,129 @@ | |||
| <template> | |||
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.
Loads of diffs because I just moved the file, but there were plenty of changes to the template and script
| router.push(path); | ||
| }; | ||
| const activeCategory: CategoryTreeInterface = findDeep(categoryTree.value, (value, key) => key === 'slug' && value === route.value.fullPath.replace('/default/c', ''))?.parent; |
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.
Note the ugly hack with the /default/c replace, but that's the closest I could find to a "unique id" to detect the current category.
ee65681 to
7296abf
Compare
|
|
a3d1e41 to
9dbab82
Compare
packages/theme/modules/catalog/category/components/sidebar/CategorySidebar.vue
Show resolved
Hide resolved
| import { CategoryTreeInterface } from '~/modules/catalog/category/types'; | ||
|
|
||
| export const useMobileCategoryTree = (initialHistory: CategoryTreeInterface[] = []) => { | ||
| const history = ref<CategoryTreeInterface[]>(initialHistory); |
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.
There's something really wrong with TypeScript here as it can't understand the <T = CategoryTreeInterface> syntax, so there's lots of duplication of types
packages/theme/modules/catalog/category/components/sidebar/command/categoryList.gql.ts
Show resolved
Hide resolved
|
need to resolve conflicts, sec |
| const activeCategoryAncestors = ref(null); | ||
| const isLoading = ref(true); | ||
| onMounted(async () => { |
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.
Shouldn't this be useAsync?
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.
Probably out of scope for this PR, but still
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.
The onMounted is good here, because we won't cache the category tree in Redis/cdn so they are loaded on the client-side.
Before this commit there were 2 issues: - Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files but this happened only when running tests with Jest (ts-jest) - TypeScript didn't know where to find the @types/jest (when using tsserver), so I changed the typeRoots to point to the parent pkg This is only a half-solution as I think if I used some composite configs it'd be more manageable fix(theme): squash this fix(theme): squash this
02cd541 to
9143eea
Compare
refactor(theme): refactor find active category function to return whole object squash this feat(theme): pinia working wip feat(theme): reorganize folders for helpers feat(theme): reduce duplication in graphql query feat(theme): adjust desktop and mobile categories fix(theme): fix invalid import paths
9143eea to
060fe77
Compare
packages/theme/modules/catalog/category/components/sidebar/CategorySidebar.vue
Show resolved
Hide resolved
| const activeCategoryAncestors = ref(null); | ||
| const isLoading = ref(true); | ||
| onMounted(async () => { |
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.
The onMounted is good here, because we won't cache the category tree in Redis/cdn so they are loaded on the client-side.
…enu (#709) * fix(theme): allow spec.ts files to be used Before this commit there were 2 issues: - Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files but this happened only when running tests with Jest (ts-jest) - TypeScript didn't know where to find the @types/jest (when using tsserver), so I changed the typeRoots to point to the parent pkg This is only a half-solution as I think if I used some composite configs it'd be more manageable fix(theme): squash this fix(theme): squash this * feat(theme): add nested categories in mobile category menu refactor(theme): refactor find active category function to return whole object squash this feat(theme): pinia working wip feat(theme): reorganize folders for helpers feat(theme): reduce duplication in graphql query feat(theme): adjust desktop and mobile categories fix(theme): fix invalid import paths
…enu (#709) * fix(theme): allow spec.ts files to be used Before this commit there were 2 issues: - Types from Cypress and Jest fighting for the `expect()` keyword in .spec.ts files but this happened only when running tests with Jest (ts-jest) - TypeScript didn't know where to find the @types/jest (when using tsserver), so I changed the typeRoots to point to the parent pkg This is only a half-solution as I think if I used some composite configs it'd be more manageable fix(theme): squash this fix(theme): squash this * feat(theme): add nested categories in mobile category menu refactor(theme): refactor find active category function to return whole object squash this feat(theme): pinia working wip feat(theme): reorganize folders for helpers feat(theme): reduce duplication in graphql query feat(theme): adjust desktop and mobile categories fix(theme): fix invalid import paths
Description
Add the ability to enter subcategories from the side menu on mobile
Before this PR you could only access top level categories like Men, Women, Gear, but now you can enter eg. Men>Tops>Jackets
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Screen.Recording.2022-03-10.at.12.55.52.mov
Types of changes
Checklist: