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

feat: refactor side navigation #380

Merged
merged 13 commits into from
Oct 30, 2019
Merged

Conversation

InnaAtanasova
Copy link
Contributor

@InnaAtanasova InnaAtanasova commented Oct 21, 2019

Related Issue

Closes #207

Description

  • added a new (INTERNAL for the lib) reusable component called Nested list which will allow multiple levels of nesting (up to 10)
  • use the Nested List component in Side Navigation component
  • refactor the Side Nav component to match the latest specs
  • The Side nav now has 2 sections - Main Section and Utility Section. Each of these sections has a Nested List for displaying the navigation items.

BREAKING CHANGES

  • Removed classes: fd-side-nav__list, fd-side-nav__item, fd-side-nav__link, fd-side-nav__group, fd-side-nav__title, fd-side-nav__sublist, fd-side-nav__subitem, fd-side-nav__sublink, fd-side-nav__icon, fd-side-nav--icons

@netlify
Copy link

netlify bot commented Oct 21, 2019

Deploy preview for fundamental-styles ready!

Built with commit 873711f

https://deploy-preview-380--fundamental-styles.netlify.com

@droshev droshev added the Enhancement New feature or request label Oct 21, 2019
@droshev droshev added this to the sprint 22 - Gendry milestone Oct 21, 2019
@bcullman
Copy link
Contributor

Should this even be needed?

With proper CSS, any li that is a direct child of a li ul can be set to indented - no need for an indented class or a collection of classes to name what level deep your are

@bcullman
Copy link
Contributor

bcullman commented Oct 22, 2019

note that plain old html indents children

<html>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3
            <ul>
                <li>a</li>
                <li>b</li>
                <li>c
                    <ul>
                        <li>i</li>
                        <li>ii</li>
                        <li>iii</li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</body>
</html>

Copy link
Contributor

@markpalfreeman markpalfreeman left a comment

Choose a reason for hiding this comment

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

@greg-a-smith how does this jive with the work you did on standard List?

Are we trying to only create fundamental-styles "components" that match to UI5 controls? If so, I'm not sure we need a NestedList as a separate one unless we're actually planning to reuse it somewhere else besides SideNavigation.

speak: none;
}

@mixin fd-flex-center {
Copy link
Contributor

Choose a reason for hiding this comment

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

This would probably better live in a shared utilities folder, as it's not particular to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


.#{$block}__link,
.#{$block}__content {
padding-left: $paddingLeft;
Copy link
Contributor

@markpalfreeman markpalfreeman Oct 22, 2019

Choose a reason for hiding this comment

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

As @bcullman mentioned previously, I don't think we want to be determining the "level" of nesting and calculating padding for each form the outer-most point... wouldn't it be preferred to instead put padding on each "parent" ul (with some modifier like .fd-list--expandable) and let the children indent themselves (recursively)? It would eliminate the need for this custom math.

As a visible example from UI5:
Screen Shot 2019-10-22 at 9 31 03 AM

Copy link
Contributor Author

@InnaAtanasova InnaAtanasova Oct 22, 2019

Choose a reason for hiding this comment

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

Yes, in most of the cases this would be the approach, but not in this one. If you add padding to the ul element then the selected and hover styling of the subitems (children) wouldn't be correct. The background color and the underline border should go to the ends of the Navigation list.
Here is how it looks now:
Screen Shot 2019-10-22 at 1 25 50 PM

Here is the case when we add padding to the ul element and don't do the calculations
Screen Shot 2019-10-22 at 1 29 20 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, I didn't see the hover/active states previously.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't know that we want the consumers of this to have to keep track of the "level" of indentation in their markup to supply the correct class.

Seems like using parent/child relationship selectors allows consumers to just apply classes more generically, and the CSS is smart enough to style itself, like:

.list
    .list__item
    .list__item
        .list__item
        .list
            .list__item
            .list__item
        .list__item
    .list__item

@InnaAtanasova
Copy link
Contributor Author

Should this even be needed?

With proper CSS, any li that is a direct child of a li ul can be set to indented - no need for an indented class or a collection of classes to name what level deep your are

@bcullman , applying padding to the li adds indentation but doesn't have the correct styling for hover, is-selected and focus state.
Screen Shot 2019-10-22 at 1 36 39 PM

@droshev
Copy link
Contributor

droshev commented Oct 22, 2019

to only create fundamental-styles "components" that match to UI5 controls? If so, I'm not sure we need a NestedList as a separate one unless we're actuall

@markpalfreeman It is not only needed for the side navigation and we are not first creating that. UI5 has different components too

@InnaAtanasova
Copy link
Contributor Author

InnaAtanasova commented Oct 22, 2019

@greg-a-smith how does this jive with the work you did on standard List?

Are we trying to only create fundamental-styles "components" that match to UI5 controls? If so, I'm not sure we need a NestedList as a separate one unless we're actually planning to reuse it somewhere else besides SideNavigation.

@markpalfreeman , my approach at the beginning was to refactor the List component and achieve the nesting there. But it required too many changes. For starters, the current implementation uses flex for situating the icons and text. This causes problems when you add a ul inside the fd-list__item.
Second, you can "mix" items with and without icons, and the items without icons should have the same text alignment as the items with icons.
Third, the "after" icon (the arrow) should be dynamic - it should have different states when the child list is expanded and not-expanded. This can't be achieve with CSS and the current implementation of the List.
The list items should be links. The list item in List component is just an icon plus text, it doesn't have a link
Screen Shot 2019-10-22 at 2 04 15 PM

Copy link
Contributor

@markpalfreeman markpalfreeman left a comment

Choose a reason for hiding this comment

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

If we go forward with Nested List, I think tit'd be the first time this library would be exporting a non-Fiori3 component and referencing it in public docs/navigation.

If this is something that needs to be shared in multiple places, my preference would be to use it as a sass mixin that gets brought into the components that need it, but the class names stay aligned to Fiori3 components so we have a 1:1 match.

Probably worth deciding as a team, but to me it gets confusing if we start creating "non-standard" components here—how do we keep track of which ones are Fiori3 and which ones are "helpers"?


.#{$block}__link,
.#{$block}__content {
padding-left: $paddingLeft;
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't know that we want the consumers of this to have to keep track of the "level" of indentation in their markup to supply the correct class.

Seems like using parent/child relationship selectors allows consumers to just apply classes more generically, and the CSS is smart enough to style itself, like:

.list
    .list__item
    .list__item
        .list__item
        .list
            .list__item
            .list__item
        .list__item
    .list__item

@InnaAtanasova InnaAtanasova changed the title feat: new component nested list, refactor side navigation feat: refactor side navigation Oct 24, 2019
Copy link
Contributor

@markpalfreeman markpalfreeman left a comment

Choose a reason for hiding this comment

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

Thanks Inna! I have a few pending questions and would still prefer someone with more familiarity to chime in if possible 😄


$block: #{$fd-namespace}-nested-list;

@mixin fd-side-nav-arrow {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since this is nested-list.scss, this is probably better named fd-nested-list-arrow to not couple to the "side-nav" concept

}
}

&[aria-hidden="true"] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want an additional .is-hidden class to not fully rely on aria attributes for styles?

Copy link
Contributor

Choose a reason for hiding this comment

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

so I think we never fully decided how we want to handle all the aria-selectors. We've got it implemented many ways across components with no real standard. We should figure this out in general, but maybe not here.

list-style: none;
width: 100%;

@for $i from 2 through 10 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if my previous comment got lost or if I forgot to post it, but do we want consuming libraries to have to calculate .level-# for classes?

I love that this is a mixin, but it seems like a preferred hierarchy would just be something like this, and the styles would be ready to support all tiers of parent/child relationship (and padding size) up to a certain level.

Thoughts from the rest of the team? (pseudo-code)

.list
    .list__item
    .list__item
        .list
            .list__item
            .list__item
       ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Brad did rightly mention, though, that the tradeoff for this is making really deep parent-child selectors in the CSS 😕

.list > .list__item > list > .list__item {} etc

I'm not sure which is best

Copy link
Contributor

Choose a reason for hiding this comment

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

@markpalfreeman what would you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just leave it like this; both ways have tradeoffs.

@markpalfreeman markpalfreeman dismissed their stale review October 25, 2019 18:44

Primary issue addressed, new set of questions

Copy link
Contributor

@greg-a-smith greg-a-smith left a comment

Choose a reason for hiding this comment

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

Appears that a few things aren't self-contained for styling yet (see screenshot).
Screen Shot 2019-10-25 at 2 41 41 PM

@InnaAtanasova
Copy link
Contributor Author

Appears that a few things aren't self-contained for styling yet (see screenshot).
Screen Shot 2019-10-25 at 2 41 41 PM

Hi @greg-a-smith ,
I added a reset for the TEST list items.

Screen Shot 2019-10-28 at 2 01 09 PM

Screen Shot 2019-10-28 at 2 01 02 PM

margin: 0;
border: 0;
list-style: none;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These shouldn't be necessary, should they? The playground is supposed to demonstrate the component and its styles. The "test" classes are for extraneous components included within another component (e.g. buttons in an action bar or modal, icons in a panel, etc.)

)}}
{% endset %}
{{ format(example) }}
<h2>Nested List Without Icons</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

All these nested list examples should be in their own page: test/templates/nested-list/index.njk. This file should only have the examples that show the fd-side-nav* classes.

Copy link
Contributor

@greg-a-smith greg-a-smith left a comment

Choose a reason for hiding this comment

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

Looks good. 🚢

@InnaAtanasova InnaAtanasova merged commit 9ab0628 into master Oct 30, 2019
@InnaAtanasova InnaAtanasova deleted the feat/nested-list__side-nav branch October 30, 2019 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Side Navigation styling inconsistency with Fiori 3
6 participants