Skip to content

Commit

Permalink
WIP collapse button for floating viz controls
Browse files Browse the repository at this point in the history
  • Loading branch information
chowington committed Oct 4, 2023
1 parent 7ab5540 commit 3637a62
Show file tree
Hide file tree
Showing 15 changed files with 364 additions and 260 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CSSProperties } from 'react';
import { FilledButton } from '@veupathdb/coreui';
import { CSSProperties, useState } from 'react';
import { FloatingDiv } from '../../../map/analysis/FloatingDiv';
import { RequiredInputsPrompt } from './RequiredInputPrompts';

Expand All @@ -7,6 +8,7 @@ import { LayoutProps } from './types';
export interface Props extends LayoutProps {
showRequiredInputsPrompt?: boolean;
isMosaicPlot?: boolean;
hideControls?: boolean;
}

const defaultContainerStyles: CSSProperties = {
Expand All @@ -27,15 +29,18 @@ export function FloatingLayout({
plotStyles,
showRequiredInputsPrompt,
isMosaicPlot,
hideControls,
}: Props) {
return (
<div style={{ ...defaultContainerStyles, ...containerStyles }}>
<div style={{ ...defaultPlotStyles, ...plotStyles }}>
{showRequiredInputsPrompt && (
<RequiredInputsPrompt isMosaicPlot={isMosaicPlot} />
)}
{plotNode}
{controlsNode}
<div>
{showRequiredInputsPrompt && (
<RequiredInputsPrompt isMosaicPlot={isMosaicPlot} />
)}
{plotNode}
{!hideControls && controlsNode}
</div>
</div>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions packages/libs/eda/src/lib/core/components/layouts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export interface LayoutProps {
containerStyles?: CSSProperties;
legendNode?: ReactNode;
legendStyles?: CSSProperties;
// inputVariablesNode?: ReactNode;
plotNode: ReactNode;
controlsNode?: ReactNode;
plotStyles?: CSSProperties;
tableGroupNode: ReactNode;
tableGroupStyles?: CSSProperties;
hideControls?: boolean;
}

export type StyleProps<P> = Pick<P, keyof P & `${string}Styles`>;
Expand All @@ -19,6 +21,7 @@ export interface LayoutOptions {
hideFacetInputs?: boolean;
// considering marginal histogram
showMarginalHistogram?: boolean;
// hideInputsAndControls?: boolean;
}

export interface TitleOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface VisualizationProps<Options = undefined> {
geoConfigs: GeoConfig[];
otherVizOverviews: VisualizationOverview[];
computeJobStatus?: JobStatus;
hideInputsAndControls?: boolean;
plotContainerStyles?: React.CSSProperties;
}

export interface IsEnabledInPickerParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ interface Props {
createComputeJob?: () => void;
/** optional dynamic plugins */
plugins?: Partial<Record<string, ComputationPlugin>>;
hideInputsAndControls?: boolean;
}

/**
Expand Down Expand Up @@ -449,7 +450,8 @@ type FullScreenVisualizationPropKeys =
| 'disableThumbnailCreation'
| 'computeJobStatus'
| 'createComputeJob'
| 'plugins';
| 'plugins'
| 'hideInputsAndControls';

interface FullScreenVisualizationProps
extends Pick<Props, FullScreenVisualizationPropKeys> {
Expand Down Expand Up @@ -479,6 +481,7 @@ export function FullScreenVisualization(props: FullScreenVisualizationProps) {
computeJobStatus,
createComputeJob,
plugins = staticPlugins,
hideInputsAndControls,
} = props;
const themePrimaryColor = useUITheme()?.palette.primary;
const history = useHistory();
Expand Down Expand Up @@ -643,20 +646,24 @@ export function FullScreenVisualization(props: FullScreenVisualizationProps) {
</ContentError>
) : (
<div>
<h3>
<SaveableTextEditor
value={viz.displayName ?? 'unnamed visualization'}
onSave={(value) => {
if (value)
analysisState.updateVisualization({
...viz,
displayName: value,
});
}}
/>
</h3>
<div className="Subtitle">{overview?.displayName}</div>
{plugin && analysisState.analysis && (
{!hideInputsAndControls && (
<>
<h3>
<SaveableTextEditor
value={viz.displayName ?? 'unnamed visualization'}
onSave={(value) => {
if (value)
analysisState.updateVisualization({
...viz,
displayName: value,
});
}}
/>
</h3>
<div className="Subtitle">{overview?.displayName}</div>
</>
)}
{!hideInputsAndControls && plugin && analysisState.analysis && (
<div
style={{
display: 'flex',
Expand Down Expand Up @@ -719,6 +726,7 @@ export function FullScreenVisualization(props: FullScreenVisualizationProps) {
geoConfigs={geoConfigs}
otherVizOverviews={overviews.others}
computeJobStatus={computeJobStatus}
hideInputsAndControls={hideInputsAndControls}
/>
</div>
</ComputationStepContainer>
Expand All @@ -741,6 +749,7 @@ export function FullScreenVisualization(props: FullScreenVisualizationProps) {
geoConfigs={geoConfigs}
otherVizOverviews={overviews.others}
computeJobStatus={computeJobStatus}
hideInputsAndControls={hideInputsAndControls}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export type BarplotDataWithStatistics = (
) &
CoverageStatistics;

// Do we want to pull this out and pass it in as a prop?
// If so, it will be harder to make sure we honor it as part of the API
const plotContainerStyles = {
height: 450,
width: 750,
Expand Down Expand Up @@ -191,6 +193,7 @@ function BarplotViz(props: VisualizationProps<Options>) {
toggleStarredVariable,
totalCounts,
filteredCounts,
hideInputsAndControls,
} = props;
const studyMetadata = useStudyMetadata();
const { id: studyId } = studyMetadata;
Expand Down Expand Up @@ -892,40 +895,45 @@ function BarplotViz(props: VisualizationProps<Options>) {
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', alignItems: 'center', zIndex: 1 }}>
<InputVariables
inputs={inputs}
entities={entities}
selectedVariables={selectedVariables}
onChange={handleInputVariableChange}
constraints={dataElementConstraints}
dataElementDependencyOrder={dataElementDependencyOrder}
starredVariables={starredVariables}
enableShowMissingnessToggle={
(overlayVariable != null || facetVariable != null) &&
data.value?.completeCasesAllVars !==
data.value?.completeCasesAxesVars
}
toggleStarredVariable={toggleStarredVariable}
// this can be used to show and hide no data control
onShowMissingnessChange={
computation.descriptor.type === 'pass'
? onShowMissingnessChange
: undefined
}
showMissingness={vizConfig.showMissingness}
outputEntity={outputEntity}
/>
{!hideInputsAndControls && (
<InputVariables
inputs={inputs}
entities={entities}
selectedVariables={selectedVariables}
onChange={handleInputVariableChange}
constraints={dataElementConstraints}
dataElementDependencyOrder={dataElementDependencyOrder}
starredVariables={starredVariables}
enableShowMissingnessToggle={
(overlayVariable != null || facetVariable != null) &&
data.value?.completeCasesAllVars !==
data.value?.completeCasesAxesVars
}
toggleStarredVariable={toggleStarredVariable}
// this can be used to show and hide no data control
onShowMissingnessChange={
computation.descriptor.type === 'pass'
? onShowMissingnessChange
: undefined
}
showMissingness={vizConfig.showMissingness}
outputEntity={outputEntity}
/>
)}
</div>

<PluginError error={data.error} outputSize={outputSize} />
<OutputEntityTitle entity={outputEntity} outputSize={outputSize} />
{!hideInputsAndControls && (
<OutputEntityTitle entity={outputEntity} outputSize={outputSize} />
)}
<LayoutComponent
isFaceted={isFaceted(data.value)}
plotNode={plotNode}
controlsNode={controlsNode}
legendNode={showOverlayLegend ? legendNode : null}
tableGroupNode={tableGroupNode}
showRequiredInputsPrompt={!areRequiredInputsSelected}
hideControls={hideInputsAndControls}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function BoxplotViz(props: VisualizationProps<Options>) {
totalCounts,
filteredCounts,
computeJobStatus,
hideInputsAndControls,
} = props;
const studyMetadata = useStudyMetadata();
const { id: studyId } = studyMetadata;
Expand Down Expand Up @@ -871,45 +872,50 @@ function BoxplotViz(props: VisualizationProps<Options>) {
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', alignItems: 'center', zIndex: 1 }}>
<InputVariables
inputs={finalizedInputs}
entities={entities}
selectedVariables={selectedVariables}
variablesForConstraints={variablesForConstraints}
onChange={handleInputVariableChange}
constraints={dataElementConstraints}
dataElementDependencyOrder={dataElementDependencyOrder}
starredVariables={starredVariables}
toggleStarredVariable={toggleStarredVariable}
enableShowMissingnessToggle={
(overlayVariable != null || facetVariable != null) &&
data.value?.completeCasesAllVars !==
data.value?.completeCasesAxesVars
}
showMissingness={vizConfig.showMissingness}
// this can be used to show and hide no data control
onShowMissingnessChange={
options?.hideShowMissingnessToggle
? undefined
: onShowMissingnessChange
}
outputEntity={outputEntity}
/>
{!hideInputsAndControls && (
<InputVariables
inputs={finalizedInputs}
entities={entities}
selectedVariables={selectedVariables}
variablesForConstraints={variablesForConstraints}
onChange={handleInputVariableChange}
constraints={dataElementConstraints}
dataElementDependencyOrder={dataElementDependencyOrder}
starredVariables={starredVariables}
toggleStarredVariable={toggleStarredVariable}
enableShowMissingnessToggle={
(overlayVariable != null || facetVariable != null) &&
data.value?.completeCasesAllVars !==
data.value?.completeCasesAxesVars
}
showMissingness={vizConfig.showMissingness}
// this can be used to show and hide no data control
onShowMissingnessChange={
options?.hideShowMissingnessToggle
? undefined
: onShowMissingnessChange
}
outputEntity={outputEntity}
/>
)}
</div>

<PluginError error={data.error} outputSize={outputSize} />
<OutputEntityTitle
entity={outputEntity}
outputSize={outputSize}
subtitle={plotSubtitle}
/>
{!hideInputsAndControls && (
<OutputEntityTitle
entity={outputEntity}
outputSize={outputSize}
subtitle={plotSubtitle}
/>
)}
<LayoutComponent
isFaceted={isFaceted(data.value)}
legendNode={showOverlayLegend ? legendNode : null}
plotNode={plotNode}
controlsNode={controlsNode}
tableGroupNode={tableGroupNode}
showRequiredInputsPrompt={!areRequiredInputsSelected}
hideControls={hideInputsAndControls}
/>
</div>
);
Expand Down
Loading

0 comments on commit 3637a62

Please sign in to comment.