diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 311f5aa35..51c6ea798 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -7,7 +7,7 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: [ master, mui5 ] jobs: build: diff --git a/__tests__/src/components/ManifestListItem.test.js b/__tests__/src/components/ManifestListItem.test.js index eeba7e6c9..bd444de91 100644 --- a/__tests__/src/components/ManifestListItem.test.js +++ b/__tests__/src/components/ManifestListItem.test.js @@ -23,12 +23,17 @@ describe('ManifestListItem', () => { createWrapper({ buttonRef: 'ref' }); expect(screen.getByRole('listitem')).toHaveAttribute('data-manifestid', 'http://example.com'); + expect(screen.getByRole('listitem')).toHaveClass('MuiListItem-root'); expect(screen.getByRole('button')).toHaveTextContent('xyz'); }); - it('properly interprets active in the DOM', () => { - createWrapper({ active: true }); + it('adds a class when the item is active', () => { + createWrapper({ active: true, classes: { active: 'active' } }); + // If this is true, we can assume the proper styling classes are being applied expect(screen.getByRole('listitem')).toHaveAttribute('data-active', 'true'); + + expect(screen.getByRole('listitem')).toHaveClass('active'); + expect(screen.getByRole('listitem')).toHaveClass('Mui-selected'); }); it('renders a placeholder element until real data is available', () => { const { container } = createWrapper({ ready: false }); diff --git a/src/components/CompanionArea.js b/src/components/CompanionArea.js index 638cd209d..f1df3b45b 100644 --- a/src/components/CompanionArea.js +++ b/src/components/CompanionArea.js @@ -39,6 +39,13 @@ const StyledToggleButton = styled(MiradorMenuButton)({ /** */ export class CompanionArea extends Component { + /** */ + areaLayoutClass() { + const { classes, position } = this.props; + + return (position === 'bottom' || position === 'far-bottom') ? classes.horizontal : null; + } + /** */ collapseIcon() { const { companionAreaOpen, direction } = this.props; @@ -75,7 +82,7 @@ export class CompanionArea extends Component { companionWindowIds, companionAreaOpen, setCompanionAreaOpen, position, sideBarOpen, t, windowId, } = this.props; - + const className = [this.areaLayoutClass(), ns(`companion-area-${position}`)].join(' '); return ( {}, sideBarOpen: false, }; diff --git a/src/components/CompanionWindow.js b/src/components/CompanionWindow.js index d0bbdb462..0f4cca214 100644 --- a/src/components/CompanionWindow.js +++ b/src/components/CompanionWindow.js @@ -91,7 +91,7 @@ export class CompanionWindow extends Component { */ render() { const { - ariaLabel, paperClassName, onCloseClick, updateCompanionWindow, isDisplayed, + ariaLabel, classes, paperClassName, onCloseClick, updateCompanionWindow, isDisplayed, position, t, title, children, titleControls, size, defaultSidebarPanelWidth, defaultSidebarPanelHeight, } = this.props; @@ -135,7 +135,7 @@ export class CompanionWindow extends Component { display: isDisplayed ? null : 'none', order: position === 'left' ? -1 : null, }} - className={[ns(`companion-window-${position}`), paperClassName].join(' ')} + className={[ns(`companion-window-${position}`), paperClassName, position === 'bottom' ? classes.horizontal : classes.vertical].join(' ')} square component="aside" aria-label={ariaLabel || title} @@ -161,7 +161,7 @@ export class CompanionWindow extends Component { minHeight: 'max-content', paddingLeft: 2, }} - className={ns('companion-window-header')} + className={[ns('companion-window-header'), size.width < 370 ? classes.small : null].join(' ')} disableGutters > ({ '&:hover,&:focus-within': { backgroundColor: theme.palette.action.hover, @@ -123,6 +125,8 @@ export class ManifestListItem extends Component { return ( ({ '&:hover,&:focus-within': { backgroundColor: theme.palette.action.hover, diff --git a/src/components/SanitizedHtml.js b/src/components/SanitizedHtml.js index f7f6180c4..01f12c507 100644 --- a/src/components/SanitizedHtml.js +++ b/src/components/SanitizedHtml.js @@ -14,7 +14,7 @@ export class SanitizedHtml extends Component { */ render() { const { - htmlString, ruleSet, ...props + classes, htmlString, ruleSet, ...props } = this.props; // Add a hook to make all links open a new window @@ -35,7 +35,7 @@ export class SanitizedHtml extends Component { textDecoration: 'underline', }, }} - className={[ns('third-party-html')].join(' ')} + className={[ns('third-party-html'), classes.root].join(' ')} dangerouslySetInnerHTML={{ // eslint-disable-line react/no-danger __html: DOMPurify.sanitize(htmlString, htmlRules[ruleSet]), }} @@ -46,6 +46,11 @@ export class SanitizedHtml extends Component { } SanitizedHtml.propTypes = { + classes: PropTypes.objectOf(PropTypes.string), htmlString: PropTypes.string.isRequired, ruleSet: PropTypes.string.isRequired, }; + +SanitizedHtml.defaultProps = { + classes: {}, +}; diff --git a/src/components/ScrollIndicatedDialogContent.js b/src/components/ScrollIndicatedDialogContent.js index 69fed57fe..b05d29be3 100644 --- a/src/components/ScrollIndicatedDialogContent.js +++ b/src/components/ScrollIndicatedDialogContent.js @@ -6,7 +6,8 @@ import DialogContent from '@mui/material/DialogContent'; * to indicate there is scrollable content */ export function ScrollIndicatedDialogContent(props) { - const { className, ...otherProps } = props; + const { classes, className, ...otherProps } = props; + const ourClassName = [className, classes.shadowScrollDialog].join(' '); return ( ); } ScrollIndicatedDialogContent.propTypes = { + classes: PropTypes.shape({ + shadowScrollDialog: PropTypes.string, + }), className: PropTypes.string, }; ScrollIndicatedDialogContent.defaultProps = { + classes: {}, className: '', }; diff --git a/src/components/SearchHit.js b/src/components/SearchHit.js index 1b96d21b2..a8f4aad8a 100644 --- a/src/components/SearchHit.js +++ b/src/components/SearchHit.js @@ -101,6 +101,7 @@ export class SearchHit extends Component { scrollTo={windowSelected && !focused} > {this.wrappedTopBar()} diff --git a/src/components/WindowSideBar.js b/src/components/WindowSideBar.js index eee9135f9..87e8d1ef2 100644 --- a/src/components/WindowSideBar.js +++ b/src/components/WindowSideBar.js @@ -13,12 +13,13 @@ export class WindowSideBar extends Component { */ render() { const { - direction, t, windowId, sideBarOpen, + classes, direction, t, windowId, sideBarOpen, } = this.props; return ( ({ flexShrink: 0, height: '100%', @@ -48,6 +49,7 @@ export class WindowSideBar extends Component { } WindowSideBar.propTypes = { + classes: PropTypes.objectOf(PropTypes.string), direction: PropTypes.string.isRequired, sideBarOpen: PropTypes.bool, t: PropTypes.func.isRequired, @@ -55,5 +57,6 @@ WindowSideBar.propTypes = { }; WindowSideBar.defaultProps = { + classes: {}, sideBarOpen: false, }; diff --git a/src/components/WindowTopMenuButton.js b/src/components/WindowTopMenuButton.js index b3b6679fc..4618bdb4a 100644 --- a/src/components/WindowTopMenuButton.js +++ b/src/components/WindowTopMenuButton.js @@ -49,7 +49,7 @@ export class WindowTopMenuButton extends Component { */ render() { const { - t, windowId, + classes, t, windowId, } = this.props; const { open, anchorEl } = this.state; const menuId = `window-menu_${windowId}`; @@ -59,6 +59,7 @@ export class WindowTopMenuButton extends Component { aria-haspopup="true" aria-label={t('windowMenu')} aria-owns={open ? menuId : undefined} + className={open ? classes.ctrlBtnSelected : undefined} sx={{ margin: 1, ...(open && { @@ -82,10 +83,12 @@ export class WindowTopMenuButton extends Component { } WindowTopMenuButton.propTypes = { + classes: PropTypes.objectOf(PropTypes.string), t: PropTypes.func, windowId: PropTypes.string.isRequired, }; WindowTopMenuButton.defaultProps = { + classes: {}, t: key => key, }; diff --git a/src/components/WorkspaceElasticWindow.js b/src/components/WorkspaceElasticWindow.js index 90dea640f..dea8c87b6 100644 --- a/src/components/WorkspaceElasticWindow.js +++ b/src/components/WorkspaceElasticWindow.js @@ -19,6 +19,7 @@ class WorkspaceElasticWindow extends Component { */ render() { const { + classes, companionWindowDimensions, focused, focusWindow, @@ -33,6 +34,7 @@ class WorkspaceElasticWindow extends Component { return ( {}, diff --git a/src/components/ZoomControls.js b/src/components/ZoomControls.js index f533c96f0..041fcbf45 100644 --- a/src/components/ZoomControls.js +++ b/src/components/ZoomControls.js @@ -61,10 +61,10 @@ export class ZoomControls extends Component { * @returns {Box | null} */ renderDivider() { - const { displayDivider } = this.props; + const { classes, displayDivider } = this.props; if (displayDivider) { - return ; + return ; } return null; @@ -103,6 +103,7 @@ export class ZoomControls extends Component { } ZoomControls.propTypes = { + classes: PropTypes.objectOf(PropTypes.string), displayDivider: PropTypes.bool, showZoomControls: PropTypes.bool, t: PropTypes.func, @@ -117,6 +118,7 @@ ZoomControls.propTypes = { }; ZoomControls.defaultProps = { + classes: {}, displayDivider: true, showZoomControls: false, t: key => key,