Skip to content

Commit

Permalink
[WALL] Aizad/WALL-4550/Adding Video Player as Common Components (bina…
Browse files Browse the repository at this point in the history
…ry-com#16093)

* chore: added video player inside of componetns package

* chore: remove package from appstore

* chore: fix test case

* chore: fix test case pt.2

* chore: made changes inside of Trader package

* chore: remove unused class

* chore: retrigger vercel

* chore: removed unused styles

* chore: udpate video height

* chore: update video height

* chore: update stylings for Video Controls and minor sizing change for Onboarding video
  • Loading branch information
aizad-deriv committed Aug 8, 2024
1 parent 5e50926 commit abf00f3
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 44 deletions.
3 changes: 1 addition & 2 deletions packages/appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"react-content-loader": "^6.2.0",
"react-joyride": "^2.5.3",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"@cloudflare/stream-react": "^1.9.1"
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
&__media-container {
width: 56rem;
height: 100%;
min-height: 32rem;
min-height: 30rem;
filter: drop-shadow(0px 4px 6px rgba(14, 14, 14, 0.03)) drop-shadow(0px 12px 16px rgba(14, 14, 14, 0.08));

@include mobile-screen {
width: 27.9rem;
min-height: 16.1rem;
width: 28rem;
min-height: 16rem;
}

@include tablet-screen {
Expand All @@ -46,18 +46,6 @@
}
}

&__video {
width: 100%;

iframe {
aspect-ratio: 16 / 9;
border-radius: $BORDER_RADIUS;
@include mobile-or-tablet-screen {
border-radius: 4px;
}
}
}

&__text {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { Analytics, TEvents } from '@deriv-com/analytics';
import classNames from 'classnames';
import { Stream } from '@cloudflare/stream-react';
import { Button, Text, Modal } from '@deriv/components';
import { Button, Text, Modal, VideoPlayer } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { observer, useStore } from '@deriv/stores';
import { useWalletMigration } from '@deriv/hooks';
Expand All @@ -24,7 +23,7 @@ const trackAnalyticsEvent = (
const WalletsUpgradeModal = observer(() => {
const { traders_hub, ui } = useStore();
const { is_demo, is_real_wallets_upgrade_on, toggleWalletsUpgrade } = traders_hub;
const { is_desktop } = ui;
const { is_desktop, is_mobile } = ui;
const { is_eligible, startMigration } = useWalletMigration();
const account_mode = is_demo ? 'demo' : 'real';
const isWalletMigrationModalClosed = localStorage.getItem('is_wallet_migration_modal_closed');
Expand Down Expand Up @@ -65,17 +64,11 @@ const WalletsUpgradeModal = observer(() => {
<Modal.Body>
<div className='wallets-upgrade-modal__content'>
<div className='wallets-upgrade-modal__media-container'>
<Stream
autoplay
className='wallets-upgrade-modal__video'
controls
letterboxColor='transparent'
loop
<VideoPlayer
height={is_desktop ? '311px' : '157px'}
is_mobile={is_mobile}
muted
preload='auto'
responsive={false}
src='25df7df0d0af48090b086cd6f103d8f3'
width='100%'
/>
</div>
<div className='wallets-upgrade-modal__text'>
Expand Down
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"webpack-cli": "^4.7.2"
},
"dependencies": {
"@cloudflare/stream-react": "^1.9.1",
"@contentpass/zxcvbn": "^4.4.3",
"@deriv-com/ui": "1.29.9",
"@deriv/shared": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ const mocked_props: React.ComponentProps<typeof VideoPlayer> = {
src: 'test_src',
};

jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
Icon: jest.fn(({ icon }: { icon: string }) => <div>{icon}</div>),
jest.mock('../../icon', () => ({
__esModule: true,
default: jest.fn(({ icon }: { icon: string }) => <div>{icon}</div>),
}));

jest.mock('@cloudflare/stream-react', () => ({
...jest.requireActual('@cloudflare/stream-react'),
Stream: jest.fn(({ onEnded, onPlay, onLoadedMetaData, streamRef, src }: TMockedStreamProps) => (
<video
data-testid='dt_video'
data-testid={video_data_testid}
onClick={onEnded}
onLoadedData={onLoadedMetaData}
onPlay={onPlay}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import VideoPlayer from './video-player';
import './video-player.scss';

export default VideoPlayer;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Dropdown, Icon } from '@deriv/components';
import Dropdown from '../dropdown';
import Icon from '../icon';
import { localize } from '@deriv/translations';

type TPlaybackRateControl = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { Text, Icon } from '@deriv/components';
import Icon from '../icon';
import Text from '../text';
import { formatDurationTime } from '@deriv/shared';
import VolumeControl from './volume-control';
import PlaybackRateControl from './playback-rate-control';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import { Icon } from '@deriv/components';
import Icon from '../icon';

type TVideoOverlay = {
onClick: (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
align-items: center;

svg {
margin: 0;
margin: 0 !important; // Override default margin from contract-type-info.scss
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ type TVideoPlayerProps = {
data_testid?: string;
height?: string;
is_mobile?: boolean;
muted?: boolean;
src: string;
};

const VideoPlayer = ({ className, data_testid, height, is_mobile, src }: TVideoPlayerProps) => {
const VideoPlayer = ({ className, data_testid, height, is_mobile, muted = false, src }: TVideoPlayerProps) => {
const should_autoplay =
(!isSafariBrowser() || (is_mobile && mobileOSDetect() !== 'iOS' && mobileOSDetect() !== 'unknown')) ?? true;

const [current_time, setCurrentTime] = React.useState<number>();
const [has_enlarged_dot, setHasEnlargedDot] = React.useState(false);
const [is_animated, setIsAnimated] = React.useState(true);
const [is_playing, setIsPlaying] = React.useState(false);
const [is_muted, setIsMuted] = React.useState(false);
const [is_muted, setIsMuted] = React.useState(muted);
const [playback_rate, setPlaybackRate] = React.useState(1);
const [show_controls, setShowControls] = React.useState(!should_autoplay);
const [shift_X, setShiftX] = React.useState(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { CSSTransition } from 'react-transition-group';
import { Icon } from '@deriv/components';
import Icon from '../icon';

type TVolumeControl = {
onVolumeChange: (new_value: number) => void;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export { default as UILoader } from './components/u-i-loader';
export { default as UnhandledErrorModal } from './components/unhandled-error-modal';
export { default as VerticalTab } from './components/vertical-tab';
export { default as Wizard } from './components/wizard';
export { default as VideoPlayer } from './components/video-player';
export * from './components/wallet-card';
export * from './components/wallet-icon';
export * from './components/app-linked-with-wallet-icon';
Expand Down
1 change: 0 additions & 1 deletion packages/trader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"webpack-node-externals": "^2.5.2"
},
"dependencies": {
"@cloudflare/stream-react": "^1.9.1",
"@deriv-com/analytics": "1.11.0",
"@deriv-com/quill-tokens": "^2.0.4",
"@deriv-com/quill-ui": "1.13.27",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { ActionSheet, Heading, Chip, Text } from '@deriv-com/quill-ui';
import { VideoPlayer } from '@deriv/components';
import { Localize } from '@deriv/translations';
import { clickAndKeyEventHandler } from '@deriv/shared';
import { AVAILABLE_CONTRACTS, CONTRACT_LIST } from 'AppV2/Utils/trade-types-utils';
import { getDescriptionVideoIds } from 'AppV2/Utils/contract-description-utils';
import VideoPlayer from 'App/Components/Elements/VideoPlayer';
import TradeDescription from './Description/trade-description';
import VideoPreview from './Description/video-preview';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { VideoPlayer } from '@deriv/components';
import { useStore } from '@deriv/stores';
import { getDescriptionVideoId } from 'Modules/Trading/Helpers/video-config';
import VideoPlayer from 'App/Components/Elements/VideoPlayer';

type TContractTypeDescriptionVideo = {
data_testid?: string;
Expand Down
1 change: 0 additions & 1 deletion packages/trader/src/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
@import 'app/_common/components/contract-type-no-result';
@import 'app/_common/components/market-is-closed-overlay';
@import 'app/_common/components/number-selector';
@import 'app/_common//components/video-player';
@import 'app/_common/components/purchase-button';
@import 'app/_common/components/range-slider';

Expand Down

0 comments on commit abf00f3

Please sign in to comment.