-
Notifications
You must be signed in to change notification settings - Fork 97
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
Conversation
Preview: https://patternfly-pr-3130.surge.sh A11y report: https://patternfly-pr-3130-coverage.surge.sh |
@@ -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}}} |
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.
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}}" |
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.
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; |
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.
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
.
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.
Tried this and it works really well from what i can see!
@@ -246,6 +254,11 @@ | |||
} | |||
} | |||
|
|||
.pf-c-app-launcher__menu-item-description { |
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.
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.
fixed now
Menu item disabled | ||
{{#> app-launcher-menu-item-description}} | ||
This is a description. | ||
{{/ app-launcher-menu-item-description}} |
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.
{{/ 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}} |
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.
{{/ 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}} |
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.
{{/ app-launcher-menu-item-description}} | |
{{/app-launcher-menu-item-description}} |
|
||
#ws-core-c-applauncher-with-description { | ||
min-height: 300px; | ||
} |
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.
} | |
} | |
{{{options-menu-menu-item-description--attribute}}} | ||
{{/if}}> | ||
{{> @partial-block}} | ||
</p> |
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.
</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}}" |
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.
<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> |
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.
</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; |
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.
--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%; |
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.
Should this be: --pf-c-options-menu__menu-item--m-selected__menu-item-icon--TranslateY: -50%;
?
@@ -0,0 +1,6 @@ | |||
<span class="pf-c-dropdown__menu-item-description{{#if dropdown-menu-item-description--modifier}} {{dropdown-menu-item-description--modifier}}{{/if}}" |
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.
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}}" |
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 might just call this menu-item-text
instead of menu-item-title
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.
Oh sorry I read the code before looking at the examples and assumed it just wrapped the text. Maybe -main
?
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.
yeah that sounds good to me
} | ||
|
||
.pf-c-dropdown__menu-item-title { | ||
display: flex; |
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.
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; |
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.
is this necessary?
@@ -346,6 +354,14 @@ | |||
right: 0; | |||
} | |||
|
|||
&.pf-m-wrap { |
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.
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; | ||
} |
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.
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. | |
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.
| `.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"> |
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.
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); |
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.
Should this be...
--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; |
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.
and if you made the change above, this would change to
--pf-c-select__menu-item--m-selected--PaddingRight: 0; | |
--pf-c-select__menu-item--PaddingRight: 0; |
fix(select, dropdown): updates to description
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.
Nice!!
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.
LPTM 🚢 it!
closes #3057