Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Svelte: add lines to directory groups#62981

Merged
camdencheek merged 3 commits into
mainfrom
cc/directory-lines
May 31, 2024
Merged

Svelte: add lines to directory groups#62981
camdencheek merged 3 commits into
mainfrom
cc/directory-lines

Conversation

@camdencheek

@camdencheek camdencheek commented May 30, 2024

Copy link
Copy Markdown
Member

This adds guidelines for open directories in the file tree. I recommend reviewing with whitespace changes hidden.

Fixes SRCH-443

Dark:
screenshot-2024-05-29_22-50-29@2x

Light:
screenshot-2024-05-29_22-50-54@2x

Test plan

Manual testing. This is one where a screenshot test would be really nice 🙂

@cla-bot cla-bot Bot added the cla-signed label May 30, 2024
</span>

<!-- We have to stop even propagation because the tree root listens for click events for
{#if expandable}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Slight change in behavior: instead of reserving space for the chevron icon so the file icon lines up with the folder icon, this lines up the file icon with the chevron of a sibling directory. This was necessary for the lines to make sense because we want the guideline to terminate at the file icon, not at an empty space in front of the file icon. This is visible in the screenshots.

Comment on lines +204 to +209
transform: translateX(
calc(
var(--tree-node-nested-level) * 1.25rem + var(--tree-node-left-padding) + var(--icon-inline-size) /
2 - 1px
)
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kinda a gnarly calculation, but it's using the same logic used to offset the labels within the list item.

@camdencheek camdencheek requested review from a team and taiyab May 30, 2024 04:58

@taiyab taiyab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great Camden. Awesome stuff! Really exciting update.

@taiyab taiyab requested a review from a team May 30, 2024 09:15

@vovakulikov vovakulikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Look good, I think there is only one small regression for the flat list items paddings
Compare

Before After
Screenshot 2024-05-30 at 11 28 52 Screenshot 2024-05-30 at 11 28 43

I left a comment on how this might be fixed below.

// since none of items is expandable, hence there aren't any offsets
:global([data-tree-view-flat-list='true']) & {
width: 0;
margin-left: 0.5rem;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic previously was giving additional left spacing for the flat list case
See my comment with screenshots above. I think we should add a special value
for the flat list selector

[role="treeitem"] {
   /* ... styles .... */
   
      :global([data-tree-view-flat-list='true']) & {
            --tree-node-left-padding: 2.75rem;
       }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, I see now! I was struggling to figure out how data-tree-view-flat-list was actulaly triggered. Will fixup 👍

@camdencheek camdencheek May 30, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay, fixed it. Now that we're not specially indenting files (compared to dirs), the calculation actually got quite a bit simpler. I think there are also some followup simplifications we could make to remove the absolute positioning and padding calculations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like we don't use data-tree-view-flat-list anywhere else, so we can remove the logic that sets it in TreeView.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes! Planning a followup PR with simplifications. I started doing it in this PR, but it got pretty noisy

@camdencheek camdencheek requested a review from vovakulikov May 30, 2024 17:13
// since none of items is expandable, hence there aren't any offsets
:global([data-tree-view-flat-list='true']) & {
width: 0;
margin-left: 0.5rem;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like we don't use data-tree-view-flat-list anywhere else, so we can remove the logic that sets it in TreeView.

@camdencheek camdencheek merged commit 52059fc into main May 31, 2024
@camdencheek camdencheek deleted the cc/directory-lines branch May 31, 2024 13:37
camdencheek added a commit that referenced this pull request Jun 4, 2024
After the changes to the file tree layout in #62981, we can clean up the styles and DOM a bit. These changes are partially in prep for experimenting with alternative "current path" representations. Comments inline.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants