Skip to content

Commit 38292f4

Browse files
authored
fix(styling): replace CSS file with inline iframe styling (#11)
- Remove CSS file dependency causing webpack parse errors - Apply width/height styles directly via JavaScript after iframe loads - Improves package compatibility without requiring CSS loaders
1 parent 1262f59 commit 38292f4

File tree

7 files changed

+40
-15
lines changed

7 files changed

+40
-15
lines changed

.changeset/poor-baths-shave.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"react-native-vimeo-bridge": patch
3+
---
4+
5+
fix(styling): replace CSS file with inline iframe styling
6+
7+
- Remove CSS file dependency causing webpack parse errors
8+
- Apply width/height styles directly via JavaScript after iframe loads
9+
- Improves package compatibility without requiring CSS loaders
10+
- Breaking Changes: The removal of `width`, `height`, `maxwidth`, `maxheight`, and `responsive` from VimeoPlayerOptions (https://github.com/vimeo/player.js/issues/38#issuecomment-242462979)

example/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function App() {
6666
[player],
6767
);
6868

69-
const getPlayerInfo = async () => {
69+
const getPlayerInfo = useCallback(async () => {
7070
try {
7171
const [videoId, title, url, width, height] = await Promise.all([
7272
player.getVideoId(),
@@ -93,7 +93,7 @@ function App() {
9393
} catch (error) {
9494
console.error('Error getting player info:', error);
9595
}
96-
};
96+
}, [player]);
9797

9898
useVimeoEvent(player, 'playing', (data) => {
9999
console.log('playing', data);

src/VimeoPlayer.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,15 @@ const VimeoPlayer = ({
146146
player.on('bufferstart', sendMessage('bufferstart'));
147147
player.on('bufferend', sendMessage('bufferend'));
148148
player.on('error', sendMessage('error'));
149-
player.on('loaded', sendMessage('loaded'));
149+
player.on('loaded', (data) => {
150+
sendMessage('loaded')(data);
151+
152+
const iframe = document.querySelector('iframe');
153+
if (iframe) {
154+
iframe.style.width = '100%';
155+
iframe.style.height = '100%';
156+
}
157+
});
150158
player.on('durationchange', sendMessage('durationchange'));
151159
player.on('fullscreenchange', sendMessage('fullscreenchange'));
152160
player.on('qualitychange', sendMessage('qualitychange'));

src/VimeoPlayer.web.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { useEffect, useRef, useState } from 'react';
22
import { useWindowDimensions } from 'react-native';
33
import WebVimeoPlayerController from './module/WebVimeoPlayerController';
4+
import { INTERNAL_SET_CONTROLLER_INSTANCE } from './symbol';
45
import type { VimeoPlayerProps } from './types';
56
import VimeoPlayerWrapper from './VimeoPlayerWrapper';
67

7-
import './styles.css';
8-
import { INTERNAL_SET_CONTROLLER_INSTANCE } from './symbol';
9-
108
const VimeoPlayer = ({ player, height = 200, width, style, iframeStyle }: VimeoPlayerProps) => {
119
const containerRef = useRef<HTMLDivElement>(null);
1210
const [isInitialized, setIsInitialized] = useState(false);

src/module/WebVimeoPlayerController.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ class WebVimeoPlayerController {
7777

7878
this.player = new window.Vimeo.Player(containerId, options);
7979

80+
if (this.player) {
81+
this.player.on('loaded', () => {
82+
const iframe = container.querySelector('iframe');
83+
84+
if (iframe) {
85+
iframe.style.width = '100%';
86+
iframe.style.height = '100%';
87+
}
88+
});
89+
}
90+
8091
return this.player;
8192
}
8293

src/styles.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/types/vimeo.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,25 @@ export interface VimeoPlayerOptions {
115115
color?: string | undefined;
116116
controls?: boolean | undefined;
117117
dnt?: boolean | undefined;
118-
height?: number | undefined;
119118
interactive_params?: string | undefined;
120119
keyboard?: boolean | undefined;
121120
loop?: boolean | undefined;
122-
maxheight?: number | undefined;
123-
maxwidth?: number | undefined;
124121
muted?: boolean | undefined;
125122
pip?: boolean | undefined;
126123
playsinline?: boolean | undefined;
127124
portrait?: boolean | undefined;
128-
responsive?: boolean | undefined;
129125
speed?: boolean | undefined;
130126
quality?: VimeoVideoQuality | undefined;
131127
texttrack?: string | undefined;
132128
title?: boolean | undefined;
133129
transparent?: boolean | undefined;
134-
width?: number | undefined;
130+
131+
// NOTE - https://github.com/vimeo/player.js/issues/38#issuecomment-242462979
132+
// maxheight?: number | undefined;
133+
// maxwidth?: number | undefined;
134+
// responsive?: boolean | undefined;
135+
// width?: number | undefined;
136+
// height?: number | undefined;
135137
}
136138

137139
export interface VimeoPlayerEventMap {

0 commit comments

Comments
 (0)