allenai / pdf-component-library

44 stars 4 forks source link

Adding Visibility Detector Class & Unit Test For PDF Component #146

Closed huytr1995 closed 2 years ago

huytr1995 commented 2 years ago

Description

Ref: https://github.com/allenai/scholar/issues/32907

To be able to get the ability to display the current page we need to add code of Paul prototype PR. So this PR address that

Reviewer Instructions

@yensung this PR add both visibleOutLine & visiblePages functionality and also the rest of the scrollContext logic. The VisibilityDetector.ts is a high level abstraction layer since the logic of both is really similar but just different attribute or selector that being used. This VisiblityDetector.ts has been going through Paul for code structure and usage. Unit test has been set up for it too. We dont unit test anything directly from ScrollContext but rather on the abstraction layer. I'm also taken the liberty to bring in Sinon to improve our test. To be able to test this we need to do UI change which there will be a follow up PR for this.

Testing Plan

Unit test to verify everything pass.

Output / Screenshots

image

A11y

No A11y involvement