Skip to content

Commit

Permalink
Merge pull request #6211 from wellcomecollection/show-labels-in-viewer
Browse files Browse the repository at this point in the history
show canvas labels if toggle is on
  • Loading branch information
gestchild authored Mar 11, 2021
2 parents 171d0e3 + a4b7493 commit b757afb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
32 changes: 27 additions & 5 deletions common/views/components/IIIFViewer/parts/IIIFCanvasThumbnail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FunctionComponent, useState } from 'react';
import { FunctionComponent, useState, useContext } from 'react';
import { IIIFCanvas } from '@weco/common/model/iiif';
import { classNames, font } from '@weco/common/utils/classnames';
import styled from 'styled-components';
Expand All @@ -8,6 +8,8 @@ import IIIFResponsiveImage from '@weco/common/views/components/IIIFResponsiveIma
import LL from '@weco/common/views/components/styled/LL';
import { getImageAuthService } from '@weco/common/utils/iiif';
import Padlock from '@weco/common/views/components/styled/Padlock';
import TogglesContext from '@weco/common/views/components/TogglesContext/TogglesContext';
import Space from '@weco/common/views/components/styled/Space';

type ViewerThumbProps = {
isFocusable?: boolean;
Expand Down Expand Up @@ -106,6 +108,7 @@ const IIIFCanvasThumbnail: FunctionComponent<IIIFCanvasThumbnailProps> = ({
thumbnailService.sizes
.sort((a, b) => a.width - b.width)
.find(dimensions => dimensions.width > 100);
const { showCanvasLabels } = useContext(TogglesContext);
return (
<IIIFViewerThumb
onClick={clickHandler}
Expand Down Expand Up @@ -159,10 +162,29 @@ const IIIFCanvasThumbnail: FunctionComponent<IIIFCanvasThumbnailProps> = ({
)}
</ImageContainer>
<div>
<IIIFViewerThumbNumber isActive={isActive}>
<span className="visually-hidden">image </span>
{thumbNumber}
</IIIFViewerThumbNumber>
{showCanvasLabels ? (
<>
{canvas.label.trim() !== '-' && (
<Space v={{ size: 's', properties: ['margin-bottom'] }}>
<IIIFViewerThumbNumber isActive={isActive}>
{canvas.label}
</IIIFViewerThumbNumber>
</Space>
)}
<div>
<IIIFViewerThumbNumber isActive={isActive}>
<span
style={{ fontSize: '11px' }}
>{`image ${thumbNumber}`}</span>
</IIIFViewerThumbNumber>
</div>
</>
) : (
<IIIFViewerThumbNumber isActive={isActive}>
<span className="visually-hidden">image </span>
{thumbNumber}
</IIIFViewerThumbNumber>
)}
</div>
</IIIFViewerThumbInner>
</IIIFViewerThumb>
Expand Down
7 changes: 7 additions & 0 deletions toggles/webapp/toggles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export default {
toggles: [
{
id: 'showCanvasLabels',
title: 'Show canvas labels on viewer thumbnails',
description:
'Shows the canvas label on the viewer thumbnails above the image number',
defaultValue: false,
},
{
id: 'openWithAdvisoryPrototype',
title: 'Open with advisory',
Expand Down

0 comments on commit b757afb

Please sign in to comment.