Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show canvas labels if toggle is on #6211

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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