JSPM

react-document-picture-in-picture

1.2.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 5
    • Score
      100M100P100Q44994F
    • License GPL-3.0-only

    Feature-packed and optimised React component for Chrome's new Document Picture-in-Picture API

    Package Exports

    • react-document-picture-in-picture
    • react-document-picture-in-picture/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-document-picture-in-picture) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    react-document-picture-in-picture

    Easily and quickly use Chrome's new experimental Document Picture-in-Picture API as a zero-dependency React component.

    Installation

    npm install react-document-picture-in-picture

    Installs the component package from this monorepo project.

    Usage

    import ReactDocumentPictureInPicture from "react-document-picture-in-picture";
    
    // Inside your React component ...
    <ReactDocumentPictureInPicture
        buttonRenderer={
            ({ open, close, toggle, isOpen }) => 
                <div>
                    <b>Is {isOpen ? 'Open' : 'Closed'}</b>
                    <button onClick={open}>Open</button>
                    <button onClick={close}>Close</button>
                    <button onClick={toggle}>Toggle</button>
                </div>
        }
        onOpen={() => console.log('Opened')}
        onClose={() => console.log('Closed')}
        onResize={(w, h) => console.log('Resized to ' + w + 'x' + h)}
    >
        This text should be displayed in a Document Picture in Picture in the bottom right of the original window
    </ReactDocumentPictureInPicture>
    

    There are at least three useful examples demonstrating how to use event props, the ref prop and size props in the examples package of this monorepo.

    To quickly take a look at the examples, clone the repository, install PNPM and run the following commands:

    pnpm install 
    pnpm run --filter react-document-picture-in-picture build
    pnpm run --filter examples start

    The examples will be available at https://localhost:1234/ in your browser.