Skip to content

Commit

Permalink
fix(player): keyboard display should not show empty icons
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Jun 7, 2024
1 parent 4b0e109 commit 008141d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/components/layouts/default/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,5 @@ export interface DefaultLayoutIcons {
SeekButton: DefaultSeekButtonIcons;
DownloadButton?: DefaultDownloadButtonIcons;
Menu: DefaultMenuIcons;
KeyboardDisplay?: DefaultKeyboardDisplayIcons;
KeyboardDisplay?: Partial<DefaultKeyboardDisplayIcons>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { DefaultKeyboardDisplayIcons } from '../icons';

export interface DefaultKeyboardDisplayProps
extends Omit<PrimitivePropsWithRef<'div'>, 'disabled'> {
icons: DefaultKeyboardDisplayIcons;
icons: Partial<DefaultKeyboardDisplayIcons>;
}

const DefaultKeyboardDisplay = React.forwardRef<HTMLElement, DefaultKeyboardDisplayProps>(
Expand Down Expand Up @@ -54,7 +54,7 @@ const DefaultKeyboardDisplay = React.forwardRef<HTMLElement, DefaultKeyboardDisp
};
}, [$lastKeyboardAction]);

return (
return Icon ? (
<Primitive.div
{...props}
className={className}
Expand All @@ -65,14 +65,12 @@ const DefaultKeyboardDisplay = React.forwardRef<HTMLElement, DefaultKeyboardDisp
<div className="vds-kb-text">{$text}</div>
</div>
<div className="vds-kb-bezel" key={count}>
{Icon ? (
<div className="vds-kb-icon">
<Icon />
</div>
) : null}
<div className="vds-kb-icon">
<Icon />
</div>
</div>
</Primitive.div>
);
) : null;
},
);

Expand All @@ -98,7 +96,7 @@ function getVolumeText(volume: number, gain: number) {
return `${Math.round(volume * gain * 100)}%`;
}

function getIcon(Icons: DefaultKeyboardDisplayIcons) {
function getIcon(Icons: Partial<DefaultKeyboardDisplayIcons>) {
const { $state } = useContext(mediaContext),
action = $state.lastKeyboardAction()?.action;
switch (action) {
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/providers/remotion/ui/context.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';

import { noop } from 'maverick.js/std';
import {
Internals,
type CompositionManagerContext,
Expand Down Expand Up @@ -59,6 +60,7 @@ export function RemotionContextProvider({
unregisterFolder: () => undefined,
registerComposition: () => undefined,
unregisterComposition: () => undefined,
updateCompositionDefaultProps: noop,
currentCompositionMetadata: null,
setCurrentCompositionMetadata: () => undefined,
canvasContent: { type: 'composition', compositionId: REMOTION_PROVIDER_ID },
Expand Down
4 changes: 4 additions & 0 deletions packages/vidstack/styles/player/default/keyboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
pointer-events: none;
}

.vds-kb-bezel:not(:has(svg)) {
display: none !important;
}

.light .vds-kb-bezel {
--default-bg: rgb(255 255 255 / 0.6);
}
Expand Down

0 comments on commit 008141d

Please sign in to comment.