From 4219c751c0f984fac6e5995c1ab955a8d63a28cd Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Sun, 11 May 2025 21:18:55 -0400 Subject: many changes to firefly UI (options added) and starting work on finalizing conditionals --- .../DocCreatorMenu/Backend/TemplateManager.ts | 14 +- .../DataVizBox/DocCreatorMenu/DocCreatorMenu.scss | 300 ++++++++++----------- .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 36 ++- .../DocCreatorMenu/Menu/TemplateEditingWindow.tsx | 160 +++++++---- .../DocCreatorMenu/Menu/TemplatePreviewBox.tsx | 32 +-- .../DocCreatorMenu/Menu/TemplatePreviewGrid.tsx | 10 +- .../nodes/DataVizBox/DocCreatorMenu/Template.ts | 23 +- src/client/views/smartdraw/DrawingFillHandler.tsx | 5 +- src/server/ApiManagers/FireflyManager.ts | 6 +- 9 files changed, 296 insertions(+), 290 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Backend/TemplateManager.ts b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Backend/TemplateManager.ts index d11f05766..030c6db95 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Backend/TemplateManager.ts +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Backend/TemplateManager.ts @@ -20,7 +20,7 @@ export class TemplateManager { templates: Template[] = []; - fieldConditions: Record = {}; + conditionalFieldLogic: Record = {}; constructor(templateSettings: FieldSettings[]) { makeAutoObservable(this); @@ -40,16 +40,16 @@ export class TemplateManager { }; addFieldCondition = (fieldTitle: string, condition: Conditional) => { - if (this.fieldConditions[fieldTitle] === undefined) { - this.fieldConditions[fieldTitle] = [condition]; + if (this.conditionalFieldLogic[fieldTitle] === undefined) { + this.conditionalFieldLogic[fieldTitle] = [condition]; } else { - this.fieldConditions[fieldTitle].push(condition); + this.conditionalFieldLogic[fieldTitle].push(condition); } } removeFieldCondition = (fieldTitle: string, condition: Conditional) => { - if (this.fieldConditions[fieldTitle]) { - this.fieldConditions[fieldTitle] = this.fieldConditions[fieldTitle].filter(cond => cond !== condition); + if (this.conditionalFieldLogic[fieldTitle]) { + this.conditionalFieldLogic[fieldTitle] = this.conditionalFieldLogic[fieldTitle].filter(cond => cond !== condition); } } @@ -84,6 +84,8 @@ export class TemplateManager { await applyGPTContent(); + templateCopy.applyConditionalLogic(this.conditionalFieldLogic); + return templateCopy.getRenderedDoc(); }; diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.scss b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.scss index 2a1a79029..8ac718fb7 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.scss +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.scss @@ -33,6 +33,7 @@ &:hover { box-shadow: none; + background-color: rgb(60, 60, 65); } &.no-margin { @@ -57,42 +58,6 @@ margin-left: 0px; font-size: 12px; } - - &.close-menu { - font-size: 12px; - width: 18px; - height: 18px; - font-size: 12px; - margin-left: auto; - margin-right: 5px; - margin-bottom: 3px; - } - - &.options { - margin-left: 0px; - } - - &:hover { - background-color: rgb(60, 60, 65); - } - - &.top-bar { - border-bottom: 25px solid #555; - border-left: 12px solid transparent; - border-right: 12px solid transparent; - // border-top-left-radius: 5px; - // border-top-right-radius: 5px; - border-radius: 0px; - height: 0; - width: 50px; - } - - &.preview-toggle { - margin: 0px; - border-top-left-radius: 0px; - border-bottom-left-radius: 0px; - border-left: 0px; - } } .docCreatorMenu-top-buttons-container { @@ -400,30 +365,6 @@ } -.docCreatorMenu-variation-prompt-input { - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - margin: 5px; - gap: 15px; - height: 30px; - width: 100%; -} - -.docCreatorMenu-variation-prompt-input-textbox { - height: 100%; - width: 80%; - color: white; - margin-top: 1%; - margin-bottom: 1%; - margin-left: 5%; - background-color: rgb(50, 50, 50); - border-radius: 5px; - overflow: hidden; - resize: none; -} - .docCreatorMenu-variations-tab { flex-grow: .5; } @@ -435,6 +376,7 @@ position: relative; flex-grow: 1; height: 100%; + width: 100%; margin: 0px; margin-top: 0px; margin-bottom: 0px; @@ -446,7 +388,7 @@ justify-content: center; align-items: center; position: absolute; - width: 100%; + width: calc(100% - 10px); bottom: 0px; margin: 0px; margin-bottom: 10px; @@ -457,11 +399,18 @@ .docCreatorMenu-templates-preview-window { display: grid; justify-content: space-evenly; + row-gap: 2rem; grid-template-columns: repeat(auto-fill, minmax(225px, 30%)); - gap: 1rem; margin: 5px; width: calc(100% - 10px); + height: 100%; padding-bottom: 40px; + + &.scrolling { + overflow-y: scroll; + max-height: 300px; + padding-bottom: 0px; + } } .divvv{ @@ -847,108 +796,6 @@ background-color: rgb(50, 50, 50); } -// .field-panel { -// position: relative; -// display: flex; -// // align-items: flex-start; -// flex-direction: column; -// gap: 5px; -// padding: 5px; -// height: 100px; -// //width: 100%; -// border: 1px solid rgb(180, 180, 180); -// margin: 5px; -// margin-top: 0px; -// border-radius: 3px; -// flex: 0 0 auto; - -// .properties-wrapper { -// display: flex; -// flex-direction: row; -// align-items: flex-start; -// gap: 5px; - -// .field-property-container { -// background-color: rgb(40, 40, 40); -// border: 1px solid rgb(100, 100, 100); -// border-radius: 3px; -// width: 30%; -// height: 25px; -// padding-left: 3px; -// align-items: center; -// color: whitesmoke; -// } - -// .field-type-selection-container { -// display: flex; -// flex-direction: row; -// align-items: center; -// background-color: rgb(40, 40, 40); -// border: 1px solid rgb(100, 100, 100); -// border-radius: 3px; -// width: 31%; -// height: 25px; -// padding-left: 3px; -// color: whitesmoke; - -// .placeholder { -// color: gray; -// } - -// &:hover .placeholder { -// display: none; -// } - -// .bubbles { -// display: none; -// } - -// .text { -// margin-top: 5px; -// margin-bottom: 5px; -// } - -// &:hover .bubbles { -// display: flex; -// flex-direction: row; -// align-items: flex-start; -// } - -// &:hover .type-display { -// display: none; -// } - -// .bubble { -// margin: 5px; -// } - -// &:hover .bubble { -// margin-top: 7px; -// } -// } -// } - -// .field-description-container { -// background-color: rgb(40, 40, 40); -// border: 1px solid rgb(100, 100, 100); -// border-radius: 3px; -// width: 100%; -// height: 100%; -// resize: none; - -// ::-webkit-scrollbar-track { -// background: none; -// } -// } - -// .top-right { -// position: absolute; -// top: 0px; -// right: 0px; -// } -// } -// } - .field-panel { display: flex; flex-direction: column; @@ -1214,4 +1061,127 @@ } } -} \ No newline at end of file +} + +//------------------------------------------------------------------------------------------------------------------------------------------ +// EditingWindow CSS +//-------------------------------------------------------------------------------------------------------------------------------------------- + +.docCreatorMenu-editing-firefly-section { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; + width: 100%; + padding: 5px; +} + +.docCreatorMenu-firefly-options { + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-end; + height: fit-content; + width: 100%; +} + +.docCreatorMenu-variation-prompt-row { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + gap: 15px; + height: fit-content; + width: 100%; +} + +.docCreatorMenu-variation-prompt-input-textbox { + height: 40px; + width: 80%; + color: white; + margin-top: 1%; + margin-bottom: 1%; + margin-left: 5%; + background-color: rgb(50, 50, 50); + border-radius: 5px; + overflow: hidden; + resize: none; +} + +.options‑menu { + display: flex; + align-items: center; + justify-content: center; + gap: 2rem; + padding: 0.5rem 1rem; + background: rgb(50, 50, 50); + color: whitesmoke; + font-family: system-ui, sans-serif; + font-size: 0.9rem; + flex-wrap: wrap; + } + + .menu‑item { + display: flex; + align-items: center; + gap: 0.5rem; + white-space: nowrap; + } + + .menu‑item input[type="range"] { + width: 7rem; + accent-color: whitesmoke; + } + + .value { + min-width: 2ch; + text-align: right; + } + + .switch { + gap: 0.75rem; + } + + .switch .slider { + position: relative; + width: 2.2rem; + height: 1.1rem; + background: whitesmoke; + border-radius: 1rem; + cursor: pointer; + transition: background 0.2s; + } + + .switch .slider::before { + content: ''; + position: absolute; + top: 0.1rem; + left: 0.1rem; + width: 0.9rem; + height: 0.9rem; + background: rgb(50, 50, 50); + border-radius: 50%; + transition: transform 0.2s; + } + + .switch input { + display: none; + } + + .switch input:checked + .slider { + background: #9fe29d; + } + + .switch input:checked + .slider::before { + transform: translateX(1.1rem); + } + +.firefly-option-label { + padding: .2em .6em .3em; + font-size: 100%; + color: whitesmoke; + text-align: center; +} + + diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index 2e4b81253..2565a9332 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -36,7 +36,7 @@ import { CgPathIntersect } from 'react-icons/cg'; import { StaticContentField } from './TemplateFieldTypes/StaticContentField'; import { TemplateMenuAIUtils } from './Backend/TemplateMenuAIUtils' import { TemplatePreviewGrid } from './Menu/TemplatePreviewGrid'; -import { TemplateEditingWindow } from './Menu/TemplateEditingWindow'; +import { FireflyStructureOptions, TemplateEditingWindow } from './Menu/TemplateEditingWindow'; import { DocCreatorMenuButton } from './Menu/DocCreatorMenuButton'; export enum LayoutType { @@ -103,7 +103,6 @@ export class DocCreatorMenu extends ObservableReactComponent @observable _userCreatedFields: Col[] = []; @observable _collapsedCols: String[] = []; //any columns whose options panels are hidden - @observable _conditions: Conditional[] = []; @observable _currEditingConditional: Conditional = {} as Conditional; @observable _layout: { type: LayoutType; yMargin: number; xMargin: number; columns?: number; repeat: number } = { type: LayoutType.FREEFORM, yMargin: 10, xMargin: 10, columns: 3, repeat: 0 }; @@ -594,7 +593,8 @@ export class DocCreatorMenu extends ObservableReactComponent ); }; - generateVariations = async (onDoc: Doc, prompt: string): Promise => { + generateVariations = async (onDoc: Doc, prompt: string, options: FireflyStructureOptions): Promise => { + const { numVariations, temperature, useStyleRef } = options; this.variations = []; const mainCollection = this._dataViz?.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView; @@ -603,12 +603,12 @@ export class DocCreatorMenu extends ObservableReactComponent clone.x = 10000; clone.y = 10000; - await DrawingFillHandler.drawingToImage(clone, 100, prompt, clone, this) + await DrawingFillHandler.drawingToImage(clone, 100 - temperature, prompt, useStyleRef ? clone : undefined, this, numVariations) return this.variations; } - @observable variations: string[] = [] + variations: string[] = [] @action addVariation = (url: string) => { this.variations.push(url); @@ -918,7 +918,7 @@ export class DocCreatorMenu extends ObservableReactComponent } get dashboardContents() { - const conditionForm = (title: string, parameters?: Conditional) => { + const conditionForm = (title: string, parameters?: Conditional, empty: boolean = false) => { const params: Conditional = parameters ?? this._currEditingConditional; @@ -942,8 +942,8 @@ export class DocCreatorMenu extends ObservableReactComponent
then
{params.target ?? 'self'} -
{params.target = 'self'}}>{'self'}
-
{params.target = 'template'}}>{'template'}
+
{params.target = 'self'}}>{'own'}
+
{params.target = 'template'}}>{`template's`}