-
Notifications
You must be signed in to change notification settings - Fork 116
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
chore(deps): Upgrade React dependencies to v17 #1334
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
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
32 changes: 0 additions & 32 deletions
32
src/lib/viewers/controls/hooks/__tests__/usePreventKey-test.tsx
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default as useAttention } from './useAttention'; | ||
export { default as useFullscreen } from './useFullscreen'; | ||
export { default as usePreventKey } from './usePreventKey'; |
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import React from 'react'; | ||
import usePreventKey from '../hooks/usePreventKey'; | ||
import { decodeKeydown } from '../../../util'; | ||
|
||
export type Props = React.ButtonHTMLAttributes<HTMLButtonElement>; | ||
|
||
export default function MediaToggle(props: Props): JSX.Element { | ||
const buttonElRef = React.useRef<HTMLButtonElement>(null); | ||
const handleKeydown = (event: React.KeyboardEvent): void => { | ||
const key = decodeKeydown(event); | ||
|
||
usePreventKey(buttonElRef, ['Enter', 'Space']); | ||
if (key === 'Enter' || key === 'Space') { | ||
event.stopPropagation(); | ||
} | ||
}; | ||
|
||
return <button ref={buttonElRef} type="button" {...props} />; | ||
return <button onKeyDown={handleKeydown} type="button" {...props} />; | ||
} |
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 |
---|---|---|
|
@@ -6,9 +6,9 @@ import IconVolumeLow24 from '../icons/IconVolumeLow24'; | |
import IconVolumeMedium24 from '../icons/IconVolumeMedium24'; | ||
import IconVolumeMute24 from '../icons/IconVolumeMute24'; | ||
import MediaToggle from './MediaToggle'; | ||
import SliderControl, { Ref as SliderControlRef } from '../slider'; | ||
import SliderControl from '../slider'; | ||
import useAttention from '../hooks/useAttention'; | ||
import usePreventKey from '../hooks/usePreventKey'; | ||
import { decodeKeydown } from '../../../util'; | ||
import './VolumeControls.scss'; | ||
|
||
export type Props = { | ||
|
@@ -33,12 +33,20 @@ export function getIcon(volume: number): (props: React.SVGProps<SVGSVGElement>) | |
|
||
export default function VolumeControls({ onMuteChange, onVolumeChange, volume = 1 }: Props): JSX.Element { | ||
const [isActive, handlers] = useAttention(); | ||
const inputElRef = React.useRef<SliderControlRef>(null); | ||
const isMuted = !volume; | ||
const Icon = isMuted ? IconVolumeMute24 : getIcon(volume); | ||
const title = isMuted ? __('media_unmute') : __('media_mute'); | ||
const value = Math.round(volume * 100); | ||
|
||
const handleKeydown = (event: React.KeyboardEvent): void => { | ||
const key = decodeKeydown(event); | ||
|
||
// Allow the range input to handle its own left/right keydown events | ||
if (key === 'ArrowLeft' || key === 'ArrowRight') { | ||
event.stopPropagation(); // Prevents global key handling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this comment be applied above to |
||
} | ||
}; | ||
|
||
const handleMute = (): void => { | ||
onMuteChange(!isMuted); | ||
}; | ||
|
@@ -47,9 +55,6 @@ export default function VolumeControls({ onMuteChange, onVolumeChange, volume = | |
onVolumeChange(newValue / 100); | ||
}; | ||
|
||
// Allow the range input to handle its own left/right keydown events | ||
usePreventKey(inputElRef, ['ArrowLeft', 'ArrowRight']); | ||
|
||
return ( | ||
<div className="bp-VolumeControls"> | ||
<MediaToggle className="bp-VolumeControls-toggle" onClick={handleMute} title={title} {...handlers}> | ||
|
@@ -58,9 +63,9 @@ export default function VolumeControls({ onMuteChange, onVolumeChange, volume = | |
|
||
<div className={classNames('bp-VolumeControls-flyout', { 'bp-is-open': isActive })}> | ||
<SliderControl | ||
ref={inputElRef} | ||
className="bp-VolumeControls-slider" | ||
onChange={handleVolume} | ||
onKeyDown={handleKeydown} | ||
title={__('media_volume_slider')} | ||
track={`linear-gradient(to right, ${bdlBoxBlue} ${value}%, ${white} ${value}%)`} | ||
value={value} | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉