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

Update: Open Preview Thumbnails by default #971

Merged
merged 4 commits into from
Apr 2, 2019

Conversation

ConradJChan
Copy link
Contributor

@ConradJChan ConradJChan commented Apr 1, 2019

Will open the Preview Thumbnails by default for document viewers. Will also remember on a per file basis (via localStorage) the toggle state of the thumbnails sidebar.

Todo:

  • unit tests
  • e2e tests
  • verify UX with design

@boxcla
Copy link

boxcla commented Apr 1, 2019

Verified that @ConradJChan has signed the CLA. Thanks for the pull request!

src/lib/viewers/doc/DocBaseViewer.js Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Show resolved Hide resolved
src/lib/viewers/doc/__tests__/DocBaseViewer-test.js Outdated Show resolved Hide resolved
this.rootEl.insertBefore(this.thumbnailsSidebarEl, this.containerEl);

if (this.getCachedThumbnailsToggledState()) {
this.rootEl.classList.add(CLASS_BOX_PREVIEW_THUMBNAILS_OPEN);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strongly recommend moving this to its own method. The sidebar open class logic is going to be in multiple places and will require a OPEN_ACTIVE class now, as well.

src/lib/viewers/doc/DocBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Show resolved Hide resolved
* localStorage if not cached. Defaults to true if not found.
* @return {boolean} Whether thumbnails is toggled open or not
*/
getCachedThumbnailsToggledState() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this live in the Thumbnails Sidebar class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a follow on PR to see how I can clean this up

src/lib/viewers/doc/DocBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Outdated Show resolved Hide resolved
const thumbnailsToggledMap = this.cache.get(THUMBNAILS_SIDEBAR_TOGGLED_MAP_KEY) || {};
const newThumbnailsToggledMap = { ...thumbnailsToggledMap, [this.options.file.id]: !!isOpen };

this.cache.set(THUMBNAILS_SIDEBAR_TOGGLED_MAP_KEY, newThumbnailsToggledMap, true /* useLocalStorage */);
Copy link
Collaborator

@jstoffan jstoffan Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the /* useLocalStorage */ comment needed? I thought it was a webpack annotation for a second.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah not needed, was a copy pasta

@ConradJChan ConradJChan merged commit 5be09ef into box:master Apr 2, 2019
@ConradJChan ConradJChan deleted the thumbnails-open branch April 2, 2019 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants