Skip to content

Commit 13d5e95

Browse files
committed
Prettier and CI Ecodev#100
1 parent 2766d9f commit 13d5e95

File tree

16 files changed

+1076
-475
lines changed

16 files changed

+1076
-475
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
node-version: '18'
2525
cache: 'yarn'
2626
- run: yarn --frozen-lockfile
27+
- run: yarn playwright install --with-deps
2728
- run: HEADLESS=1 yarn test
2829

2930
lint:

jest.config.cjs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ module.exports = {
55
testEnvironment: 'jsdom',
66
collectCoverage: true,
77
coverageDirectory: 'tests/logs/coverage',
8-
coverageReporters: [
9-
"text",
10-
"html",
11-
"lcov"
12-
],
8+
coverageReporters: ['text', 'html', 'lcov'],
139
moduleNameMapper: {
1410
'^.+\\.(css|scss)$': 'jest-transform-stub',
15-
'^.*photoswipe.*$': 'jest-transform-stub'
11+
'^.*photoswipe.*$': 'jest-transform-stub',
1612
},
1713
};

src/js/Column.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export class Column<Model extends ModelAttributes> {
2121
this._elementRef.style.width = this.options.width + 'px';
2222
}
2323

24-
public addItem(item: Item<Model>): void {
25-
this.collection.push(item);
26-
}
27-
2824
get height(): number {
2925
return this._elementRef.offsetHeight;
3026
}
@@ -36,4 +32,8 @@ export class Column<Model extends ModelAttributes> {
3632
get elementRef(): HTMLElement {
3733
return this._elementRef;
3834
}
35+
36+
public addItem(item: Item<Model>): void {
37+
this.collection.push(item);
38+
}
3939
}

src/js/Item.ts

Lines changed: 90 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export enum LabelVisibility {
88
}
99

1010
export declare interface ItemOptions {
11-
1211
/**
1312
* Enables ability to zoom images in photoswipe
1413
*/
@@ -38,55 +37,115 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
3837
* Cleaned title, used for label / button
3938
*/
4039
public readonly sanitizedTitle: string;
40+
/**
41+
* Reference to the select button
42+
*/
43+
private _checkbox!: HTMLButtonElement;
44+
/**
45+
* Element referring the "button" containing the label
46+
*/
47+
private figcaption: HTMLElement | null = null;
48+
49+
/**
50+
*
51+
* @param model Contains the source data given for an item (e.g. object instance from database with id etc...)
52+
*/
53+
public constructor(
54+
private readonly document: Document,
55+
private readonly options: ItemOptions,
56+
public readonly model: Model,
57+
) {
58+
this.sanitizedTitle = sanitizeHtml(model.title);
59+
}
4160

4261
/**
4362
* Actual row index in the list
4463
*/
4564
private _row!: number;
4665

66+
get row(): number {
67+
return this._row;
68+
}
69+
70+
set row(value: number) {
71+
this._row = value;
72+
}
73+
4774
/**
4875
* If is actually the last element of a row
4976
*/
5077
private _last!: boolean;
5178

79+
get last(): boolean {
80+
return this._last;
81+
}
82+
83+
set last(value: boolean) {
84+
this._last = value;
85+
}
86+
5287
/**
5388
* Computed size (real used size)
5489
*/
5590
private _width!: number;
91+
92+
get width(): number {
93+
return this._width;
94+
}
95+
96+
set width(value: number) {
97+
this._width = value;
98+
}
99+
56100
private _height!: number;
57101

102+
get height(): number {
103+
return this._height;
104+
}
105+
106+
set height(value: number) {
107+
this._height = value;
108+
}
109+
58110
private _cropped = true;
59111

112+
/* istanbul ignore next */
113+
get cropped(): boolean {
114+
return this._cropped;
115+
}
116+
117+
set cropped(value: boolean) {
118+
this._cropped = value;
119+
}
120+
60121
/**
61122
* Wherever item is selected or not
62123
*/
63124
private _selected = false;
64125

126+
/* istanbul ignore next */
127+
get selected(): boolean {
128+
return this._selected;
129+
}
130+
65131
/**
66132
* Item root element reference (figure)
67133
*/
68134
private _rootElement!: HTMLElement;
69135

70-
/**
71-
* Reference to the select button
72-
*/
73-
private _checkbox!: HTMLButtonElement;
136+
/* istanbul ignore next */
137+
get rootElement(): HTMLElement {
138+
return this._rootElement;
139+
}
74140

75-
/**
76-
* Element referring the "button" containing the label
77-
*/
78-
private figcaption: HTMLElement | null = null;
141+
/* istanbul ignore next */
142+
get enlargedWidth(): number {
143+
return this.model.enlargedWidth;
144+
}
79145

80-
/**
81-
*
82-
* @param model Contains the source data given for an item (e.g. object instance from database with id etc...)
83-
*/
84-
public constructor(
85-
private readonly document: Document,
86-
private readonly options: ItemOptions,
87-
public readonly model: Model,
88-
) {
89-
this.sanitizedTitle = sanitizeHtml(model.title);
146+
/* istanbul ignore next */
147+
get enlargedHeight(): number {
148+
return this.model.enlargedHeight;
90149
}
91150

92151
/**
@@ -131,7 +190,9 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
131190
root = figure;
132191
zoomableElement = figure;
133192
figure.appendChild(image);
134-
console.warn('Link or activation are ignored when lightbox is true and there is no caption because there is no element to support it');
193+
console.warn(
194+
'Link or activation are ignored when lightbox is true and there is no caption because there is no element to support it',
195+
);
135196
} else if (this.options.lightbox && !caption && !link) {
136197
root = figure;
137198
zoomableElement = figure;
@@ -218,6 +279,10 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
218279
this.updateAriaSelectedStatus();
219280
}
220281

282+
public remove(): void {
283+
this._rootElement.parentNode?.removeChild(this._rootElement);
284+
}
285+
221286
private updateAriaSelectedStatus(): void {
222287
this._checkbox.setAttribute('aria-checked', String(this._selected));
223288
this._checkbox.setAttribute('aria-label', this._selected ? 'Unselect' : 'Select');
@@ -244,10 +309,6 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
244309
return null;
245310
}
246311

247-
public remove(): void {
248-
this._rootElement.parentNode?.removeChild(this._rootElement);
249-
}
250-
251312
/**
252313
* Label is visible if options mention hover or always
253314
* @private
@@ -256,7 +317,11 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
256317
let showLabel = false;
257318

258319
const showLabelValues = [LabelVisibility.ALWAYS, LabelVisibility.HOVER];
259-
if (this.sanitizedTitle && this.options.labelVisibility && showLabelValues.includes(this.options.labelVisibility)) {
320+
if (
321+
this.sanitizedTitle &&
322+
this.options.labelVisibility &&
323+
showLabelValues.includes(this.options.labelVisibility)
324+
) {
260325
showLabel = true;
261326
}
262327

@@ -353,7 +418,6 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
353418
}
354419

355420
private handleActivation(element: HTMLElement): void {
356-
357421
element.setAttribute('aria-label', 'activate item');
358422
const activate = (ev: MouseEvent | KeyboardEvent) => {
359423
const data: ItemActivateEventDetail<Model> = {item: this, event: ev};
@@ -392,65 +456,4 @@ export class Item<Model extends ModelAttributes = ModelAttributes> {
392456
});
393457
}
394458
}
395-
396-
get last(): boolean {
397-
return this._last;
398-
}
399-
400-
set last(value: boolean) {
401-
this._last = value;
402-
}
403-
404-
get row(): number {
405-
return this._row;
406-
}
407-
408-
set row(value: number) {
409-
this._row = value;
410-
}
411-
412-
get height(): number {
413-
return this._height;
414-
}
415-
416-
set height(value: number) {
417-
this._height = value;
418-
}
419-
420-
get width(): number {
421-
return this._width;
422-
}
423-
424-
set width(value: number) {
425-
this._width = value;
426-
}
427-
428-
/* istanbul ignore next */
429-
get cropped(): boolean {
430-
return this._cropped;
431-
}
432-
433-
set cropped(value: boolean) {
434-
this._cropped = value;
435-
}
436-
437-
/* istanbul ignore next */
438-
get enlargedWidth(): number {
439-
return this.model.enlargedWidth;
440-
}
441-
442-
/* istanbul ignore next */
443-
get enlargedHeight(): number {
444-
return this.model.enlargedHeight;
445-
}
446-
447-
/* istanbul ignore next */
448-
get selected(): boolean {
449-
return this._selected;
450-
}
451-
452-
/* istanbul ignore next */
453-
get rootElement(): HTMLElement {
454-
return this._rootElement;
455-
}
456459
}

0 commit comments

Comments
 (0)