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

Extending the thumbnail label to reveal more text #758 #950

Open
wants to merge 35 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3cb5067
gallery view checkbox
Saira-A Jan 5, 2024
283d676
checkbox in left panel
Saira-A Jan 5, 2024
d1c6d5b
4.1.0
Saira-A Jan 5, 2024
e856014
working checkbox test
Saira-A Jan 14, 2024
a48863c
checkbox test
Saira-A Jan 14, 2024
070e37f
left panel
Saira-A Jan 18, 2024
5547def
width 98px
Saira-A Jan 18, 2024
89afa9d
labels extended by default
Saira-A Jan 18, 2024
b166ff3
translations
Saira-A Jan 18, 2024
d438487
testing
Saira-A Jan 18, 2024
7451743
comments
Saira-A Jan 19, 2024
f509070
review
Saira-A Jan 23, 2024
217f718
changes
Saira-A Jan 24, 2024
6aede73
remove whitespace
Saira-A Jan 24, 2024
bfcae9e
galleryView label height
Saira-A Jan 26, 2024
6215786
Revert "4.1.0"
Saira-A Feb 2, 2024
a71c7f1
Revert "4.1.0"
Saira-A Feb 2, 2024
55221dc
tests updated
Saira-A Feb 2, 2024
b4aa8d3
Revert "Revert "4.1.0""
Saira-A Feb 5, 2024
be33e3b
default to true
Saira-A Feb 13, 2024
4ec467f
update test
Saira-A Feb 13, 2024
be384a4
config
Saira-A Feb 13, 2024
db421f8
Truncate by default
Saira-A Feb 26, 2024
60e53fe
update test
Saira-A Feb 26, 2024
00a7917
Remove unnecessary newline.
demiankatz Feb 26, 2024
6ba0b98
Restore lost indentation.
demiankatz Feb 26, 2024
7c104e1
Fix indentation.
demiankatz Feb 26, 2024
76acb6e
Remove extra blank line.
demiankatz Feb 26, 2024
43d30dd
Fix indentation.
demiankatz Feb 26, 2024
5e4c880
Remove unwanted newline.
demiankatz Feb 26, 2024
1020ac2
Remove newline.
demiankatz Feb 26, 2024
751df42
Whitespace cleanup.
demiankatz Feb 26, 2024
7552f7d
resolve conflicts
Saira-A Jul 18, 2024
8b751fb
remove tests
Saira-A Jul 18, 2024
0a8f88b
Merge branch 'dev' into 758
Saira-A Jul 18, 2024
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
59 changes: 57 additions & 2 deletions __tests__/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,68 @@
test.skip('Configuration options', () => {});

const puppeteer = require('puppeteer');

describe('Universal Viewer', () => {
let browser;
let page;

beforeAll(async () => {
await page.goto('http://localhost:4444/');
browser = await puppeteer.launch();
page = await browser.newPage();
await page.goto('http://localhost:8080/#?xywh=-1741%2C125%2C8017%2C6807&iiifManifestId=http%3A%2F%2Fiiif.bodleian.ox.ac.uk%2Fexamples%2Fmushaf4.json');
});

afterAll(async () => {
await browser.close();
});

it('has the correct page title', async () => {
const title = await page.title();
expect(title).toBe('Universal Viewer Examples');
});

it('extends thumbnail labels when "extend labels" checkbox is clicked', async () => {




await page.waitForSelector('.btn.imageBtn.settings .uv-icon-settings');
await page.click('.btn.imageBtn.settings .uv-icon-settings');


await page.waitForSelector('.setting.extendThumbnailLabels');


await page.click('#extendThumbnailLabels');


await page.waitForSelector('.thumb.extend-labels');


const labelContainerStyle = await page.evaluate(() => {
const firstThumbnailLabelContainer = document.querySelector('.thumb.extend-labels .info .label');
return window.getComputedStyle(firstThumbnailLabelContainer).getPropertyValue('white-space');
});


expect(labelContainerStyle).toBe('break-spaces');
});

it('settings button is visible', async () => {

await page.waitForSelector('.btn.imageBtn.settings');


const isSettingsButtonVisible = await page.evaluate(() => {
const settingsButton = document.querySelector('.btn.imageBtn.settings');
const style = window.getComputedStyle(settingsButton);
return style.getPropertyValue('visibility') !== 'hidden' && style.getPropertyValue('display') !== 'none';
});

expect(isSettingsButtonVisible).toBe(true);
});
});

// it('loads the viewer images', async () => {
// await page.waitForSelector('#thumb0');
// const imageSrc = await page.$eval('#thumb0 img', e => e.src);
Expand All @@ -17,4 +72,4 @@ describe('Universal Viewer', () => {
// )
// );
// });
});

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "universalviewer",
"version": "4.0.25",
"version": "4.1.0",
Saira-A marked this conversation as resolved.
Show resolved Hide resolved
"description": "The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎",
"engines": {
"node": ">=14.18.1",
Expand Down Expand Up @@ -134,6 +134,7 @@
"enableTsDiagnostics": true
}
},
"testTimeout": 10000,
"preset": "jest-puppeteer",
"transform": {
"^.+\\.tsx?$": "ts-jest"
Expand Down
1 change: 1 addition & 0 deletions src/content-handlers/iiif/BaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export type SettingsDialogueContent = DialogueContent & {
clickToZoomEnabled: string;
pagingEnabled: string;
reducedMotion: string;
extendThumbnailLabels: string;
preserveViewport: string;
title: string;
website: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"clickToZoomEnabled": "Mouse Click To Zoom",
"pagingEnabled": "Two Page View",
"reducedMotion": "Reduce motion (disables animations)",
"extendThumbnailLabels": "Extend Thumbnail Labels",
"preserveViewport": "Preserve Zoom",
"title": "Settings",
"website": "<a href='https://github.com/universalviewer/universalviewer#contributors'>more info</a>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$twoPageView",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface ISettings {
preserveViewport?: boolean;
clickToZoomEnabled?: boolean;
reducedAnimation?: boolean;
extendThumbnailLabels?: boolean;
Saira-A marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export class SettingsDialogue extends BaseSettingsDialogue {
$clickToZoomEnabled: JQuery;
$clickToZoomEnabledCheckbox: JQuery;
$clickToZoomEnabledLabel: JQuery;
$extendThumbnailLabels: JQuery;
$extendThumbnailLabelsLabel: JQuery;
$extendThumbnailLabelsCheckbox: JQuery;
$navigatorEnabled: JQuery;
$navigatorEnabledCheckbox: JQuery;
$navigatorEnabledLabel: JQuery;
Expand All @@ -14,6 +17,7 @@ export class SettingsDialogue extends BaseSettingsDialogue {
$preserveViewport: JQuery;
$preserveViewportCheckbox: JQuery;
$preserveViewportLabel: JQuery;


constructor($element: JQuery) {
super($element);
Expand Down Expand Up @@ -53,6 +57,30 @@ export class SettingsDialogue extends BaseSettingsDialogue {
);
this.$pagingEnabled.append(this.$pagingEnabledLabel);

// Extend Thumbnail Labels
this.$extendThumbnailLabels = $('<div class="setting extendThumbnailLabels"></div>');
this.$scroll.append(this.$extendThumbnailLabels);

this.$extendThumbnailLabelsCheckbox = $(
'<input id="extendThumbnailLabels" type="checkbox" tabindex="0" />'
);

this.$extendThumbnailLabels.append(this.$extendThumbnailLabelsCheckbox);

this.$extendThumbnailLabelsLabel = $(
'<label for="extendThumbnailLabels">' + this.content.extendThumbnailLabels + "</label>"
);

this.$extendThumbnailLabels.append(this.$extendThumbnailLabelsLabel);

this.$extendThumbnailLabelsCheckbox.change(() => {
const settings: ISettings = {};

settings.extendThumbnailLabels = this.$extendThumbnailLabelsCheckbox.is(":checked");

this.updateSettings(settings);
});

this.$clickToZoomEnabled = $('<div class="setting clickToZoom"></div>');
this.$scroll.append(this.$clickToZoomEnabled);

Expand Down Expand Up @@ -130,6 +158,9 @@ export class SettingsDialogue extends BaseSettingsDialogue {

this.updateSettings(settings);
});

Saira-A marked this conversation as resolved.
Show resolved Hide resolved


}

open(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$goHome",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
"clickToZoomEnabled": "$clickToZoomEnabled",
"pagingEnabled": "$goHome",
"reducedMotion": "$reducedMotion",
"extendThumbnailLabels": "$extendThumbnailLabels",
"preserveViewport": "$preserveViewport",
"title": "$settings",
"website": "$uvWebsite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,26 +491,30 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
}

const paged: boolean =
!!this.extension.getSettings().pagingEnabled &&
this.extension.helper.isPaged();

const selectedIndices: number[] = this.extension.getPagedIndices(
this.extension.helper.canvasIndex
);

// console.log("selectedIndeces", selectedIndices);

this.thumbsRoot.render(
createElement(ThumbsView, {
thumbs,
paged,
viewingDirection: viewingDirection || ViewingDirection.LEFT_TO_RIGHT,
selected: selectedIndices,
onClick: (thumb: Thumb) => {
this.extensionHost.publish(IIIFEvents.THUMB_SELECTED, thumb);
},
})
);
!!this.extension.getSettings().pagingEnabled &&
Saira-A marked this conversation as resolved.
Show resolved Hide resolved
this.extension.helper.isPaged();

const selectedIndices: number[] = this.extension.getPagedIndices(
this.extension.helper.canvasIndex
);

// console.log("selectedIndeces", selectedIndices);
Saira-A marked this conversation as resolved.
Show resolved Hide resolved

const settings = this.extension.getSettings(); // Get settings object

this.thumbsRoot.render(
createElement(ThumbsView, {
thumbs,
paged,
viewingDirection: viewingDirection || ViewingDirection.LEFT_TO_RIGHT,
selected: selectedIndices,
extendThumbnailLabels: settings.extendThumbnailLabels || false,
onClick: (thumb: Thumb) => {
this.extensionHost.publish(IIIFEvents.THUMB_SELECTED, thumb);
},
})
);

}

createGalleryView(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const $ = require("jquery");
import { IIIFEvents } from "../../IIIFEvents";
import { ContentLeftPanel } from "../../extensions/config/ContentLeftPanel";
import { BaseView } from "../uv-shared-module/BaseView";
import { GalleryComponent } from "@iiif/iiif-gallery-component";
import $ from "jquery";

export class GalleryView extends BaseView<ContentLeftPanel> {
isOpen: boolean = false;
galleryComponent: any;
galleryData: any;
$gallery: JQuery;
$extendLabelsCheckbox: JQuery | undefined;

constructor($element: JQuery) {
super($element, true, true);
Expand All @@ -31,7 +32,7 @@ export class GalleryView extends BaseView<ContentLeftPanel> {

this.galleryComponent.on(
"thumbSelected",
function(thumb: any) {
function (thumb: any) {
that.extensionHost.publish(IIIFEvents.GALLERY_THUMB_SELECTED, thumb);
that.extensionHost.publish(IIIFEvents.THUMB_SELECTED, thumb);
},
Expand All @@ -40,15 +41,15 @@ export class GalleryView extends BaseView<ContentLeftPanel> {

this.galleryComponent.on(
"decreaseSize",
function() {
function () {
that.extensionHost.publish(IIIFEvents.GALLERY_DECREASE_SIZE);
},
false
);

this.galleryComponent.on(
"increaseSize",
function() {
function () {
that.extensionHost.publish(IIIFEvents.GALLERY_INCREASE_SIZE);
},
false
Expand All @@ -64,12 +65,14 @@ export class GalleryView extends BaseView<ContentLeftPanel> {
show(): void {
this.isOpen = true;
this.$element.show();

// todo: would be better to have no imperative methods on components and use a reactive pattern
setTimeout(() => {
this.galleryComponent.selectIndex(this.extension.helper.canvasIndex);
this.applyExtendedLabelsStyles();
}, 10);
}

Saira-A marked this conversation as resolved.
Show resolved Hide resolved

hide(): void {
this.isOpen = false;
Expand All @@ -82,4 +85,12 @@ export class GalleryView extends BaseView<ContentLeftPanel> {
const $header: JQuery = this.$gallery.find(".header");
$main.height(this.$element.height() - $header.height());
}


Saira-A marked this conversation as resolved.
Show resolved Hide resolved

public applyExtendedLabelsStyles(): void {

this.$gallery.addClass('label-extended');
}

}
Loading