Skip to content
Snippets Groups Projects
Commit 0c6fa5b0 authored by Jack Reed's avatar Jack Reed
Browse files

Sets up ThumbnailNavigation to support right-to-left viewing

parent f655e84c
No related branches found
No related tags found
No related merge requests found
...@@ -130,4 +130,17 @@ describe('ThumbnailNavigation', () => { ...@@ -130,4 +130,17 @@ describe('ThumbnailNavigation', () => {
}); });
}); });
}); });
describe('when viewingDirection="right-to-left"', () => {
beforeEach(() => {
wrapper = createWrapper({
viewingDirection: 'right-to-left',
});
});
it('sets up react-window to be rtl', () => {
expect(wrapper
.find('AutoSizer').dive().find('List').dive()
.props().style.direction).toEqual('rtl');
});
});
}); });
...@@ -176,11 +176,13 @@ export class ThumbnailNavigation extends Component { ...@@ -176,11 +176,13 @@ export class ThumbnailNavigation extends Component {
classes, classes,
config, config,
position, position,
viewingDirection,
windowId, windowId,
} = this.props; } = this.props;
if (position === 'off') { if (position === 'off') {
return <></>; return <></>;
} }
const htmlDir = viewingDirection === 'right-to-left' ? 'rtl' : 'ltr';
return ( return (
<Paper <Paper
className={classNames( className={classNames(
...@@ -201,6 +203,7 @@ export class ThumbnailNavigation extends Component { ...@@ -201,6 +203,7 @@ export class ThumbnailNavigation extends Component {
> >
{({ height, width }) => ( {({ height, width }) => (
<List <List
direction={htmlDir}
height={this.areaHeight(height)} height={this.areaHeight(height)}
itemCount={this.itemCount()} itemCount={this.itemCount()}
itemSize={this.calculateScaledSize} itemSize={this.calculateScaledSize}
...@@ -236,6 +239,7 @@ ThumbnailNavigation.propTypes = { ...@@ -236,6 +239,7 @@ ThumbnailNavigation.propTypes = {
setPreviousCanvas: PropTypes.func, setPreviousCanvas: PropTypes.func,
t: PropTypes.func.isRequired, t: PropTypes.func.isRequired,
view: PropTypes.string, view: PropTypes.string,
viewingDirection: PropTypes.string,
windowId: PropTypes.string.isRequired, windowId: PropTypes.string.isRequired,
}; };
...@@ -245,4 +249,5 @@ ThumbnailNavigation.defaultProps = { ...@@ -245,4 +249,5 @@ ThumbnailNavigation.defaultProps = {
setNextCanvas: () => {}, setNextCanvas: () => {},
setPreviousCanvas: () => {}, setPreviousCanvas: () => {},
view: undefined, view: undefined,
viewingDirection: '',
}; };
...@@ -9,6 +9,7 @@ import { ThumbnailNavigation } from '../components/ThumbnailNavigation'; ...@@ -9,6 +9,7 @@ import { ThumbnailNavigation } from '../components/ThumbnailNavigation';
import { import {
getNextCanvasGrouping, getPreviousCanvasGrouping, getNextCanvasGrouping, getPreviousCanvasGrouping,
getManifestCanvases, getCanvasIndex, getWindowViewType, getManifestCanvases, getCanvasIndex, getWindowViewType,
getManifestViewingDirection,
} from '../state/selectors'; } from '../state/selectors';
/** /**
...@@ -29,6 +30,7 @@ const mapStateToProps = (state, { windowId }) => { ...@@ -29,6 +30,7 @@ const mapStateToProps = (state, { windowId }) => {
hasPreviousCanvas: !!getPreviousCanvasGrouping(state, { windowId }), hasPreviousCanvas: !!getPreviousCanvasGrouping(state, { windowId }),
position: state.companionWindows[state.windows[windowId].thumbnailNavigationId].position, position: state.companionWindows[state.windows[windowId].thumbnailNavigationId].position,
view: viewType, view: viewType,
viewingDirection: getManifestViewingDirection(state, { windowId }),
}; };
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment