-
Notifications
You must be signed in to change notification settings - Fork 81
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
Refactor KBreadcrumbs to utilize KListWithOverflow #790
Conversation
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.
Hey @sruthin21! Thanks for your hard work. This is looking great! However my major concern is that we should make this change a non-breaking change, and avoid modifying the public API of the KBreadcrumbs and keep the external functionality the same as before.
One method to ensure that we are not breaking anything is to constantly check the KBreadcrumbs page http://localhost:4000/kbreadcrumbs and see that it looks and behave exactly the same as our current version of kbreadcrumbs which you can see in the production docs site https://design-system.learningequality.org/kbreadcrumbs/.
As you can see now we dont show the breadcrumbs in the docs page:
Before | After |
---|---|
export default { | ||
name: 'KBreadcrumbs', | ||
props: { | ||
breadcrumbs: { |
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.
Here we should not change the public API as this would be a breaking change, we should keep the same API as before, or at least that if we make any change to the API, that this is not a breaking change. So we should keep the items
and showSingleItem
props, and they should keep working exactly the same as before the refactor.
type: Boolean, | ||
default: false, | ||
}, | ||
import KListWithOverflow from './KListWithOverflow.vue'; |
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.
Here we dont need to import there components, as they are already registered in the Vue context, we can use it without it.
list.style.maxHeight = `${maxHeight}px`; | ||
|
||
this.setVisibleItems(directionIndexes, overflowItemsIdx); |
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.
We are not doing anything with this visibleItems
array. I would suggest to remove them. Also I dont note any added value of removing the maxWidth = Math.ceil(maxWidth);
sentence. I think we can keep these lines as before:
maxWidth = Math.ceil(maxWidth);
this.overflowItems = overflowItemsIdx.map(idx => this.items[idx]);
this.isMoreButtonVisible = overflowItemsIdx.length > 0;
list.style.maxWidth = `${maxWidth}px`;
list.style.maxHeight = `${maxHeight}px`;
},
@@ -152,29 +161,32 @@ | |||
itemsSizes.push(itemSize); | |||
} | |||
|
|||
if (this.overflowDirection === 'start') { | |||
itemsSizes.reverse(); |
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.
We dont need to reverse the itemSizes because we are already reverting the directionIndexes
, and when we iterate directionIndexes
, we are using the same index to access the list.children which is not reverted and the itemSizes which is reverted. So we are not matching the same information for the children and its size.
if (itemWidth >= availableWidth || overflowItemsIdx.length > 0) { | ||
overflowItemsIdx.push(i); | ||
item.style.visibility = 'hidden'; | ||
item.style.position = 'absolute'; | ||
list.children[i].style.visibility = 'hidden'; |
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 its better to revert this change and have the item
object to avoid repeating the list.children[i]
|
||
// If the item dont fit in the available space or if we have already |
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.
Lets keep these comments, as they are useful for new team members that doesnt know the logic here
@@ -195,11 +207,17 @@ | |||
maxWidth -= removedDividerWidth; |
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.
We need to also check the logic of the fix dividers Visibility, because for example here, when we have dividers, we can have this situation where some overflowed items are visible:
Compartir.pantalla.-.2024-09-28.10_26_02.mp4
@@ -276,5 +294,8 @@ | |||
.more-button-wrapper { | |||
visibility: hidden; | |||
} | |||
.more-button-wrapper.start-button { |
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.
We cant have this solution for the position of the button, because Keyboard navigation would not be the same. We need to keep the current behaviour in KBreadcrumbs that if the more button appears at the beginning, the keyboard navigation should focus it first, before the rest items.
Compartir.pantalla.-.2024-09-28.10_29_00.mp4
} | ||
|
||
.link { | ||
color: blue; |
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.
Here we shouldnt add color styles like these. We cant set burned colors, instead we need to use our brand colors, you can find the guides here.
Although, I think most of these styles arent really needed. Do they?
Also, a side note! When we open a PR we should keep and fill the form template that appears when we create the PR, not remove it, I have pasted it again to the PR description 🤗. |
Hey @sruthin21! Are you still interested in continuing working in this issue? |
Hi @sruthin21, by deleting your fork, unfortunately we won't be able to finish this PR. I will unassign you from #693, but feel free to message us and re-open if you'd like. |
Description
Task1
Task2
Issue addressed
Addresses #693.
Before/after screenshots
Changelog
Steps to test
(optional) Implementation notes
At a high level, how did you implement this?
Does this introduce any tech-debt items?
Testing checklist
Reviewer guidance
Comments