Skip to content

Commit

Permalink
feat(player): media announcer
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Feb 26, 2024
1 parent 5f07f55 commit 533edc5
Show file tree
Hide file tree
Showing 22 changed files with 443 additions and 341 deletions.
47 changes: 47 additions & 0 deletions packages/react/src/components/announcer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';

import { composeRefs, createReactComponent, type ReactElementProps } from 'maverick.js/react';

import { MediaAnnouncerInstance } from './primitives/instances';
import { Primitive } from './primitives/nodes';

/* -------------------------------------------------------------------------------------------------
* MediaAnnouncer
* -----------------------------------------------------------------------------------------------*/

const MediaAnnouncerBridge = createReactComponent(MediaAnnouncerInstance, {
events: ['onChange'],
});

export interface MediaAnnouncerProps extends ReactElementProps<MediaAnnouncerInstance> {
ref?: React.Ref<HTMLElement>;
}

/**
*
* @docs {@link https://www.vidstack.io/docs/player/components/display/announcer}
* @example
* ```tsx
* <MediaAnnouncer />
* ```
*/
const MediaAnnouncer = React.forwardRef<HTMLElement, MediaAnnouncerProps>(
({ style, children, ...props }, forwardRef) => {
return (
<MediaAnnouncerBridge {...(props as Omit<MediaAnnouncerProps, 'ref'>)}>
{(props) => (
<Primitive.div
{...props}
style={{ display: 'contents', ...style }}
ref={composeRefs(props.ref, forwardRef)}
>
{children}
</Primitive.div>
)}
</MediaAnnouncerBridge>
);
},
);

MediaAnnouncer.displayName = 'MediaAnnouncer';
export { MediaAnnouncer };
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { createComputed } from '../../../hooks/use-signals';
import * as Controls from '../../ui/controls';
import { useLayoutName } from '../utils';
import { i18n, useDefaultLayoutContext } from './context';
import { DefaultKeyboardStatus } from './keyboard-action-display';
import { createDefaultMediaLayout, type DefaultLayoutProps } from './media-layout';
import {
DefaultAnnouncer,
DefaultCaptionButton,
DefaultCaptions,
DefaultChaptersMenu,
Expand Down Expand Up @@ -112,8 +112,8 @@ function AudioLayout() {
const slots = useDefaultAudioLayoutSlots();
return (
<>
<DefaultAnnouncer />
<DefaultCaptions />
<DefaultKeyboardStatus className="vds-sr-only" />
<Controls.Root className="vds-controls">
<Controls.Group className="vds-controls-group">
{slot(slots, 'seekBackwardButton', <DefaultSeekButton backward tooltip="top start" />)}
Expand Down
9 changes: 1 addition & 8 deletions packages/react/src/components/layouts/default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@ export type { DefaultLayoutProps } from './media-layout';
export * from './icons';
export * from './context';
export * from './ui';
export {
DefaultKeyboardDisplay,
DefaultKeyboardStatus,
type DefaultKeyboardDisplayProps,
type DefaultKeyboardDisplayWords,
type DefaultKeyboardDisplayTranslations,
type DefaultKeyboardStatusProps,
} from './keyboard-action-display';
export { DefaultKeyboardDisplay, type DefaultKeyboardDisplayProps } from './keyboard-display';

This file was deleted.

Loading

0 comments on commit 533edc5

Please sign in to comment.