|
| 1 | +# PIP - Picture in picture |
| 2 | + |
| 3 | +Picture in picture mode of preview inside the viewport for viewing UI Previews in more ux friendly way. |
| 4 | + |
| 5 | +# Resizable-PIP |
| 6 | + |
| 7 | +A resizable picture-in-picture component for React. |
| 8 | + |
| 9 | +```js |
| 10 | +<ResizablePIP> |
| 11 | + <div>I can be resized and moved around!</div> |
| 12 | +</ResizablePIP> |
| 13 | +``` |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +### Installing |
| 18 | + |
| 19 | +```bash |
| 20 | +$ yarn add @code-editor/preview-pip |
| 21 | +``` |
| 22 | + |
| 23 | +### Usage |
| 24 | + |
| 25 | +This package has two major exports: |
| 26 | + |
| 27 | +- [`<ResizablePIP>`](/lib/resizable-pip.tsx): A simple PIP component that can be resized and moved around. |
| 28 | +- [`<PIP>`](/lib/pip.tsx): A simple PIP component that does not receive props and cannot be resized. Used as a base for the ResizablePIP component. |
| 29 | + |
| 30 | +## `<ResizablePIP>` |
| 31 | + |
| 32 | +A `<ResizablePIP>` element wraps an existing element and extends it with the ability to be resized and moved around, above all content in the app. |
| 33 | + |
| 34 | +### ResizablePIP Usage |
| 35 | + |
| 36 | +View the [source](/src/lib/components/ResizablePIP.jsx) for more. |
| 37 | + |
| 38 | +```js |
| 39 | +import { ResizablePIP } from "@code-editor/preview-pip"; |
| 40 | + |
| 41 | +function App() { |
| 42 | + return ( |
| 43 | + <div> |
| 44 | + <ResizablePIP |
| 45 | + width={500} |
| 46 | + heigt={500} |
| 47 | + minConstraints={[300, 300]} |
| 48 | + maxConstraints={[800, 800]} |
| 49 | + > |
| 50 | + <p> |
| 51 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do |
| 52 | + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad |
| 53 | + minim veniam, quis nostrud exercitation ullamco laboris nisi ut |
| 54 | + aliquip ex ea commodo consequat. Duis aute irure dolor in |
| 55 | + reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla |
| 56 | + pariatur. Excepteur sint occaecat cupidatat non proident, sunt in |
| 57 | + culpa qui officia deserunt mollit anim id est laborum. |
| 58 | + </p> |
| 59 | + </ResizablePIP> |
| 60 | + </div> |
| 61 | + ); |
| 62 | +} |
| 63 | + |
| 64 | +export default App; |
| 65 | +``` |
| 66 | + |
| 67 | +#### `<ResizablePIP>` Props: |
| 68 | + |
| 69 | +```ts |
| 70 | + |
| 71 | +// |
| 72 | +// Props: |
| 73 | +// |
| 74 | +{ |
| 75 | +// Specifies initial PIP window width. |
| 76 | +// Example: 600 |
| 77 | +// Default value: 500 |
| 78 | +width: number, |
| 79 | + |
| 80 | +// Specifies initial PIP window height. |
| 81 | +// Example: 600 |
| 82 | +// Default value: 500 |
| 83 | +height: number, |
| 84 | + |
| 85 | +// Specifies the minimum size possible for the PIP window (width, height). |
| 86 | +// Example: [100, 100] |
| 87 | +// Default value: [300, 300] |
| 88 | +minConstraints: [number, number] |
| 89 | + |
| 90 | +// Specifies the maximum size possible for the PIP window (width, height). |
| 91 | +// Example: [900, 900] |
| 92 | +// Default value: [800, 800] |
| 93 | +maxConstraints: [number, number] |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +## References |
| 98 | + |
| 99 | +https://www.w3.org/TR/picture-in-picture/ |
| 100 | + |
| 101 | +## Disclaimer |
| 102 | + |
| 103 | +The origin source was forked from - https://github.com/itielMaimon/resizable-pip under MIT License |
| 104 | + |
| 105 | +### License |
| 106 | + |
| 107 | +MIT |
0 commit comments