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

📝 Update aria-label in Popover #2570

Merged
merged 5 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ const Demo = () => {

<Story id="data-display-popover--activate-on-hover"/>

### With Tooltip

<Story id="data-display-popover--with-tooltip"/>

### With close button

<ul>
Expand Down
114 changes: 32 additions & 82 deletions packages/eds-core-react/src/components/Popover/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Popover,
PopoverProps,
Icon,
Tooltip,
EdsProvider,
Density,
} from '../..'
Expand All @@ -20,7 +19,6 @@ import {
email,
home,
instrument,
more_vertical,
pipe_support,
platform,
settings,
Expand Down Expand Up @@ -77,27 +75,24 @@ export const Introduction: Story<PopoverProps> = (args) => {
<>
<Button
aria-haspopup
id="default-popover-anchor"
aria-controls="default-popover"
aria-expanded={isOpen}
ref={referenceElement}
onClick={handleOpen}
>
Click me!
Open popover
</Button>

<Popover
open={isOpen}
{...args}
id="default-popover"
anchorEl={referenceElement.current}
onClose={handleClose}
>
<Popover.Header>
<Popover.Title>Title</Popover.Title>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
<Typography variant="body_short">Popover content</Typography>
</Popover.Content>
<Popover.Actions>
<Button onClick={handleClose}>OK</Button>
Expand Down Expand Up @@ -126,26 +121,25 @@ export const ActivateOnClick: Story<PopoverProps> = () => {
return (
<>
<Button
id="click-popover-anchor"
aria-controls="click-popover"
aria-haspopup
aria-expanded={isOpen}
ref={anchorRef}
onClick={openPopover}
>
Click to activate
</Button>

<Popover
id="click-popover"
aria-expanded={isOpen}
anchorEl={anchorRef.current}
onClose={closePopover}
open={isOpen}
placement="top"
>
<Popover.Header>
<Popover.Title>Title</Popover.Title>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
<Typography variant="body_short">Popover content</Typography>
</Popover.Content>
<Popover.Actions>
<Button onClick={closePopover}>OK</Button>
Expand Down Expand Up @@ -187,8 +181,7 @@ export const ActivateOnHover: Story<PopoverProps> = () => {
return (
<>
<Button
id="hover-popover-anchor"
aria-controls="hover-popover"
aria-haspopup
aria-expanded={isOpen}
ref={anchorRef}
onMouseOver={handleHover}
Expand All @@ -199,7 +192,6 @@ export const ActivateOnHover: Story<PopoverProps> = () => {
</Button>

<Popover
id="hover-popover"
anchorEl={anchorRef.current}
onClose={handleClose}
open={isOpen}
Expand All @@ -209,7 +201,7 @@ export const ActivateOnHover: Story<PopoverProps> = () => {
<Popover.Title>Title</Popover.Title>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
<Typography variant="body_short">Popover content</Typography>
</Popover.Content>
<Popover.Actions>
<Button onClick={handleClose}>OK</Button>
Expand All @@ -229,46 +221,6 @@ ActivateOnHover.decorators = [
},
]

export const WithTooltip: Story<PopoverProps> = () => {
const [isOpen, setIsOpen] = useState<boolean>(false)
const anchorRef = useRef<HTMLButtonElement>(null)

const openPopover = () => setIsOpen(true)
const closePopover = () => setIsOpen(false)

return (
<>
<Tooltip title="Menu">
<Button ref={anchorRef} variant="ghost_icon" onClick={openPopover}>
<Icon data={more_vertical} />
</Button>
</Tooltip>
<Popover
anchorEl={anchorRef.current}
open={isOpen}
onClose={closePopover}
placement="top"
>
<Popover.Header>
<Popover.Title>Title</Popover.Title>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
</Popover.Content>
</Popover>
</>
)
}
WithTooltip.decorators = [
(Story) => {
return (
<Stack style={{ padding: '160px' }}>
<Story />
</Stack>
)
},
]

export const WithCloseButton: Story<PopoverProps> = () => {
const [isOpen, setIsOpen] = useState<boolean>(false)
const anchorRef = useRef<HTMLButtonElement>(null)
Expand All @@ -279,20 +231,19 @@ export const WithCloseButton: Story<PopoverProps> = () => {
return (
<>
<Button
id="click-popover-anchor"
aria-controls="click-popover"
aria-haspopup
aria-expanded={isOpen}
ref={anchorRef}
onClick={openPopover}
>
Click to activate
Open popover
</Button>

<Popover
id="click-popover"
aria-expanded={isOpen}
anchorEl={anchorRef.current}
onClose={closePopover}
open={isOpen}
placement="top"
>
<Popover.Header>
<Popover.Title>Title</Popover.Title>
Expand All @@ -306,7 +257,7 @@ export const WithCloseButton: Story<PopoverProps> = () => {
</Button>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
<Typography variant="body_short">Popover content</Typography>
</Popover.Content>
</Popover>
</>
Expand Down Expand Up @@ -347,20 +298,15 @@ export const PersistentPopover: Story<PopoverProps> = () => {
return (
<>
<Button
id="click-popover-anchor"
aria-controls="click-popover"
aria-haspopup
aria-expanded={isOpen}
ref={anchorRef}
onClick={openPopover}
>
Click to activate
Open popover
</Button>

<Popover
id="click-popover"
aria-expanded={isOpen}
anchorEl={anchorRef.current}
open={isOpen}
>
<Popover anchorEl={anchorRef.current} open={isOpen} placement="top">
<Popover.Header>
<Popover.Title>With Autocomplete</Popover.Title>
</Popover.Header>
Expand Down Expand Up @@ -402,26 +348,25 @@ export const Compact: Story<PopoverProps> = () => {
return (
<EdsProvider density={density}>
<Button
id="click-popover-anchor"
aria-controls="click-popover"
aria-haspopup
aria-expanded={isOpen}
ref={anchorRef}
onClick={openPopover}
>
Click to activate
Open popover
</Button>

<Popover
id="click-popover"
aria-expanded={isOpen}
anchorEl={anchorRef.current}
onClose={closePopover}
open={isOpen}
placement="top"
>
<Popover.Header>
<Popover.Title>Title</Popover.Title>
</Popover.Header>
<Popover.Content>
<Typography variant="body_short">Content</Typography>
<Typography variant="body_short">Popover content</Typography>
</Popover.Content>
<Popover.Actions>
<Button onClick={closePopover}>OK</Button>
Expand Down Expand Up @@ -471,11 +416,16 @@ export const AppLauncher: Story<PopoverProps> = () => {

return (
<>
<Tooltip title="App Launcher">
<Button ref={anchorRef} variant="ghost_icon" onClick={openPopover}>
<Icon data={apps} />
</Button>
</Tooltip>
<Button
aria-haspopup
aria-expanded={isOpen}
aria-label="app launcher"
ref={anchorRef}
variant="ghost_icon"
onClick={openPopover}
>
<Icon data={apps} />
</Button>
<Popover
anchorEl={anchorRef.current}
open={isOpen}
Expand Down