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

Better RTL support in gallery mode

parent 807d42da
No related branches found
No related tags found
No related merge requests found
...@@ -32,4 +32,16 @@ describe('GalleryView', () => { ...@@ -32,4 +32,16 @@ describe('GalleryView', () => {
it('renders gallery items for all canvases', () => { it('renders gallery items for all canvases', () => {
expect(wrapper.find(GalleryViewThumbnail).length).toBe(3); expect(wrapper.find(GalleryViewThumbnail).length).toBe(3);
}); });
describe('when viewingDirection="right-to-left"', () => {
beforeEach(() => {
wrapper = createWrapper({
viewingDirection: 'right-to-left',
});
});
it('sets up Paper to be rtl', () => {
expect(wrapper.find('WithStyles(ForwardRef(Paper))').props().dir).toEqual('rtl');
});
});
}); });
...@@ -12,11 +12,13 @@ export class GalleryView extends Component { ...@@ -12,11 +12,13 @@ export class GalleryView extends Component {
*/ */
render() { render() {
const { const {
canvases, classes, windowId, canvases, classes, viewingDirection, windowId,
} = this.props; } = this.props;
const htmlDir = viewingDirection === 'right-to-left' ? 'rtl' : 'ltr';
return ( return (
<Paper <Paper
component="section" component="section"
dir={htmlDir}
square square
elevation={0} elevation={0}
className={classes.galleryContainer} className={classes.galleryContainer}
...@@ -39,9 +41,11 @@ export class GalleryView extends Component { ...@@ -39,9 +41,11 @@ export class GalleryView extends Component {
GalleryView.propTypes = { GalleryView.propTypes = {
canvases: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types canvases: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
classes: PropTypes.objectOf(PropTypes.string), classes: PropTypes.objectOf(PropTypes.string),
viewingDirection: PropTypes.string,
windowId: PropTypes.string.isRequired, windowId: PropTypes.string.isRequired,
}; };
GalleryView.defaultProps = { GalleryView.defaultProps = {
classes: {}, classes: {},
viewingDirection: '',
}; };
...@@ -3,7 +3,7 @@ import { connect } from 'react-redux'; ...@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { GalleryView } from '../components/GalleryView'; import { GalleryView } from '../components/GalleryView';
import { getManifestCanvases } from '../state/selectors'; import { getManifestCanvases, getManifestViewingDirection } from '../state/selectors';
/** /**
* mapStateToProps - to hook up connect * mapStateToProps - to hook up connect
...@@ -13,6 +13,7 @@ import { getManifestCanvases } from '../state/selectors'; ...@@ -13,6 +13,7 @@ import { getManifestCanvases } from '../state/selectors';
const mapStateToProps = (state, { windowId }) => ( const mapStateToProps = (state, { windowId }) => (
{ {
canvases: getManifestCanvases(state, { windowId }), canvases: getManifestCanvases(state, { windowId }),
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