-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(FEC-12957): Transcript Plugin - move download transcript inside t…
…he plugin menu and "release" the download button. Remove download and print icons Add popover menu for download and print Use close button from common
- Loading branch information
1 parent
1d250ec
commit d2c93cc
Showing
14 changed files
with
366 additions
and
176 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 was deleted.
Oops, something went wrong.
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
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,2 @@ | ||
import {PopoverMenu, PopoverMenuItemData} from './popover-menu'; | ||
export {PopoverMenu, PopoverMenuItemData}; |
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,73 @@ | ||
@import './variables.scss'; | ||
|
||
.popover-anchor-container { | ||
cursor: pointer; | ||
margin-left: 8px; | ||
border-radius: $roundness-1; | ||
|
||
&:hover { | ||
background-color: $tone-4-color; | ||
} | ||
|
||
&.active { | ||
background-color: $tone-6-color; | ||
} | ||
|
||
.popover-anchor { | ||
pointer-events: none; | ||
} | ||
} | ||
|
||
.popover-container { | ||
position: relative; | ||
|
||
.popover-component { | ||
background-color: $tone-7-color; | ||
border-radius: $roundness-1; | ||
display: block; | ||
font-size: 15px; | ||
margin-top: 6px; | ||
position: absolute; | ||
right: 0px; | ||
z-index: 1; | ||
|
||
&.hidden { | ||
display: none; | ||
} | ||
|
||
&.bottom { | ||
top: 100%; | ||
margin-top: 6px; | ||
} | ||
|
||
&.left { | ||
right: 0px; | ||
} | ||
} | ||
} | ||
.popover-menu-item { | ||
align-items: center; | ||
display: flex; | ||
font-size: 15px; | ||
line-height: 18px; | ||
min-height: 30px; | ||
padding: 9px 24px 9px 16px; | ||
white-space: nowrap; | ||
margin: 4px; | ||
|
||
&:hover { | ||
background-color: $tone-6-color; | ||
border-radius: $roundness-1; | ||
cursor: pointer; | ||
} | ||
|
||
&:focus { | ||
outline: 1px solid #222; | ||
} | ||
} | ||
|
||
.popover-menu { | ||
padding-top: 6px; | ||
padding-bottom: 6px; | ||
} | ||
|
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,107 @@ | ||
import {A11yWrapper} from '@playkit-js/common/dist/hoc/a11y-wrapper'; | ||
import {h, Component, VNode} from 'preact'; | ||
|
||
const {withEventManager} = KalturaPlayer.ui.Event; | ||
const {ENTER, ESC, SPACE} = KalturaPlayer.ui.utils.KeyMap; | ||
|
||
import * as styles from './popover-menu.scss'; | ||
|
||
interface PopoverMenuItemData { | ||
testId: string; | ||
label: string; | ||
onClick: () => void; | ||
} | ||
|
||
interface PopoverMenuProps { | ||
eventManager?: any; | ||
children?: VNode; | ||
items: Array<PopoverMenuItemData>; | ||
} | ||
|
||
interface PopoverMenuState { | ||
isOpen: boolean; | ||
} | ||
|
||
@withEventManager | ||
class PopoverMenu extends Component<PopoverMenuProps, PopoverMenuState> { | ||
private _controlElementRef: HTMLDivElement | null = null; | ||
private _popoverElementRef: HTMLDivElement | null = null; | ||
|
||
eventManager: any; | ||
|
||
constructor(props: PopoverMenuProps) { | ||
super(props); | ||
this.state = {isOpen: false}; | ||
|
||
this.props.eventManager?.listen(document, 'click', this.handleMouseEvent); | ||
this.props.eventManager?.listen(document, 'keydown', this.handleKeyboardEvent); | ||
} | ||
|
||
private handleMouseEvent = (event: MouseEvent) => { | ||
if (!this._controlElementRef?.contains(event.target as Node | null)) { | ||
this.closePopover(); | ||
} | ||
}; | ||
|
||
private handleKeyboardEvent = (event: KeyboardEvent) => { | ||
if (this._controlElementRef?.contains(event.target as Node | null) && [ENTER, SPACE].includes(event.keyCode)) { | ||
// use handler of control element | ||
event.preventDefault(); | ||
return; | ||
} | ||
if (this._popoverElementRef?.contains(event.target as Node | null) && event.keyCode !== ESC) { | ||
// use handler of popover element | ||
return; | ||
} | ||
this.closePopover(); | ||
}; | ||
|
||
private closePopover() { | ||
this.setState({isOpen: false}); | ||
} | ||
|
||
private togglePopover = () => { | ||
this.setState({isOpen: !this.state.isOpen}); | ||
}; | ||
|
||
render() { | ||
const {children, items} = this.props; | ||
|
||
return ( | ||
<div className={styles.popoverContainer}> | ||
<A11yWrapper onClick={this.togglePopover}> | ||
<div | ||
data-testid="popover-anchor-container" | ||
className={`${styles.popoverAnchorContainer} ${this.state.isOpen ? styles.active : ''}`} | ||
ref={node => { | ||
this._controlElementRef = node; | ||
}}> | ||
<div className={styles.popoverAnchor}>{children}</div> | ||
</div> | ||
</A11yWrapper> | ||
|
||
<div className={styles.popoverComponent} role="menu" aria-expanded={this.state.isOpen}> | ||
{this.state.isOpen | ||
? items.map(({label, onClick, testId}) => { | ||
return ( | ||
<A11yWrapper | ||
onClick={() => { | ||
this.closePopover(); | ||
onClick(); | ||
}}> | ||
{ | ||
<div tabIndex={0} role="menuitem" className={styles.popoverMenuItem} data-testid={testId}> | ||
{label} | ||
</div> | ||
} | ||
</A11yWrapper> | ||
); | ||
}) | ||
: null} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export {PopoverMenu, PopoverMenuItemData}; |
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,2 @@ | ||
import {TranscriptMenu} from './transcript-menu'; | ||
export {TranscriptMenu}; |
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,56 @@ | ||
import {Component, h} from 'preact'; | ||
import {PopoverMenu} from '../popover-menu'; | ||
import {PopoverMenuItemData} from '../popover-menu'; | ||
|
||
import {Button, ButtonType} from '@playkit-js/common/dist/components/button'; | ||
|
||
interface TranscriptMenuProps { | ||
printDownloadAreaLabel?: string; | ||
printTranscript?: string; | ||
downloadTranscript?: string; | ||
onDownload: () => void; | ||
onPrint: () => void; | ||
downloadDisabled?: boolean; | ||
printDisabled?: boolean; | ||
} | ||
|
||
interface TranscriptMenuState { | ||
isOpen: boolean; | ||
items: Array<PopoverMenuItemData>; | ||
} | ||
|
||
class TranscriptMenu extends Component<TranscriptMenuProps, TranscriptMenuState> { | ||
constructor(props: TranscriptMenuProps) { | ||
super(); | ||
|
||
const {downloadDisabled, onDownload, printDisabled, onPrint, printDownloadAreaLabel, printTranscript, downloadTranscript} = props; | ||
const items = []; | ||
if (!downloadDisabled) { | ||
items.push({ | ||
testId: 'download-menu-item', | ||
label: 'Download transcript', | ||
onClick: onDownload | ||
}); | ||
} | ||
|
||
if (!printDisabled) { | ||
items.push({ | ||
testId: 'print-menu-item', | ||
label: 'Print transcript', | ||
onClick: onPrint | ||
}); | ||
} | ||
|
||
this.state = {isOpen: false, items}; | ||
} | ||
|
||
render() { | ||
return this.state.items.length ? ( | ||
<PopoverMenu items={this.state.items}> | ||
<Button type={ButtonType.borderless} icon={'more'}></Button> | ||
</PopoverMenu> | ||
) : null; | ||
} | ||
} | ||
|
||
export {TranscriptMenu}; |
Oops, something went wrong.