-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c691624
commit 89f1fef
Showing
12 changed files
with
502 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React, { Component, HTMLAttributes } from 'react'; | ||
import { EuiComment } from '../../../../src/components/comment'; | ||
import { EuiButtonIcon } from '../../../../src/components/button'; | ||
import { EuiText } from '../../../../src/components/text'; | ||
import { EuiPopover } from '../../../../src/components/popover'; | ||
import { | ||
EuiContextMenuPanel, | ||
EuiContextMenuItem, | ||
} from '../../../../src/components/context_menu'; | ||
import { CommonProps } from '../../../../src/components/common'; | ||
|
||
const body = ( | ||
<EuiText size="s"> | ||
<p> | ||
This comment has custom actions available. See the upper right corner. | ||
</p> | ||
</EuiText> | ||
); | ||
|
||
export type CustomActionsProps = HTMLAttributes<HTMLDivElement> & | ||
CommonProps & {}; | ||
|
||
interface CustomActionsState { | ||
isPopoverOpen: boolean; | ||
} | ||
|
||
export default class extends Component< | ||
// export class CustomActions extends Component< | ||
CustomActionsProps, | ||
CustomActionsState | ||
> { | ||
state = { | ||
isPopoverOpen: false, | ||
}; | ||
|
||
togglePopover = () => { | ||
this.setState(prevState => ({ | ||
isPopoverOpen: !prevState.isPopoverOpen, | ||
})); | ||
}; | ||
|
||
closePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: false, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { isPopoverOpen } = this.state; | ||
const customActions = ( | ||
<EuiPopover | ||
// id={`${item.id}-actions`} | ||
button={ | ||
<EuiButtonIcon | ||
aria-label="Actions" | ||
iconType="gear" | ||
size="s" | ||
color="text" | ||
onClick={() => this.togglePopover()} | ||
/> | ||
} | ||
isOpen={isPopoverOpen} | ||
closePopover={() => this.closePopover()} | ||
panelPaddingSize="none" | ||
anchorPosition="leftCenter"> | ||
<EuiContextMenuPanel | ||
items={[ | ||
<EuiContextMenuItem | ||
key="A" | ||
icon="pencil" | ||
onClick={() => { | ||
this.closePopover(); | ||
}}> | ||
Edit | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
key="B" | ||
icon="share" | ||
onClick={() => { | ||
this.closePopover(); | ||
}}> | ||
Share | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
key="C" | ||
icon="copy" | ||
onClick={() => { | ||
this.closePopover(); | ||
}}> | ||
Copy | ||
</EuiContextMenuItem>, | ||
]} | ||
/> | ||
</EuiPopover> | ||
); | ||
return ( | ||
<div> | ||
<EuiComment | ||
username="janed" | ||
event="added a comment" | ||
actions={customActions} | ||
timestamp="Jan 1, 2020"> | ||
{body} | ||
</EuiComment> | ||
</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
Oops, something went wrong.