-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from rebeccaalpert/panel
Start investigating panel
- Loading branch information
Showing
8 changed files
with
457 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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 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 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,16 @@ | ||
import { Button } from '@patternfly/react-core'; | ||
import { TimesIcon } from '@patternfly/react-icons'; | ||
import * as React from 'react'; | ||
|
||
interface FlyoutHeaderProps { | ||
title: string; | ||
hideFlyout: () => void; | ||
} | ||
export const FlyoutHeader: React.FunctionComponent<FlyoutHeaderProps> = ({ title, hideFlyout }: FlyoutHeaderProps) => { | ||
return ( | ||
<div className="flyout-header"> | ||
{title} | ||
<Button onClick={hideFlyout} variant="plain" icon={<TimesIcon />} /> | ||
</div> | ||
); | ||
}; |
This file contains 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,39 @@ | ||
import { Button } from '@patternfly/react-core'; | ||
import * as React from 'react'; | ||
|
||
interface FlyoutStartScreenProps { | ||
image?: string; | ||
imageAlt?: string; | ||
title: string; | ||
subtitle?: string; | ||
primaryButtonText?: string; | ||
secondaryButtonText?: string; | ||
} | ||
|
||
export const FlyoutStartScreen: React.FunctionComponent<FlyoutStartScreenProps> = ({ | ||
image, | ||
imageAlt, | ||
subtitle, | ||
title, | ||
primaryButtonText, | ||
secondaryButtonText, | ||
}: FlyoutStartScreenProps) => { | ||
return ( | ||
<div className="start-screen"> | ||
{image && <img src={image} alt={imageAlt} />} | ||
<div className="start-screen-text"> | ||
<h1>{title}</h1> | ||
{subtitle && <p>{subtitle}</p>} | ||
</div> | ||
<div className="start-screen-actions"> | ||
{primaryButtonText && <Button>{primaryButtonText}</Button>} | ||
{secondaryButtonText && ( | ||
<> | ||
<p>or</p> | ||
<Button variant="secondary">{secondaryButtonText}</Button> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains 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,67 @@ | ||
import { FocusTrap } from '@patternfly/react-core'; | ||
import React from 'react'; | ||
|
||
interface FlyoutMenuProps { | ||
id: string; | ||
height: number; | ||
children: React.ReactNode; | ||
hideFlyout: () => void; | ||
} | ||
export const FlyoutMenu: React.FunctionComponent<FlyoutMenuProps> = ({ | ||
id, | ||
height, | ||
children, | ||
hideFlyout, | ||
}: FlyoutMenuProps) => { | ||
const previouslyFocusedElement = React.useRef<HTMLElement>(null); | ||
|
||
const handleFlyout = (event) => { | ||
const key = event.key; | ||
if (key === 'Escape') { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
hideFlyout(); | ||
} | ||
}; | ||
|
||
const focusTrapProps = { | ||
tabIndex: -1, | ||
'aria-modal': true, | ||
role: 'dialog', | ||
active: true, | ||
'aria-labelledby': id, | ||
focusTrapOptions: { | ||
onActivate: () => { | ||
if (previouslyFocusedElement.current !== document.activeElement) { | ||
//@ts-expect-error can't assign to current | ||
previouslyFocusedElement.current = document.activeElement; | ||
} | ||
}, | ||
onDeactivate: () => { | ||
previouslyFocusedElement.current && | ||
previouslyFocusedElement.current.focus && | ||
previouslyFocusedElement.current.focus(); | ||
}, | ||
clickOutsideDeactivates: true, | ||
returnFocusOnDeactivate: false, | ||
// FocusTrap's initialFocus can accept false as a value to prevent initial focus. | ||
// We want to prevent this in case false is ever passed in. | ||
initialFocus: undefined, | ||
escapeDeactivates: false, | ||
}, | ||
}; | ||
|
||
return ( | ||
<FocusTrap | ||
id={id} | ||
className="flyout-menu" | ||
style={{ | ||
height: `${height}px`, | ||
}} | ||
onKeyDown={handleFlyout} | ||
{...focusTrapProps} | ||
> | ||
{children} | ||
</FocusTrap> | ||
); | ||
}; |
Oops, something went wrong.