-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from THEOplayer/slot-container
Fix `topChrome` not auto-hiding in React custom UIs
- Loading branch information
Showing
15 changed files
with
123 additions
and
53 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createComponent } from '@lit/react'; | ||
import { SlotContainer as SlotContainerElement } from '@theoplayer/web-ui'; | ||
import * as React from 'react'; | ||
|
||
/** | ||
* See {@link @theoplayer/web-ui!SlotContainer | SlotContainer in @theoplayer/web-ui}. | ||
* | ||
* @group Components | ||
* @internal | ||
*/ | ||
export const SlotContainer = createComponent({ | ||
tagName: 'theoplayer-slot-container', | ||
displayName: 'SlotContainer', | ||
elementClass: SlotContainerElement, | ||
react: React | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:host { | ||
display: contents; | ||
} | ||
|
||
slot, | ||
::slotted(:not([no-auto-hide])) { | ||
/* | ||
* Inherit opacity from parent container, so auto-hide works. | ||
*/ | ||
opacity: inherit; | ||
} |
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,39 @@ | ||
import { createTemplate } from '../util/TemplateUtils'; | ||
import slotContainerCss from './SlotContainer.css'; | ||
|
||
const template = createTemplate('theoplayer-slot-container', `<style>${slotContainerCss}</style><slot></slot>`); | ||
|
||
/** | ||
* `<theoplayer-slot-container>` - A container that can be assigned to a slot, | ||
* and behaves as if all its children are directly assigned to that slot. | ||
* | ||
* This behaves approximately like a regular `<div>` with style `display: contents`, | ||
* but receives some special treatment from e.g. {@link MenuGroup | `<theoplayer-menu-group>`} | ||
* which normally expects its {@link Menu | menu}s to be slotted in as direct children. | ||
* Those menus can also be children of a `<theoplayer-slot-container>` instead. | ||
* | ||
* This is an internal component, used mainly by Open Video UI for React. | ||
* You shouldn't need this under normal circumstances. | ||
* | ||
* @group Components | ||
* @internal | ||
*/ | ||
export class SlotContainer extends HTMLElement { | ||
constructor() { | ||
super(); | ||
const shadowRoot = this.attachShadow({ mode: 'open' }); | ||
shadowRoot.appendChild(template().content.cloneNode(true)); | ||
} | ||
} | ||
|
||
customElements.define('theoplayer-slot-container', SlotContainer); | ||
|
||
export function isSlotContainer(element: Element): element is SlotContainer { | ||
return element.nodeName.toLowerCase() === 'theoplayer-slot-container'; | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'theoplayer-slot-container': SlotContainer; | ||
} | ||
} |
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