aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionCarouselView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-01 12:17:10 -0500
committerbobzel <zzzman@gmail.com>2023-12-01 12:17:10 -0500
commit678abdfceaa25cb84c4232f44a7c161b6d39b546 (patch)
tree3ee85b4796619d06949daa964556d19ed0a98830 /src/client/views/collections/CollectionCarouselView.tsx
parent9ae07e29f41df9d64985c25b67054843a99a0224 (diff)
cleaning up documentview props. got rid of special cases for keyValueBox. made fitToContents work cleanly for native scaled docs.
Diffstat (limited to 'src/client/views/collections/CollectionCarouselView.tsx')
-rw-r--r--src/client/views/collections/CollectionCarouselView.tsx36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx
index c873ef891..299a4d5d3 100644
--- a/src/client/views/collections/CollectionCarouselView.tsx
+++ b/src/client/views/collections/CollectionCarouselView.tsx
@@ -4,7 +4,7 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { StopEvent, emptyFunction, returnFalse, returnOne, returnZero } from '../../../Utils';
import { Doc, Opt } from '../../../fields/Doc';
-import { NumCast, ScriptCast, StrCast } from '../../../fields/Types';
+import { DocCast, NumCast, ScriptCast, StrCast } from '../../../fields/Types';
import { DragManager } from '../../util/DragManager';
import { StyleProp } from '../StyleProvider';
import { DocumentView, DocumentViewProps } from '../nodes/DocumentView';
@@ -51,7 +51,7 @@ export class CollectionCarouselView extends CollectionSubView() {
const index = NumCast(this.layoutDoc._carousel_index);
const curDoc = this.childLayoutPairs?.[index];
const captionProps = { ...this.props, NativeScaling: returnOne, PanelWidth: this.captionWidth, fieldKey: 'caption', setHeight: undefined, setContentView: undefined };
- const show_captions = StrCast(this.layoutDoc._layout_showCaption);
+ const carouselShowsCaptions = StrCast(this.layoutDoc._layout_showCaption);
return !(curDoc?.layout instanceof Doc) ? null : (
<>
<div className="collectionCarouselView-image" key="image">
@@ -59,36 +59,36 @@ export class CollectionCarouselView extends CollectionSubView() {
{...this.props}
NativeWidth={returnZero}
NativeHeight={returnZero}
- shouldNotScale={undefined}
layout_fitWidth={undefined}
setContentView={undefined}
onDoubleClick={this.onContentDoubleClick}
onClick={this.onContentClick}
isDocumentActive={this.props.childDocumentsActive?.() ? this.props.isDocumentActive : this.props.isContentActive}
isContentActive={this.props.childContentsActive ?? this.props.isContentActive() === false ? returnFalse : emptyFunction}
- hideCaptions={show_captions ? true : false}
+ hideCaptions={!!carouselShowsCaptions} // hide captions if the carousel is configured to show the captions
renderDepth={this.props.renderDepth + 1}
LayoutTemplate={this.props.childLayoutTemplate}
LayoutTemplateString={this.props.childLayoutString}
Document={curDoc.layout}
- TemplateDataDocument={curDoc.layout.resolvedDataDoc as Doc}
+ TemplateDataDocument={DocCast(curDoc.layout.resolvedDataDoc)}
PanelHeight={this.panelHeight}
bringToFront={returnFalse}
/>
</div>
- <div
- className="collectionCarouselView-caption"
- key="caption"
- onWheel={StopEvent}
- style={{
- display: show_captions ? undefined : 'none',
- borderRadius: this.props.styleProvider?.(this.layoutDoc, captionProps, StyleProp.BorderRounding),
- marginRight: this.marginX,
- marginLeft: this.marginX,
- width: `calc(100% - ${this.marginX * 2}px)`,
- }}>
- <FormattedTextBox key={index} {...captionProps} fieldKey={show_captions} styleProvider={this.captionStyleProvider} Document={curDoc.layout} TemplateDataDocument={undefined} />
- </div>
+ {!carouselShowsCaptions ? null : (
+ <div
+ className="collectionCarouselView-caption"
+ key="caption"
+ onWheel={StopEvent}
+ style={{
+ borderRadius: this.props.styleProvider?.(this.layoutDoc, captionProps, StyleProp.BorderRounding),
+ marginRight: this.marginX,
+ marginLeft: this.marginX,
+ width: `calc(100% - ${this.marginX * 2}px)`,
+ }}>
+ <FormattedTextBox key={index} {...captionProps} fieldKey={carouselShowsCaptions} styleProvider={this.captionStyleProvider} Document={curDoc.layout} TemplateDataDocument={undefined} />
+ </div>
+ )}
</>
);
}