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

docs(Dropdown): add composable dropdown demo, convert composable menu demos to typescript #6807

Merged
merged 5 commits into from
Jan 20, 2022

Conversation

nicolethoen
Copy link
Contributor

Closes #6016

Adds the Composable Dropdown Variants demo to the Composable Menu demos

@patternfly-build
Copy link
Contributor

patternfly-build commented Jan 17, 2022

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

I think this looks good. My only question is that since this only represents four of many possible dropdown variants we support in the Dropdown component, do we need to include a note that this is only a sample of what you can do (vs. a complete list)?

Copy link
Contributor

@jessiehuff jessiehuff left a comment

Choose a reason for hiding this comment

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

This looks good to me from an a11y standpoint. It does remind me of pre-existing issues that Dropdown has though such as tooltips on dropdown items and the Append menu document body issue.


export const ComposableActionsMenu: React.FunctionComponent = () => {
const [isOpen, setIsOpen] = React.useState(false);
const [selectedItems, setSelectedItems] = React.useState([]);
Copy link
Contributor

@jpuzz0 jpuzz0 Jan 18, 2022

Choose a reason for hiding this comment

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

We can add a type to the useState of number[] here.

And based on a separate discussion we had, boolean to the one above it.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with adding a type to React.useState([]). Adding boolean to React.useState(false) seems redundant, considering this type is inferred

import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';

export const ComposableContextSelector: React.FunctionComponent = () => {
const items: any[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there no type associated with these or are they meant to be any?

@nicolethoen nicolethoen removed the request for review from kmcfaul January 19, 2022 16:16
@jpuzz0 jpuzz0 self-requested a review January 19, 2022 19:37
Copy link
Contributor

@jpuzz0 jpuzz0 left a comment

Choose a reason for hiding this comment

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

My comments aren't blocking. The demo looks good to me!

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Looks solid. I have one typing nit.

const [activeMenu, setActiveMenu] = React.useState<string>('rootMenu');
const [menuDrilledIn, setMenuDrilledIn] = React.useState<string[]>([]);
const [drilldownPath, setDrilldownPath] = React.useState<string[]>([]);
const [menuHeights, setMenuHeights] = React.useState<any>({});
Copy link
Contributor

@wise-king-sullyman wise-king-sullyman Jan 19, 2022

Choose a reason for hiding this comment

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

Nit: wouldn't this any be better typed with an index signature like { [id: string]: number }?

@nicolethoen
Copy link
Contributor Author

I have a pending question to @mattnolting

I’m noticing that the drilldown menu example here: https://patternfly-react-pr-6807.surge.sh/demos/composable-menu#composable-drilldown-menu has an extra scroll bar when I begin drilling down. We are setting the menu height correctly (i think) but is there some extra padding or something that isn’t being accounted for?

@nicolethoen
Copy link
Contributor Author

This is ready to go in (i think)

The issue I noted above in an existing bug with the drilldown menu - I noted it here: #6842

Copy link
Contributor

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

LGTM!

@nicolethoen
Copy link
Contributor Author

@mcarrano I opened an issue to build the split button that is required to implement the other dropdown variants. I am not sure if it is reasonable at this point to assume every single example will be exactly re-implemented composably... I think collectively, these demos are telling a story of how versatile our composable approach is. and people can open issues if they want to see more examples?

@mcarrano
Copy link
Member

@nicolethoen Yes, I agree. I don't think it's necessary to re-implement every example unless we are specifically asked for it.

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

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

lgtm. Just need to re-add the beta flag back to the menu drilldown example.

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.

LGTM! Just one thing. I'm inclined to keep what's in this PR and we make a couple of changes in core to make the element that will hold an icon or image in the toggle work better.

return (
<MenuToggle
ref={toggleRef}
icon={<Avatar src={avatarImg} alt="avatar" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we use .pf-c-menu-toggle__image in core for this versus .pf-c-menu-toggle__icon, though I don't know that we need both classes - curious if we could just use a single class for both.

Some other thoughts:

  1. .pf-c-menu-toggle__image shouldn't be used right now since there is a bug in the spacing - the right margin for the image isn't being applied, so the image will touch the adjacent text.
  2. the dropdown image toggle image element has some additional CSS. It applies a top/bottom margin, too, and uses inline-flex and flex-shrink: 0;. I'm not sure about the top/bottom margin, but I think the flex properties are good adds.
  • Screen Shot 2022-01-20 at 3 02 18 PM
  1. the image isn't really aligned. we could apply line-height: 1; align-self: center to the __image/icon element. This is what it looks like in the PR.
  • Screen Shot 2022-01-20 at 3 10 12 PM

I think we could just apply all of this to a single element that holds an icon or image. wdyt @mattnolting?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mcoker I actually added the flex-shrink prop in 4617 as the image was distorted when width became constrained. I agree, we only need one container element and it should be __image IMO.

I'm not sure about the top/bottom margin, but I think the flex properties are good adds.

We should nix top/bottom margin

the image isn't really aligned. we could apply line-height: 1; align-self: center to the __image/icon element. This is what it looks like in the PR.

👍 👍 👍

@kmcfaul kmcfaul merged commit 139eda6 into patternfly:main Jan 20, 2022
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • eslint-plugin-patternfly-react@4.31.6
  • @patternfly/react-catalog-view-extension@4.43.6
  • @patternfly/react-charts@6.45.6
  • @patternfly/react-code-editor@4.33.6
  • @patternfly/react-console@4.43.6
  • @patternfly/react-core@4.192.6
  • @patternfly/react-docs@5.53.6
  • @patternfly/react-icons@4.43.6
  • @patternfly/react-inline-edit-extension@4.37.6
  • demo-app-ts@4.152.6
  • @patternfly/react-integration@4.154.6
  • @patternfly/react-log-viewer@4.37.6
  • @patternfly/react-styles@4.42.6
  • @patternfly/react-table@4.61.6
  • @patternfly/react-tokens@4.44.6
  • @patternfly/react-topology@4.39.6
  • @patternfly/react-virtualized-extension@4.39.6
  • transformer-cjs-imports@4.30.6

Thanks for your contribution! 🎉

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

Successfully merging this pull request may close these issues.

Refactor Dropdown to use Menu Toggle and Menu