-
Notifications
You must be signed in to change notification settings - Fork 381
feat(Toolbar,OverflowMenu): support responsive height vis breakpoints #12347
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
Open
kmcfaul
wants to merge
5
commits into
patternfly:main
Choose a base branch
from
kmcfaul:responsive-heights
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa6d829
feat(Toolbar,OverflowMenu): support responsive height vis breakpoints
kmcfaul fdd97ac
rebase and bump core for styling
kmcfaul eaab303
fix some examples
kmcfaul 179cd4a
update import to relative
kmcfaul be35ea3
clean up various examples, add warn for sm OverflowMenu vertical brea…
kmcfaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...act-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainerHeight.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import { useRef, useState } from 'react'; | ||
| import { | ||
| OverflowMenu, | ||
| OverflowMenuControl, | ||
| OverflowMenuContent, | ||
| OverflowMenuGroup, | ||
| OverflowMenuItem, | ||
| OverflowMenuDropdownItem, | ||
| MenuToggle, | ||
| Slider, | ||
| SliderOnChangeEvent, | ||
| Dropdown, | ||
| DropdownList | ||
| } from '@patternfly/react-core'; | ||
| import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; | ||
|
|
||
| export const OverflowMenuBreakpointOnContainerHeight: React.FunctionComponent = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [containerHeight, setContainerHeight] = useState(100); | ||
| const containerRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| const onToggle = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const onSelect = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const onChange = (_event: SliderOnChangeEvent, value: number) => { | ||
| setContainerHeight(value); | ||
| }; | ||
|
|
||
| const containerStyles = { | ||
| height: `${containerHeight}%`, | ||
| padding: '1rem', | ||
| borderWidth: '2px', | ||
| borderStyle: 'dashed' | ||
| }; | ||
|
|
||
| const dropdownItems = [ | ||
| <OverflowMenuDropdownItem itemId={0} key="item1" isShared> | ||
| Item 1 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={1} key="item2" isShared> | ||
| Item 2 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={2} key="item3" isShared> | ||
| Item 3 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={3} key="item4" isShared> | ||
| Item 4 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={4} key="item5" isShared> | ||
| Item 5 | ||
| </OverflowMenuDropdownItem> | ||
| ]; | ||
|
|
||
| return ( | ||
| <> | ||
| <div style={{ height: '100%', maxHeight: '400px' }}> | ||
| <div> | ||
| <span id="overflowMenu-hasBreakpointOnContainer-height-slider-label">Current container width</span>:{' '} | ||
| {containerHeight}% | ||
kmcfaul marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| <Slider | ||
| value={containerHeight} | ||
| onChange={onChange} | ||
| max={100} | ||
| min={20} | ||
| step={20} | ||
| showTicks | ||
| showBoundaries={false} | ||
| aria-labelledby="overflowMenu-hasBreakpointOnContainer-height-slider-label" | ||
| /> | ||
| </div> | ||
| <div ref={containerRef} id="height-breakpoint-reference-container" style={containerStyles}> | ||
| <OverflowMenu breakpointReference={containerRef} breakpoint="sm"> | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <OverflowMenuContent> | ||
| <OverflowMenuItem>Item 1</OverflowMenuItem> | ||
| <OverflowMenuItem>Item 2</OverflowMenuItem> | ||
| <OverflowMenuGroup> | ||
| <OverflowMenuItem>Item 3</OverflowMenuItem> | ||
| <OverflowMenuItem>Item 4</OverflowMenuItem> | ||
| <OverflowMenuItem>Item 5</OverflowMenuItem> | ||
| </OverflowMenuGroup> | ||
| </OverflowMenuContent> | ||
| <OverflowMenuControl> | ||
| <Dropdown | ||
| onSelect={onSelect} | ||
| toggle={(toggleRef) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| aria-label="Height breakpoint on container example overflow menu" | ||
| variant="plain" | ||
| onClick={onToggle} | ||
| isExpanded={isOpen} | ||
| icon={<EllipsisVIcon />} | ||
| /> | ||
| )} | ||
| isOpen={isOpen} | ||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
| > | ||
| <DropdownList>{dropdownItems}</DropdownList> | ||
| </Dropdown> | ||
| </OverflowMenuControl> | ||
| </OverflowMenu> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
76 changes: 76 additions & 0 deletions
76
packages/react-core/src/components/OverflowMenu/examples/OverflowMenuSimpleVertical.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { useState } from 'react'; | ||
| import { | ||
| OverflowMenu, | ||
| OverflowMenuControl, | ||
| OverflowMenuContent, | ||
| OverflowMenuGroup, | ||
| OverflowMenuItem, | ||
| OverflowMenuDropdownItem, | ||
| MenuToggle, | ||
| Dropdown, | ||
| DropdownList | ||
| } from '@patternfly/react-core'; | ||
| import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; | ||
|
|
||
| export const OverflowMenuSimpleVertical: React.FunctionComponent = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
|
|
||
| const onToggle = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const onSelect = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const dropdownItems = [ | ||
| <OverflowMenuDropdownItem itemId={0} key="item1" isShared> | ||
| Item 1 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={1} key="item2" isShared> | ||
| Item 2 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={2} key="item3" isShared> | ||
| Item 3 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={3} key="item4" isShared> | ||
| Item 4 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={5} key="item5" isShared> | ||
| Item 5 | ||
| </OverflowMenuDropdownItem> | ||
| ]; | ||
|
|
||
| return ( | ||
| <OverflowMenu breakpoint="lg" isVertical> | ||
| <OverflowMenuContent> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuGroup> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| </OverflowMenuGroup> | ||
| </OverflowMenuContent> | ||
| <OverflowMenuControl> | ||
| <Dropdown | ||
| onSelect={onSelect} | ||
| toggle={(toggleRef) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| aria-label="Simple example overflow menu" | ||
| variant="plain" | ||
| onClick={onToggle} | ||
| isExpanded={isOpen} | ||
| icon={<EllipsisVIcon />} | ||
| /> | ||
| )} | ||
| isOpen={isOpen} | ||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
| > | ||
| <DropdownList>{dropdownItems}</DropdownList> | ||
| </Dropdown> | ||
| </OverflowMenuControl> | ||
| </OverflowMenu> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.