Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed imports to ESM #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
["@babel/preset-env", { "loose": true, modules: false }],
["@babel/preset-env"],
"@babel/react"
]
}
8 changes: 4 additions & 4 deletions src/MediaPlayer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react');
const { PlayerContextProvider } = require('@cassette/core');
import React from "react";
import { PlayerContextProvider } from "@cassette/core"
import MediaPlayerUI from "./MediaPlayerUI";

const MediaPlayerUI = require('./MediaPlayerUI');

class MediaPlayer extends React.Component {
render() {
Expand Down Expand Up @@ -37,4 +37,4 @@ MediaPlayer.defaultProps = {
...PlayerContextProvider.defaultProps
};

module.exports = MediaPlayer;
export default MediaPlayer;
11 changes: 5 additions & 6 deletions src/MediaPlayerUI.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const React = require('react');
const PropTypes = require('prop-types');
const { FullscreenContextProvider } = require('@cassette/core');

const MediaPlayerView = require('./components/MediaPlayerView');
import React from "react";
import PropTypes from 'prop-types';
import { FullscreenContextProvider } from '@cassette/core';
import MediaPlayerView from './components/MediaPlayerView';

class MediaPlayerUI extends React.PureComponent {
render() {
Expand Down Expand Up @@ -46,4 +45,4 @@ MediaPlayerUI.defaultProps = {
fullscreenEnabled: false
};

module.exports = MediaPlayerUI;
export default MediaPlayerUI;
61 changes: 40 additions & 21 deletions src/components/Icon.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
const React = require('react');
const PropTypes = require('prop-types');
import React from "react";
import PropTypes from 'prop-types';

import audio from '../icons/audio.png';
import backscroll from '../icons/backscroll.png';
import backseek from '../icons/backseek.png';
import backskip from '../icons/backskip.png';
import eject from '../icons/eject.png';
import forwardscroll from '../icons/forwardscroll.png';
import forwardseek from '../icons/forwardseek.png';
import forwardskip from '../icons/forwardskip.png';
import pause from '../icons/pause.png';
import play from '../icons/play.png';
import selectionend from '../icons/selectionend.png';
import selectionstart from '../icons/selectionstart.png';
import stop from '../icons/stop.png';
import video from '../icons/video.png';
import maximize from '../icons/maximize.png';
import minimize from '../icons/minimize.png';
import unmaximize from '../icons/unmaximize.png';
import x from '../icons/x.png';

const imgs = {
audio: require('../icons/audio.png'),
backscroll: require('../icons/backscroll.png'),
backseek: require('../icons/backseek.png'),
backskip: require('../icons/backskip.png'),
eject: require('../icons/eject.png'),
forwardscroll: require('../icons/forwardscroll.png'),
forwardseek: require('../icons/forwardseek.png'),
forwardskip: require('../icons/forwardskip.png'),
pause: require('../icons/pause.png'),
play: require('../icons/play.png'),
selectionend: require('../icons/selectionend.png'),
selectionstart: require('../icons/selectionstart.png'),
stop: require('../icons/stop.png'),
video: require('../icons/video.png'),
maximize: require('../icons/maximize.png'),
minimize: require('../icons/minimize.png'),
unmaximize: require('../icons/unmaximize.png'),
x: require('../icons/x.png')
audio,
backscroll,
backseek,
backskip,
eject,
forwardscroll,
forwardseek,
forwardskip,
pause,
play,
selectionend,
selectionstart,
stop,
video,
maximize,
minimize,
unmaximize,
x,
};

class Icon extends React.PureComponent {
Expand All @@ -33,4 +52,4 @@ Icon.propTypes = {
name: PropTypes.string.isRequired
};

module.exports = Icon;
export default Icon;
11 changes: 5 additions & 6 deletions src/components/MediaBtn.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const React = require('react');
const PropTypes = require('prop-types');
const { Button } = require('react95');

const Icon = require('./Icon');
import React from "react";
import PropTypes from 'prop-types';
import { Button } from 'react95';
import Icon from './Icon';

const normalIconStyle = { opacity: 1 };
const disabledIconStyle = { opacity: 0.3 };
Expand Down Expand Up @@ -33,4 +32,4 @@ MediaBtn.defaultProps = {
disabled: false
};

module.exports = MediaBtn;
export default MediaBtn;
33 changes: 16 additions & 17 deletions src/components/MediaPlayerView.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const React = require('react');
const PropTypes = require('prop-types');
const { playerContextFilter, PlayerPropTypes } = require('@cassette/core');
const { VideoDisplay } = require('@cassette/components');
const {
import React from "react";
import PropTypes from 'prop-types';
import { playerContextFilter, PlayerPropTypes } from '@cassette/core'
import { VideoDisplay } from '@cassette/components'
import {
themes,
Window,
WindowHeader,
Expand All @@ -11,17 +11,16 @@ const {
Button,
Cutout,
Divider
} = require('react95');
const { ThemeProvider } = require('styled-components');
const ResizeObserver = require('resize-observer-polyfill').default;

const ProgressBar = require('./ProgressBar');
const MediaBtn = require('./MediaBtn');
const SeekButton = require('./SeekButton');
const Icon = require('./Icon');
const SimpleDivider = require('./SimpleDivider');
const VerticalDivider = require('./VerticalDivider');
const convertToTime = require('../utils/convertToTime');
} from 'react95'
import { ThemeProvider } from 'styled-components'
import ResizeObserver from 'resize-observer-polyfill'
import ProgressBar from './ProgressBar'
import MediaBtn from './MediaBtn'
import SeekButton from './SeekButton'
import Icon from './Icon'
import SimpleDivider from './SimpleDivider'
import VerticalDivider from './VerticalDivider'
import convertToTime from '../utils/convertToTime'

const windowHeaderStyle = {
padding: 0,
Expand Down Expand Up @@ -285,7 +284,7 @@ MediaPlayerView.propTypes = {
onForwardSkip: PropTypes.func.isRequired
};

module.exports = playerContextFilter(MediaPlayerView, [
export default playerContextFilter(MediaPlayerView, [
'fullscreen',
'requestFullscreen',
'requestExitFullscreen',
Expand Down
13 changes: 6 additions & 7 deletions src/components/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const React = require('react');
const { MediaProgressBar } = require('@cassette/components');
const { themes } = require('react95');
const ResizeObserver = require('resize-observer-polyfill').default;

const ProgressRuler = require('./ProgressRuler');
import React from 'react'
import { MediaProgressBar } from '@cassette/components'
import { themes } from 'react95'
import ResizeObserver from 'resize-observer-polyfill'
import ProgressRuler from './ProgressRuler'

const progressMargin = 10;

Expand Down Expand Up @@ -103,4 +102,4 @@ class ProgressBar extends React.PureComponent {
}
}

module.exports = ProgressBar;
export default ProgressBar;
8 changes: 4 additions & 4 deletions src/components/ProgressRuler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const React = require('react');
const PropTypes = require('prop-types');
const { playerContextFilter } = require('@cassette/core');
import React from "react";
import PropTypes from 'prop-types';
import { playerContextFilter } from '@cassette/core';

// the minimum horizontal pixel space needed to print a time label
const minWidthForTickInterval = 30;
Expand Down Expand Up @@ -102,4 +102,4 @@ ProgressRuler.propTypes = {
progressWidth: PropTypes.number.isRequired
};

module.exports = playerContextFilter(ProgressRuler, ['duration']);
export default playerContextFilter(ProgressRuler, ['duration']);
11 changes: 5 additions & 6 deletions src/components/SeekButton.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const React = require('react');
const PropTypes = require('prop-types');
const { playerContextFilter } = require('@cassette/core');

const MediaBtn = require('./MediaBtn');
import React from "react";
import PropTypes from 'prop-types';
import { playerContextFilter } from '@cassette/core';
import MediaBtn from './MediaBtn';

const icons = {
fastforward: 'forwardseek',
Expand Down Expand Up @@ -72,7 +71,7 @@ SeekButton.propTypes = {
type: PropTypes.oneOf(['fastforward', 'rewind']).isRequired
};

module.exports = playerContextFilter(SeekButton, [
export default playerContextFilter(SeekButton, [
'currentTime',
'onSeekComplete'
]);
4 changes: 2 additions & 2 deletions src/components/SimpleDivider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const React = require('react');
const { themes } = require('react95');
import React from 'react';
import { themes } from 'react95';

const style = {
height: 0,
Expand Down
6 changes: 3 additions & 3 deletions src/components/VerticalDivider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const React = require('react');
const { themes } = require('react95');
import React from 'react';
import { themes } from 'react95';

const style = {
width: 0,
Expand All @@ -15,4 +15,4 @@ const VerticalDivider = () => {
return <div style={style} />;
};

module.exports = VerticalDivider;
export default VerticalDivider;
9 changes: 2 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
const MediaPlayer = require('./MediaPlayer');
const MediaPlayerUI = require('./MediaPlayerUI');

module.exports = {
MediaPlayer,
MediaPlayerUI
};
export * as MediaPlayer from "./MediaPlayer";
export * as MediaPlayer from "./MediaPlayer";
4 changes: 1 addition & 3 deletions src/utils/convertToTime.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// slightly different than version used in @cassette/player -
// minutes are always shown as 2 digits regardless of whether
// there is an hour display or not.
function convertToTime(number) {
export default function convertToTime(number) {
const hours = Math.floor(number / (60 * 60));
const mins = Math.floor(number / 60) - hours * 60;
const secs = (number % 60).toFixed();
Expand All @@ -10,5 +10,3 @@ function convertToTime(number) {
time += `${secs < 10 ? '0' : ''}${secs}`;
return time;
}

module.exports = convertToTime;