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(dropdown, select): add description element #3130

Merged
merged 23 commits into from
Jun 18, 2020

Conversation

christiemolloy
Copy link
Member

closes #3057

@patternfly-build
Copy link

patternfly-build commented May 22, 2020

@@ -0,0 +1,6 @@
<p class="pf-c-app-launcher__menu-item-description{{#if app-launcher-menu-item-description--modifier}} {{app-launcher-menu-item-description--modifier}}{{/if}}"
{{#if app-launcher-menu-item-description--attribute}}
{{{app-launcher-menu-item-description--attribute}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation is off

@@ -0,0 +1,6 @@
<p class="pf-c-app-launcher__menu-item-description{{#if app-launcher-menu-item-description--modifier}} {{app-launcher-menu-item-description--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since a <button> only accepts phrasing content, looks like this will need to be a <span>.

@@ -230,6 +234,10 @@
--pf-c-app-launcher__menu-item--m-action--Color: var(--pf-c-app-launcher__menu-item--m-action--hover--Color);
}
}

&.pf-m-description {
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... this is going to cause the styling between non-description and description items to be different. A good example is an item with favorites.

I wonder if this might be a use case for absolutely positioning a pseudo element of __menu-item relative to the parent li so it covers the entire li. Then placing the __menu-item-description element after __menu-item element. So technically they're different elements, but the pseudo element of the __menu-item covers the __menu-item-description element, so clicking on anywhere in the li triggers a click to the __menu-item.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried this and it works really well from what i can see!

@@ -246,6 +254,11 @@
}
}

.pf-c-app-launcher__menu-item-description {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is inheriting white-space: nowrap; Which forces the dropdown to become extra wide.

Screen Shot 2020-06-01 at 2 47 25 PM

Can you white-space: normal?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed now

Menu item disabled
{{#> app-launcher-menu-item-description}}
This is a description.
{{/ app-launcher-menu-item-description}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{/ app-launcher-menu-item-description}}
{{/app-launcher-menu-item-description}}

Menu item default
{{#> app-launcher-menu-item-description}}
This is a description.
{{/ app-launcher-menu-item-description}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{/ app-launcher-menu-item-description}}
{{/app-launcher-menu-item-description}}

Menu item with long description.
{{#> app-launcher-menu-item-description}}
This is a really long description that describes the menu item. This is a really long description that describes the menu item.
{{/ app-launcher-menu-item-description}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{/ app-launcher-menu-item-description}}
{{/app-launcher-menu-item-description}}


#ws-core-c-applauncher-with-description {
min-height: 300px;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}

{{{options-menu-menu-item-description--attribute}}}
{{/if}}>
{{> @partial-block}}
</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
</p>
</span>

@@ -0,0 +1,6 @@
<p class="pf-c-select__menu-item-description{{#if select-menu-item-description--modifier}} {{select-menu-item-description--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<p class="pf-c-select__menu-item-description{{#if select-menu-item-description--modifier}} {{select-menu-item-description--modifier}}{{/if}}"
<span class="pf-c-select__menu-item-description{{#if select-menu-item-description--modifier}} {{select-menu-item-description--modifier}}{{/if}}"

{{{select-menu-item-description--attribute}}}
{{/if}}>
{{> @partial-block}}
</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
</p>
</span>

@@ -58,6 +58,11 @@
--pf-c-options-menu__menu-item--disabled--Color: var(--pf-global--Color--dark-200);
--pf-c-options-menu__menu-item--hover--BackgroundColor: var(--pf-global--BackgroundColor--light-300);
--pf-c-options-menu__menu-item--disabled--BackgroundColor: transparent;
--pf-c-options-menu__menu-item--m-selected--PaddingRight: var(--pf-global--spacer--2xl);
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Top: 50%;
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Right: 1rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Right: 1rem;
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Right: var(--pf-global--spacer--md);

--pf-c-options-menu__menu-item--m-selected--PaddingRight: var(--pf-global--spacer--2xl);
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Top: 50%;
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Right: 1rem;
--pf-c-options-menu__menu-item--m-selected__menu-item-icon--Transform: -50%;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be: --pf-c-options-menu__menu-item--m-selected__menu-item-icon--TranslateY: -50%;?

@christiemolloy christiemolloy changed the title feat(dropdown, select, applauncher, optionsmenu): add description element feat(dropdown, select): add description element Jun 9, 2020
@@ -0,0 +1,6 @@
<span class="pf-c-dropdown__menu-item-description{{#if dropdown-menu-item-description--modifier}} {{dropdown-menu-item-description--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

use a <div>

@@ -0,0 +1,6 @@
<div class="pf-c-dropdown__menu-item-title{{#if dropdown-menu-item-title--modifier}} {{dropdown-menu-item-title--modifier}}{{/if}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I might just call this menu-item-text instead of menu-item-title

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry I read the code before looking at the examples and assumed it just wrapped the text. Maybe -main?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah that sounds good to me

}

.pf-c-dropdown__menu-item-title {
display: flex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... this is going to make text in the item in a regular dropdown (no description) and an item with a description display differently. I think this flex styling needs to be scoped to when .pf-m-icon is applied to the top level item. Though I see .pf-m-icon is missing from the item in these description examples. Is that intentional?

One way is we could move .pf-m-icon from .pf-c-dropdown__menu-item to .pf-c-dropdown__menu-item-title when a description is used, and update .pf-c-dropdown__menu-item.pf-m-icon { display: flex; align-items: center;} to include .pf-c-dropdown__menu-item-title.pf-m-icon.

You could also do something like this which might be easier on the react side:

li // has icon
  a.pf-c-dropdown__menu-item.pf-m-description.pf-m-icon // leaves .pf-m-icon on the top level menu-item with or without a description
    div.pf-c-dropdown__menu-item-title // or whatever you end up calling it
      span.pf-c-dropdown__menu-item-icon
        // some icon
      the dropdown item text
    div.pf-c-dropdown__menu-item-description
      the dropdown item description

li // no icon
  a.pf-c-dropdown__menu-item.pf-m-description
    div.pf-c-dropdown__menu-item-title // or whatever you end up calling it
      the dropdown item text
    div.pf-c-dropdown__menu-item-description
      the dropdown item description

And then the CSS

.pf-c-dropdown__menu-item {
  &.pf-m-description {
    flex-direction: column; // fixes the direction when `.pf-m-icon` is applied
       
    &.pf-m-icon {
      .pf-c-dropdown__menu-item-main {
        display: flex;
        align-items: center;
      }
    }
}

}

.pf-c-select__menu-item-description {
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this necessary?

@@ -346,6 +354,14 @@
right: 0;
}

&.pf-m-wrap {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this is the intention but is .pf-m-wrap added to the parent pf-c-select__menu element to allow its children items to wrap? Which allows the description to wrap under the menu-item-title element? If so wouldn't that mean that if .pf-m-wrap is used and some of the items have descriptions and others don't, all of the items will now wrap?

Also, that would require the react component to go back up to the parent __menu to add a class when one of its children meets some condition, which isn't ideal.

What about just adding .pf-m-description to all items with descriptions (not just ones that are selected, as it is currently), and we add white-space: normal; to them, then add .white-space: nowrap; to the __menu-item-title element?

Otherwise this lgtm!

.pf-c-dropdown__menu-item-main {
display: flex;
align-items: center;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this is still here and doesn't need to be since you added it when it's a child of .pf-c-dropdown__menu-item.pf-m-icon

| `.pf-m-active` | `.pf-c-dropdown__toggle` | Forces display of the active state of the toggle. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `.pf-m-active` | `.pf-c-dropdown__toggle` | Forces display of the active state of the toggle. |
| `.pf-m-active` | `.pf-c-dropdown__toggle` | Modifies the dropdown menu toggle for the active state. |

</button>
</li>
<li>
<button type="button" class="pf-c-select__menu-item pf-m-disabled" aria-pressed="false">
Copy link
Contributor

Choose a reason for hiding this comment

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

should you add disabled here?

--pf-c-select__menu-item-description--PaddingRight: var(--pf-c-select__menu-item--PaddingRight);

// Menu item title
--pf-c-select__menu-item-main--PaddingRight: var(--pf-global--spacer--2xl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be...

Suggested change
--pf-c-select__menu-item-main--PaddingRight: var(--pf-global--spacer--2xl);
--pf-c-select__menu-item-main--PaddingRight: var(--pf-c-select__menu-item--m-selected--PaddingRight);

@@ -395,6 +403,24 @@
&.pf-m-selected {
--pf-c-select__menu-item--PaddingRight: var(--pf-c-select__menu-item--m-selected--PaddingRight);
}

&.pf-m-description {
--pf-c-select__menu-item--m-selected--PaddingRight: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

and if you made the change above, this would change to

Suggested change
--pf-c-select__menu-item--m-selected--PaddingRight: 0;
--pf-c-select__menu-item--PaddingRight: 0;

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Nice!!

@mattnolting mattnolting self-requested a review June 18, 2020 21:27
Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

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

LPTM 🚢 it!

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

Successfully merging this pull request may close these issues.

4 participants