Skip to content

Commit

Permalink
@uppy/webcam: refactor to ESM (#3686)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored May 4, 2022
1 parent b290077 commit 94b646a
Show file tree
Hide file tree
Showing 21 changed files with 682 additions and 676 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ module.exports = {
'packages/@uppy/svelte/src/**/*.js',
'packages/@uppy/svelte/rollup.config.js',
'packages/@uppy/vue/src/**/*.js',
'packages/@uppy/webcam/src/**/*.js',
],
parser: 'espree',
parserOptions: {
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/webcam/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "lib/index.js",
"style": "dist/style.min.css",
"types": "types/index.d.ts",
"type": "module",
"keywords": [
"file uploader",
"uppy",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { h } = require('preact')
import { h } from 'preact'

module.exports = () => {
export default () => {
return (
<svg aria-hidden="true" focusable="false" fill="#0097DC" width="66" height="55" viewBox="0 0 66 55">
<path d="M57.3 8.433c4.59 0 8.1 3.51 8.1 8.1v29.7c0 4.59-3.51 8.1-8.1 8.1H8.7c-4.59 0-8.1-3.51-8.1-8.1v-29.7c0-4.59 3.51-8.1 8.1-8.1h9.45l4.59-7.02c.54-.54 1.35-1.08 2.16-1.08h16.2c.81 0 1.62.54 2.16 1.08l4.59 7.02h9.45zM33 14.64c-8.62 0-15.393 6.773-15.393 15.393 0 8.62 6.773 15.393 15.393 15.393 8.62 0 15.393-6.773 15.393-15.393 0-8.62-6.773-15.393-15.393-15.393zM33 40c-5.648 0-9.966-4.319-9.966-9.967 0-5.647 4.318-9.966 9.966-9.966s9.966 4.319 9.966 9.966C42.966 35.681 38.648 40 33 40z" fillRule="evenodd" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable jsx-a11y/media-has-caption */
const { h, Component } = require('preact')
const SnapshotButton = require('./SnapshotButton')
const RecordButton = require('./RecordButton')
const RecordingLength = require('./RecordingLength')
const VideoSourceSelect = require('./VideoSourceSelect')
const SubmitButton = require('./SubmitButton')
const DiscardButton = require('./DiscardButton')
import { h, Component } from 'preact'
import SnapshotButton from './SnapshotButton.jsx'
import RecordButton from './RecordButton.jsx'
import RecordingLength from './RecordingLength.jsx'
import VideoSourceSelect from './VideoSourceSelect.jsx'
import SubmitButton from './SubmitButton.jsx'
import DiscardButton from './DiscardButton.jsx'

function isModeAvailable (modes, mode) {
return modes.indexOf(mode) !== -1
Expand Down Expand Up @@ -116,4 +116,4 @@ class CameraScreen extends Component {
}
}

module.exports = CameraScreen
export default CameraScreen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { h } = require('preact')
import { h } from 'preact'

function DiscardButton ({ onDiscard, i18n }) {
return (
Expand Down Expand Up @@ -28,4 +28,4 @@ function DiscardButton ({ onDiscard, i18n }) {
)
}

module.exports = DiscardButton
export default DiscardButton
11 changes: 0 additions & 11 deletions packages/@uppy/webcam/src/PermissionsScreen.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/@uppy/webcam/src/PermissionsScreen.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { h } from 'preact'

export default ({ icon, i18n, hasCamera }) => {
return (
<div className="uppy-Webcam-permissons">
<div className="uppy-Webcam-permissonsIcon">{icon()}</div>
<h1 className="uppy-Webcam-title">{hasCamera ? i18n('allowAccessTitle') : i18n('noCameraTitle')}</h1>
<p>{hasCamera ? i18n('allowAccessDescription') : i18n('noCameraDescription')}</p>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { h } = require('preact')
import { h } from 'preact'

module.exports = function RecordButton ({ recording, onStartRecording, onStopRecording, i18n }) {
export default function RecordButton ({ recording, onStartRecording, onStopRecording, i18n }) {
if (recording) {
return (
<button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { h } = require('preact')
const formatSeconds = require('./formatSeconds')
import { h } from 'preact'
import formatSeconds from './formatSeconds.js'

module.exports = function RecordingLength ({ recordingLengthSeconds, i18n }) {
export default function RecordingLength ({ recordingLengthSeconds, i18n }) {
const formattedRecordingLengthSeconds = formatSeconds(recordingLengthSeconds)

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { h } = require('preact')
const CameraIcon = require('./CameraIcon')
import { h } from 'preact'
import CameraIcon from './CameraIcon.jsx'

module.exports = ({ onSnapshot, i18n }) => {
export default ({ onSnapshot, i18n }) => {
return (
<button
className="uppy-u-reset uppy-c-btn uppy-Webcam-button uppy-Webcam-button--picture"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { h } = require('preact')
import { h } from 'preact'

function SubmitButton ({ onSubmit, i18n }) {
return (
Expand All @@ -25,4 +25,4 @@ function SubmitButton ({ onSubmit, i18n }) {
)
}

module.exports = SubmitButton
export default SubmitButton
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { h } = require('preact')
import { h } from 'preact'

module.exports = ({ currentDeviceId, videoSources, onChangeVideoSource }) => {
export default ({ currentDeviceId, videoSources, onChangeVideoSource }) => {
return (
<div className="uppy-Webcam-videoSource">
<select
Expand Down
Loading

0 comments on commit 94b646a

Please sign in to comment.