diff --git a/__tests__/src/components/AccessTokenSender.test.js b/__tests__/src/components/AccessTokenSender.test.js index 251896c4b9..c7b28075c3 100644 --- a/__tests__/src/components/AccessTokenSender.test.js +++ b/__tests__/src/components/AccessTokenSender.test.js @@ -1,5 +1,5 @@ import { render } from 'test-utils'; -import { AccessTokenSender } from '../../../src/components/AccessTokenSender'; +import AccessTokenSender from '../../../src/components/AccessTokenSender'; /** * Helper function to create a shallow wrapper around ErrorDialog diff --git a/__tests__/src/components/AnnotationSettings.test.js b/__tests__/src/components/AnnotationSettings.test.js index 84e04d7b86..115de2b420 100644 --- a/__tests__/src/components/AnnotationSettings.test.js +++ b/__tests__/src/components/AnnotationSettings.test.js @@ -1,6 +1,6 @@ import { render, screen } from 'test-utils'; import userEvent from '@testing-library/user-event'; -import { AnnotationSettings } from '../../../src/components/AnnotationSettings'; +import AnnotationSettings from '../../../src/components/AnnotationSettings'; /** */ function createWrapper(props) { diff --git a/__tests__/src/components/App.test.js b/__tests__/src/components/App.test.js index 53a7236ff7..cdd2d22be4 100644 --- a/__tests__/src/components/App.test.js +++ b/__tests__/src/components/App.test.js @@ -1,6 +1,6 @@ import { render, screen } from 'test-utils'; -import { App } from '../../../src/components/App'; +import App from '../../../src/components/App'; /** */ function createWrapper(props) { diff --git a/__tests__/src/components/Branding.test.js b/__tests__/src/components/Branding.test.js index 33a6f8ae9e..8048f9dfe2 100644 --- a/__tests__/src/components/Branding.test.js +++ b/__tests__/src/components/Branding.test.js @@ -1,5 +1,5 @@ import { render, screen, within } from 'test-utils'; -import { Branding } from '../../../src/components/Branding'; +import Branding from '../../../src/components/Branding'; describe('Branding', () => { it('renders', () => { diff --git a/src/components/AccessTokenSender.js b/src/components/AccessTokenSender.js index a17368488b..41c48bde48 100644 --- a/src/components/AccessTokenSender.js +++ b/src/components/AccessTokenSender.js @@ -1,48 +1,28 @@ -import { Component } from 'react'; -import PropTypes from 'prop-types'; +import { useCallback } from 'react'; import { IIIFIFrameCommunication } from './IIIFIFrameCommunication'; +/* eslint-disable react/prop-types */ /** * Opens a new window for click */ -export class AccessTokenSender extends Component { - /** */ - constructor(props) { - super(props); +export default function AccessTokenSender({ handleAccessTokenMessage, url }) { + const onReceiveAccessTokenMessage = useCallback((e) => { + if (e.data && e.data.messageId && e.data.messageId === url) { + handleAccessTokenMessage(e.data); + } + }, [handleAccessTokenMessage, url]); - this.onReceiveAccessTokenMessage = this.onReceiveAccessTokenMessage.bind(this); - } + if (!url) return null; - /** @private */ - onReceiveAccessTokenMessage(e) { - const { handleAccessTokenMessage, url } = this.props; - if (e.data && e.data.messageId && e.data.messageId === url) handleAccessTokenMessage(e.data); - } - - /** */ - render() { - const { url } = this.props; - if (!url) return null; - - /** - login, clickthrough/kiosk open @id, wait for close - external, no-op - */ - return ( - - ); - } + /** + login, clickthrough/kiosk open @id, wait for close + external, no-op + */ + return ( + + ); } - -AccessTokenSender.propTypes = { - handleAccessTokenMessage: PropTypes.func.isRequired, - url: PropTypes.string, -}; - -AccessTokenSender.defaultProps = { - url: undefined, -}; diff --git a/src/components/AnnotationSettings.js b/src/components/AnnotationSettings.js index f6fec27ad7..131d59328d 100644 --- a/src/components/AnnotationSettings.js +++ b/src/components/AnnotationSettings.js @@ -1,39 +1,26 @@ -import { Component } from 'react'; -import PropTypes from 'prop-types'; import VisibilityIcon from '@mui/icons-material/VisibilitySharp'; import VisibilityOffIcon from '@mui/icons-material/VisibilityOffSharp'; import MiradorMenuButton from '../containers/MiradorMenuButton'; +/* eslint-disable react/prop-types */ /** * AnnotationSettings is a component to handle various annotation * display settings in the Annotation companion window -*/ -export class AnnotationSettings extends Component { - /** - * Returns the rendered component - */ - render() { - const { - displayAll, displayAllDisabled, t, toggleAnnotationDisplay, - } = this.props; - - return ( - - { displayAll ? : } - - ); - } + */ +export default function AnnotationSettings({ + displayAll, + displayAllDisabled, + t, + toggleAnnotationDisplay, +}) { + return ( + + {displayAll ? : } + + ); } - -AnnotationSettings.propTypes = { - displayAll: PropTypes.bool.isRequired, - displayAllDisabled: PropTypes.bool.isRequired, - t: PropTypes.func.isRequired, - toggleAnnotationDisplay: PropTypes.func.isRequired, - windowId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types -}; diff --git a/src/components/App.js b/src/components/App.js index 0b57527c1f..daf1edf065 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,56 +1,29 @@ import { - createRef, Component, lazy, Suspense, + createRef, lazy, Suspense, } from 'react'; -import PropTypes from 'prop-types'; import PluginProvider from '../extend/PluginProvider'; import AppProviders from '../containers/AppProviders'; import WorkspaceContext from '../contexts/WorkspaceContext'; const WorkspaceArea = lazy(() => import('../containers/WorkspaceArea')); +/* eslint-disable react/prop-types */ /** * This is the top level Mirador component. * @prop {Object} manifests */ -export class App extends Component { - /** */ - constructor(props) { - super(props); - - this.areaRef = createRef(); - } - - /** - * render - * @return {String} - HTML markup for the component - */ - render() { - const { dndManager, plugins } = this.props; - - return ( - - - - } - > - - - - - - ); - } +export default function App({ dndManager, plugins = [] }) { + const areaRef = createRef(); + + return ( + + + + }> + + + + + + ); } - -App.propTypes = { - dndManager: PropTypes.object, // eslint-disable-line react/forbid-prop-types - plugins: PropTypes.array, // eslint-disable-line react/forbid-prop-types -}; - -App.defaultProps = { - dndManager: undefined, - plugins: [], -}; - -export default App; diff --git a/src/components/Branding.js b/src/components/Branding.js index 9b3af649cc..a060a0e651 100644 --- a/src/components/Branding.js +++ b/src/components/Branding.js @@ -1,47 +1,37 @@ -import { Component } from 'react'; -import PropTypes from 'prop-types'; import IconButton from '@mui/material/IconButton'; import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import MiradorIcon from './icons/MiradorIcon'; +/* eslint-disable react/prop-types */ /** * Display a branding icon */ -export class Branding extends Component { - /** */ - render() { - const { t, variant, ...ContainerProps } = this.props; - - return ( - - { variant === 'wide' && ( +export default function Branding({ t = (k) => k, variant = 'default', ...ContainerProps }) { + return ( + + {variant === 'wide' && ( - {t('mirador')} + + {t('mirador')} + - )} - - - - - - - ); - } + )} + + + + + + + ); } - -Branding.propTypes = { - t: PropTypes.func, - variant: PropTypes.oneOf(['default', 'wide']), -}; - -Branding.defaultProps = { - t: k => k, - variant: 'default', -}; diff --git a/src/components/IIIFAuthentication.js b/src/components/IIIFAuthentication.js index c804e69715..682eecef3a 100644 --- a/src/components/IIIFAuthentication.js +++ b/src/components/IIIFAuthentication.js @@ -1,6 +1,6 @@ import { Component } from 'react'; import PropTypes from 'prop-types'; -import { AccessTokenSender } from './AccessTokenSender'; +import AccessTokenSender from './AccessTokenSender'; import { NewWindow } from './NewWindow'; import WindowAuthenticationBar from '../containers/WindowAuthenticationBar'; diff --git a/src/containers/AnnotationSettings.js b/src/containers/AnnotationSettings.js index 1c1dd8d0c6..3c59bc8697 100644 --- a/src/containers/AnnotationSettings.js +++ b/src/containers/AnnotationSettings.js @@ -7,7 +7,7 @@ import { getAnnotationResourcesByMotivation, getWindow, } from '../state/selectors'; -import { AnnotationSettings } from '../components/AnnotationSettings'; +import AnnotationSettings from '../components/AnnotationSettings'; /** * Mapping redux state to component props using connect diff --git a/src/containers/Branding.js b/src/containers/Branding.js index 1e343b6f57..3f9d808a62 100644 --- a/src/containers/Branding.js +++ b/src/containers/Branding.js @@ -1,4 +1,4 @@ import { withPlugins } from '../extend/withPlugins'; -import { Branding } from '../components/Branding'; +import Branding from '../components/Branding'; export default withPlugins('Branding')(Branding);