@wistia/wistia-player-react 0.0.0-alpha.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/WistiaPlayer.cjs +45745 -0
- package/dist/WistiaPlayer.mjs +44 -0
- package/dist/WistiaPlayerWrapper-36PG3PKA.mjs +90 -0
- package/dist/chunk-F65VZERV.mjs +45572 -0
- package/dist/types/src/WistiaPlayer.d.ts +5 -0
- package/dist/types/src/WistiaPlayer.d.ts.map +1 -0
- package/dist/types/src/WistiaPlayerWrapper.d.ts +6 -0
- package/dist/types/src/WistiaPlayerWrapper.d.ts.map +1 -0
- package/dist/types/src/utils/camelCaseToKebabCase.d.ts +7 -0
- package/dist/types/src/utils/camelCaseToKebabCase.d.ts.map +1 -0
- package/dist/types/src/utils/getMergedEmbedOption.d.ts +10 -0
- package/dist/types/src/utils/getMergedEmbedOption.d.ts.map +1 -0
- package/dist/types/src/utils/swatch.d.ts +30 -0
- package/dist/types/src/utils/swatch.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +110 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
> ⚠️ **Note:** This package is in active development. Updates may unexpectedly introduce breaking changes. Use in production at your own risk.
|
|
2
|
+
|
|
3
|
+
# Wistia Player React Wrapper
|
|
4
|
+
|
|
5
|
+
Wistia's React Wrapper of the `<wistia-player/>` web component. Used to add responsive, lightweight, and SEO-friendly videos to your site.
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @wistia/wistia-player-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Simple player
|
|
14
|
+
|
|
15
|
+
The only required prop is `mediaId`, the ID of the media that will be embedded.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { WistiaPlayer } from '@wistia/wistia-player-react';
|
|
19
|
+
|
|
20
|
+
<WistiaPlayer mediaId="abc123" />;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Player with embed options and event callback
|
|
24
|
+
|
|
25
|
+
The `<WistiaPlayer>` component takes the same options (as React props) which one can set on the `<wistia-player>` web component. There is a list at the [Embed options](https://wistia.com/support/developers/embed-options) support page. The only difference here is that numbers, booleans, etc are expected to be JS values of those types rather than strings. Event callbacks can also be added, formatted in a way which is familiar React development (e.g. the `play` event would become `onPlay`).
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import { WistiaPlayer } from '@wistia/wistia-player-react';
|
|
29
|
+
|
|
30
|
+
<WistiaPlayer
|
|
31
|
+
mediaId="abc123"
|
|
32
|
+
playerColor="1e64f0"
|
|
33
|
+
onPlay={() => console.log('Wistia video is playing!')}
|
|
34
|
+
/>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Additional Options
|
|
38
|
+
|
|
39
|
+
#### Avoiding layout shifts
|
|
40
|
+
|
|
41
|
+
The player will automatically load in a lightweight placeholder "swatch" image as soon as possible. However, in certain cases (such as server-side rendering) there can still be a slight layout shift while we wait for that placeholder. In order to avoid shift completely, you can explicitly set the `aspect` of your video:
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import { WistiaPlayer } from '@wistia/wistia-player-react';
|
|
45
|
+
|
|
46
|
+
<WistiaPlayer mediaId="abc123" aspect={16 / 9} />;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Fixed-size Embeds
|
|
50
|
+
|
|
51
|
+
The player is responsive by default. If a fixed-size player is better for your use-case, you can pass in `width` and `height` values instead:
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
import { WistiaPlayer } from '@wistia/wistia-player-react';
|
|
55
|
+
|
|
56
|
+
<WistiaPlayer
|
|
57
|
+
mediaId="abc123"
|
|
58
|
+
style={{
|
|
59
|
+
width: '640px',
|
|
60
|
+
height: '360px',
|
|
61
|
+
}}
|
|
62
|
+
/>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Popovers
|
|
66
|
+
|
|
67
|
+
Wistia’s “popovers” are video embeds that open in modal overlays when a target element is clicked. For these embeds, there is an explicit, _required_ `wistiaPopover` prop (`true`/`false`) as well as an optional `popoverContent` prop. If left undefined, the default `popoverContent` value is `thumbnail`. For popovers with `popoverContent="link`, the `<WistiaPlayer>` component expects to have children.
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
import { WistiaPlayer } from '@wistia/wistia-player-react';
|
|
71
|
+
|
|
72
|
+
<WistiaPlayer mediaId="abc123" wistiaPopover={true} popoverContent="link">
|
|
73
|
+
<span>Popover Link</span>
|
|
74
|
+
</WistiaPlayer>;
|
|
75
|
+
```
|