Skip to content

Commit

Permalink
Add tab index & custom class names (#300)
Browse files Browse the repository at this point in the history
* fix: added ID element

* chore: added changeset
  • Loading branch information
0xcadams committed Mar 29, 2023
1 parent eca4f7d commit 0054108
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-ties-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livepeer/react': patch
---

**Fix:** added a `tabIndex` prop to allow for customization of the tab index of the container element, as well as consistent class names for the container elements to allow for custom CSS.
10 changes: 9 additions & 1 deletion packages/react/src/components/media/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ type PlayerProps = CorePlayerProps<HTMLMediaElement, PosterSource> & {
* domains, for access control policies.
*/
allowCrossOriginCredentials?: boolean;
/**
* The tab index of the container element.
*/
tabIndex?: number;
};

export type { PlayerObjectFit, PlayerProps };
Expand Down Expand Up @@ -83,7 +87,11 @@ export const PlayerInternal = (props: PlayerProps) => {
opts={controls ?? {}}
playerProps={props}
>
<Container theme={theme} aspectRatio={aspectRatio}>
<Container
theme={theme}
aspectRatio={aspectRatio}
tabIndex={props.tabIndex}
>
{source && source?.[0]?.type === 'audio' ? (
<AudioPlayer
{...playerProps}
Expand Down
16 changes: 9 additions & 7 deletions packages/react/src/components/media/controls/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContainerProps } from '@livepeer/core-react/components';
import { ContainerProps as CoreContainerProps } from '@livepeer/core-react/components';
import { MediaControllerState } from 'livepeer';

import { styling } from 'livepeer/media/browser/styling';
Expand All @@ -12,10 +12,12 @@ const mediaControllerSelector = ({
fullscreen,
});

export type { ContainerProps };
export type ContainerProps = CoreContainerProps & {
tabIndex?: number;
};

export const Container: React.FC<ContainerProps> = (props) => {
const { children, aspectRatio, theme } = props;
const { children, aspectRatio, theme, tabIndex } = props;

// cast response from useTheme to string
const className = useTheme(theme) as string;
Expand All @@ -27,14 +29,14 @@ export const Container: React.FC<ContainerProps> = (props) => {
style={{
display: 'contents',
}}
className={className}
className={`${className} livepeer-contents-container`}
>
<div
className={styling.container({
className={`${styling.container({
aspectRatio,
size: fullscreen ? 'fullscreen' : 'default',
})}
tabIndex={0}
})} livepeer-aspect-ratio-container`}
tabIndex={tabIndex ?? 0}
>
{children}
</div>
Expand Down

2 comments on commit 0054108

@vercel
Copy link

@vercel vercel bot commented on 0054108 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 0054108 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.