From 678abdfceaa25cb84c4232f44a7c161b6d39b546 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 1 Dec 2023 12:17:10 -0500
Subject: cleaning up documentview props.   got rid of special cases for
 keyValueBox.  made fitToContents work cleanly for native scaled docs.

---
 .../views/collections/CollectionCarouselView.tsx   | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)

(limited to 'src/client/views/collections/CollectionCarouselView.tsx')

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>
+                )}
             </>
         );
     }
-- 
cgit v1.2.3-70-g09d2

