@@ -105,6 +105,11 @@ const store = createStore({
105105 twoWayTable : false ,
106106 } ,
107107
108+ visualElements : {
109+ editExperimentButton : true ,
110+ biasTag : true ,
111+ } ,
112+
108113 running : {
109114 cancel : false ,
110115 auto : false ,
@@ -161,7 +166,7 @@ const runner = createRunner(store.getState().running, {
161166 onTick : ( ) => {
162167 const state = store . getState ( ) ;
163168 render ( els , state ) ;
164- applySectionVisibility ( state ) ;
169+ applyVisibility ( state ) ;
165170 activityLogger . maybeLogStatus ( state ) ;
166171 } ,
167172 onDone : updateControls ,
@@ -249,7 +254,7 @@ function resetSimulation({ reason = 'unknown', logSettings = false } = {}) {
249254 else resetSingleSimulation ( ) ;
250255
251256 render ( els , store . getState ( ) ) ;
252- applySectionVisibility ( store . getState ( ) ) ;
257+ applyVisibility ( store . getState ( ) ) ;
253258 syncUiFromState ( ) ;
254259
255260 const currentState = store . getState ( ) ;
@@ -313,6 +318,46 @@ function applySectionVisibility(state) {
313318 }
314319}
315320
321+ function applyVisualElementVisibility ( state ) {
322+ const visualElements = state . visualElements || { } ;
323+
324+ const showEditExperimentButton = visualElements . editExperimentButton !== false ;
325+ if ( els . openSettings ) {
326+ els . openSettings . style . display = showEditExperimentButton ? '' : 'none' ;
327+ els . openSettings . hidden = ! showEditExperimentButton ;
328+ }
329+
330+ const showBiasTag = visualElements . biasTag !== false ;
331+ if ( els . biasSummary ) {
332+ els . biasSummary . style . display = showBiasTag ? '' : 'none' ;
333+ els . biasSummary . hidden = ! showBiasTag ;
334+ }
335+
336+ const tagsContainer = els . biasSummary ?. parentElement || els . relationshipSummary ?. parentElement ;
337+ if ( tagsContainer ) {
338+ const biasVisible = Boolean (
339+ showBiasTag
340+ && els . biasSummary
341+ && ! els . biasSummary . hidden
342+ && els . biasSummary . style . display !== 'none' ,
343+ ) ;
344+ const relationshipVisible = Boolean (
345+ els . relationshipSummary
346+ && ! els . relationshipSummary . hidden
347+ && els . relationshipSummary . style . display !== 'none' ,
348+ ) ;
349+
350+ const anyVisible = biasVisible || relationshipVisible ;
351+ tagsContainer . style . display = anyVisible ? '' : 'none' ;
352+ tagsContainer . hidden = ! anyVisible ;
353+ }
354+ }
355+
356+ function applyVisibility ( state ) {
357+ applySectionVisibility ( state ) ;
358+ applyVisualElementVisibility ( state ) ;
359+ }
360+
316361function updateControls ( ) {
317362 const state = store . getState ( ) ;
318363 const autoRunning = state . running . auto ;
@@ -669,7 +714,7 @@ function renderEventOptions() {
669714 } ) ;
670715 const state = store . getState ( ) ;
671716 render ( els , state ) ;
672- applySectionVisibility ( state ) ;
717+ applyVisibility ( state ) ;
673718 activityLogger . logSettingsChange ( state ) ;
674719 } ) ;
675720
@@ -955,7 +1000,7 @@ function initEventListeners() {
9551000 } ) ;
9561001 const currentState = store . getState ( ) ;
9571002 render ( els , currentState ) ;
958- applySectionVisibility ( currentState ) ;
1003+ applyVisibility ( currentState ) ;
9591004 } ) ;
9601005
9611006 els . heatmap . addEventListener ( 'click' , ( event ) => {
@@ -984,13 +1029,13 @@ function initEventListeners() {
9841029 } ) ;
9851030 const updatedState = store . getState ( ) ;
9861031 render ( els , updatedState ) ;
987- applySectionVisibility ( updatedState ) ;
1032+ applyVisibility ( updatedState ) ;
9881033 } ) ;
9891034
9901035 window . addEventListener ( 'resize' , ( ) => {
9911036 const state = store . getState ( ) ;
9921037 render ( els , state ) ;
993- applySectionVisibility ( state ) ;
1038+ applyVisibility ( state ) ;
9941039 } ) ;
9951040}
9961041
@@ -1025,6 +1070,9 @@ async function init() {
10251070 if ( config . sections ) {
10261071 draft . sections = { ...draft . sections , ...config . sections } ;
10271072 }
1073+ if ( config . visualElements ) {
1074+ draft . visualElements = { ...draft . visualElements , ...config . visualElements } ;
1075+ }
10281076 draft . rng = createRngFromSeed ( draft . seedText ) ;
10291077 } ) ;
10301078 syncUiFromState ( ) ;
@@ -1066,12 +1114,13 @@ async function init() {
10661114
10671115 initEventListeners ( ) ;
10681116 updateControls ( ) ;
1069- applySectionVisibility ( store . getState ( ) ) ;
1117+ applyVisibility ( store . getState ( ) ) ;
10701118 activityLogger . logAppStart ( store . getState ( ) ) ;
10711119
10721120 // Defer initial render until after layout is complete
10731121 requestAnimationFrame ( ( ) => {
10741122 render ( els , store . getState ( ) ) ;
1123+ applyVisibility ( store . getState ( ) ) ;
10751124 } ) ;
10761125}
10771126
0 commit comments