Skip to content
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

updated lib/KListWithOverflow.vue and lib/KBreadcrumbs.vue #857

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

shruti862
Copy link
Contributor

Description

Updated lib/KListWithOverflow.vue and lib/KBreadcrumbs.vue files

Issue addressed

Addresses issue #693

Addresses #PR# HERE

Before/after screenshots

Changelog

  • Description: Summary of change(s)
  • Products impact: Choose from - none (for internal updates) / bugfix / new API / updated API / removed API. If it's 'none', use "-" for all items below to indicate they are not relevant.
  • Addresses: Link(s) to GH issue(s) addressed. Include KDS links as well as links to related issues in a consumer product repository too.
  • Components: Affected public KDS component. Do not include internal sub-components or documentation components.
  • Breaking: Will this change break something in a consumer? Choose from: yes / no
  • Impacts a11y: Does this change improve a11y or adds new features that can be used to improve it? Choose from: yes / no
  • Guidance: Why and how to introduce this update to a consumer? Required for breaking changes, appreciated for changes with a11y impact, and welcomed for non-breaking changes when relevant.

Steps to test

  1. Step 1
  2. Step 2
  3. ...

(optional) Implementation notes

At a high level, how did you implement this?

Does this introduce any tech-debt items?

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical and brittle code paths are covered by unit tests
  • The change is described in the changelog section above

Reviewer guidance

  • Is the code clean and well-commented?
  • Are there tests for this change?
  • Are all UI components LTR and RTL compliant (if applicable)?
  • Add other things to check for here

Comments

@MisRob MisRob marked this pull request as draft December 9, 2024 04:41
@MisRob
Copy link
Member

MisRob commented Dec 9, 2024

Converting to draft #693 (comment)

@MisRob
Copy link
Member

MisRob commented Dec 9, 2024

@shruti862 Also referencing @AlexVelezLl's comments that touches on some areas you mentioned, perhaps it helps #693 (comment)

@MisRob MisRob requested a review from AlexVelezLl December 9, 2024 08:54
@MisRob
Copy link
Member

MisRob commented Dec 9, 2024

@AlexVelezLl Hi Alex, @shruti862 continues this work and already followed some of your guidance. @shruti862 experienced some blockers and I asked to elaborate in this PR on some specific places. Would you please be available for giving a direction?

cd730f1

@shruti862
Copy link
Contributor Author

Screenshot from 2024-12-09 14-08-55
1.) Unable to get separators '>' between the items of list
2.) In the dropdown menu ,only the overflowed text is visible, link is not being applied.

@MisRob MisRob added the TODO: needs review Waiting for review label Dec 9, 2024
@AlexVelezLl
Copy link
Member

Thanks @shruti862! I will take a look later today :)

Copy link
Member

@AlexVelezLl AlexVelezLl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @shruti862!! This is a great start! I have left some instructions to solve the issues you were experiencing, along with some other things I noticed. Thank you!!

@@ -274,7 +284,15 @@
}

.more-button-wrapper {
visibility: hidden;
visibility: visible;
order: 0; /* Ensure it remains in its original position for keyboard navigation */
Copy link
Member

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.

@@ -274,7 +284,15 @@
}

.more-button-wrapper {
visibility: hidden;
visibility: visible;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm interested to know why is this change needed? The more button starts as hidden because we measure its width first, before doing the next computations, so to avoid it being visible for that first render we initialize its visibility as hidden.

@@ -129,6 +137,8 @@
*/
setOverflowItems() {
const { list, listWrapper, moreButtonWrapper } = this.$refs;

// Exit early if necessary refs are not available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove these comments, as the code itself is descriptive

const itemWidth = itemsSizes[i].width;

// If the item dont fit in the available space or if we have already
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets get back these comments that describes a behaviour a little bit more complex

lib/KListWithOverflow.vue Outdated Show resolved Hide resolved
appearance="raised-button"
>
<template #menu>
<!-- issue :: dropdown menu shows only text of the overflowItems but not the link , I don't know whether i am doing the right way to reference link or not -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this you can add these lines in KDropdownMenu:

https://github.com/shruti862/kolibri-design-system/blob/cd730f1821ceef5becb428b01d392dfdf1ae546c/lib/KDropdownMenu.vue#L20-L25

      <UiMenu 
        ref="menu" 
        :options="options" 
        :hasIcons="hasIcons" 
        @select="handleSelection" 
      >
        <template #option="{ option }">
          <slot name="option" :option="option"/>
        </template>
      </UiMenu>

And then you will be able to customize these dropdown options using this option slot in KDropdownMenu. There we can handle the link behaviour

}
// Add separators between items
return crumbs.flatMap((item, index) =>
index > 0 ? [{ type: 'separator' }, item] : [item]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason the dividers are not being visible is because we are passing this as type: "separator" while the correct name is type: "divider"

<style scoped>
.breadcrumbs-divider {
margin: 0 10px;
color: black; /* Adjust color for the ">" separator */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets standarize the name, and lets call it always "divider" instead of "separator"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, lets not use burned colors. Instead we can use our color tokens, we cant reference these in css, so we will need to set this color in the vue template

<!-- issue :: dropdown menu shows only text of the overflowItems but not the link , I don't know whether i am doing the right way to reference link or not -->
<KDropdownMenu
:options="overflowItems
.filter(item => item.type !== 'separator') // Filter out separators
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem "divider" instead of separator

.list-wrapper {
display: flex;
justify-content: space-between;
justify-content: space-between;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a alignItems: center instruction here, so the default behaviour is that the items are centered

@shruti862 shruti862 reopened this Dec 12, 2024
@shruti862
Copy link
Contributor Author

shruti862 commented Dec 12, 2024

Screenshot from 2024-12-12 19-01-41
@AlexVelezLl
I have fixed the keyboard navigation problem and alignment of list items when there is no more button in KListWithOverflow .
Now I am only facing problem in KBreadcrumb , my last visible item of list is getting outside of box even if there is enough space
left in list-wrapper box. Can you please help me resolving this issue?
Screenshot from 2024-12-12 19-03-45
One more thing I noticed that list items having links differ from whats in the https://design-system.learningequality.org/kbreadcrumbs/ page ,

@shruti862
Copy link
Contributor Author

Screenshot from 2024-12-12 19-12-52
when I mounted the items array , link is present on list tems which is not in the https://design-system.learningequality.org/kbreadcrumbs/ page

Copy link
Member

@AlexVelezLl AlexVelezLl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shruti862! Thanks! This is looking so much better! I have made some notes that will help to solve the issues that you are experiencing :).

Apologies for the late response 😅.

</slot>
<!-- @slot Slot responsible of rendering each item in the visible list -->
></slot>
<!-- Item Slot -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets gonna revert this change, this comment is useful for KDS docs:

Suggested change
<!-- Item Slot -->
<!-- @slot Slot responsible of rendering each item in the visible list -->

}

/* When the 'start-button' class is added, position visually at the start */
.more-button-wrapper.start-button {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this change is needed anymore, is it?

@@ -153,15 +177,13 @@
const itemSize = this.getSize(item);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue you are facing with the list width not being calculated correctly is because this getSize method currently doesnt support items with margins. So to fix this, lets rewrite this getSize method to something like this:

      getSize(element) {
        if (!element) {
          return { width: 0, height: 0 };
        }
        let { width, height } = element.getBoundingClientRect();

        const style = element.currentStyle || window.getComputedStyle(element);
        const marginX = parseFloat(style.marginLeft) + parseFloat(style.marginRight);
        const marginY = parseFloat(style.marginTop) + parseFloat(style.marginBottom);

        width += marginX;
        height += marginY;

        return { width, height };
      },

After this you wont see the list item in the next line when there is still space for it..

:to="item.link"
>

<template #text="{ text }">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that KRouterLink doesnt have a #text slot. So we just need to use the default slot here instead

@@ -153,15 +177,13 @@
const itemSize = this.getSize(item);
itemsSizes.push(itemSize);
}

const indexSequence = [...Array(list.children.length).keys()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of things that needs to be changed with this reversed behaviour:

  1. The fixDividersVisibility method. The intention of this method is to avoid that a divider is placed as the first or last item in the list. And here we calculate this lastVisibleIdx https://github.com/shruti862/kolibri-design-system/blob/01aededc7ac60f49278ebf9ff15db89d8aec0581/lib/KListWithOverflow.vue#L248 which will need to change when we are in reversed mode because the lastVisibleIdx is not the same in both cases.
  2. We have a couple of little bugs here and here, because we change the visibility of the item, but we need to change also the position to be position: absolute if the item is hidden, and position: unset when the item is visible. So, althoguh its not a regression of your PR, fixing this will prevent some bugs that become more apparent when we work with the overflowDirection as "start".

.breadcrumbs-divider {
margin-right: 8px;
margin-left: 8px;
color: #000000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets avoid burned color, and lets use the KDS color tokens instead https://design-system.learningequality.org/colors/#tokens-text

padding: 16px;
font-size: 16px;
font-weight: bold;
color: #4368f5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem, lets avoid burned colors

left: -1000em;
padding: 16px;
font-size: 16px;
color: #000000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants