From 29b83f023442c313ca5cf95f70f6430f101060e6 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 14 Oct 2024 19:55:32 -0400 Subject: reorganized comparisonBox related components -- moved stuff down into Docs.Crete and CurrentUserUtils. changed Doc.Copy to copy Doc's in fields tagged with cloneOnCopy. Changed ComparisonBox to support hover for slide or flip views. Fixed pointerEfvents for hover in comparisonBox --- src/client/views/nodes/ComparisonBox.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/client/views/nodes/ComparisonBox.scss') diff --git a/src/client/views/nodes/ComparisonBox.scss b/src/client/views/nodes/ComparisonBox.scss index c328ef4bf..d1cc48051 100644 --- a/src/client/views/nodes/ComparisonBox.scss +++ b/src/client/views/nodes/ComparisonBox.scss @@ -246,8 +246,7 @@ pointer-events: none; } -.comparisonBox-interactive { - pointer-events: unset; +.comparisonBox-slide { cursor: ew-resize; .slide-bar { -- cgit v1.2.3-70-g09d2 From dd93f5175064850c6c0e47f025cd7bbba1f23106 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 17 Oct 2024 17:19:11 -0400 Subject: fixed quizMode to actually render and to get pointer events. --- src/client/views/collections/CollectionCardDeckView.tsx | 14 +++++++++++++- src/client/views/nodes/ComparisonBox.scss | 3 +++ src/client/views/nodes/ComparisonBox.tsx | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/client/views/nodes/ComparisonBox.scss') diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx index 5faabacf4..b86dad9d7 100644 --- a/src/client/views/collections/CollectionCardDeckView.tsx +++ b/src/client/views/collections/CollectionCardDeckView.tsx @@ -4,7 +4,7 @@ import { computedFn } from 'mobx-utils'; import * as React from 'react'; import { ClientUtils, DashColor, imageUrlToBase64, returnFalse, returnNever, returnZero } from '../../../ClientUtils'; import { emptyFunction } from '../../../Utils'; -import { Doc } from '../../../fields/Doc'; +import { Doc, DocListCast, Opt } from '../../../fields/Doc'; import { Animation, DocData } from '../../../fields/DocSymbols'; import { Id } from '../../../fields/FieldSymbols'; import { List } from '../../../fields/List'; @@ -24,6 +24,7 @@ import { DocumentView, DocumentViewProps } from '../nodes/DocumentView'; import { GPTPopup, GPTPopupMode } from '../pdf/GPTPopup/GPTPopup'; import './CollectionCardDeckView.scss'; import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView'; +import { FocusViewOptions } from '../nodes/FocusViewOptions'; enum cardSortings { Time = 'time', @@ -342,6 +343,7 @@ export class CollectionCardView extends CollectionSubView() { fitWidth={returnFalse} waitForDoubleClickToClick={returnNever} scriptContext={this} + focus={this.focus} onDoubleClickScript={this.onChildDoubleClick} onClickScript={this._curDoc === doc ? undefined : this._clickScript} dontCenter="y" // Don't center it vertically, because the grid it's in is already doing that and we don't want to do it twice. @@ -593,6 +595,16 @@ export class CollectionCardView extends CollectionSubView() { } }); + focus = action((anchor: Doc, options: FocusViewOptions): Opt => { + const docs = DocListCast(this.Document[this.fieldKey ?? Doc.LayoutFieldKey(this.Document)]); + if (anchor.type !== DocumentType.CONFIG && !docs.includes(anchor)) return undefined; + options.didMove = true; + const target = DocCast(anchor.annotationOn) ?? anchor; + const index = docs.indexOf(target); + index !== -1 && (this._curDoc = target); + return undefined; + }); + /** * Actually renders all the cards */ diff --git a/src/client/views/nodes/ComparisonBox.scss b/src/client/views/nodes/ComparisonBox.scss index d1cc48051..d2ba9796b 100644 --- a/src/client/views/nodes/ComparisonBox.scss +++ b/src/client/views/nodes/ComparisonBox.scss @@ -236,6 +236,9 @@ } } } +.comparisonBox-interactive { + pointer-events: all; +} .comparisonBox-explain { position: absolute; diff --git a/src/client/views/nodes/ComparisonBox.tsx b/src/client/views/nodes/ComparisonBox.tsx index 3c126ea4a..f6c33d6ba 100644 --- a/src/client/views/nodes/ComparisonBox.tsx +++ b/src/client/views/nodes/ComparisonBox.tsx @@ -792,8 +792,9 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent() const renderMode = new Map JSX.Element>([ [flashcardRevealOp.FLIP, this.renderAsFlip], [flashcardRevealOp.SLIDE, this.renderAsBeforeAfter]]); // prettier-ignore - if (this.isQuizMode) this.renderAsQuiz(this.frontText); - return ( + return this.isQuizMode ? ( + this.renderAsQuiz(this.frontText) + ) : (
{renderMode.get(this.revealOp)?.() ?? null} {this.loading ? ( -- cgit v1.2.3-70-g09d2