Skip to content

Commit

Permalink
feat(components): remove headline from all visualization components
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove the `headline` attribute from all visualization components.
Instead, dashboard developers should simply create a headline themselves, outside the component,
using standard HTML/CSS.

closes #350
  • Loading branch information
fengelniederhammer committed Jul 17, 2024
1 parent 48ea46e commit 77bac6a
Show file tree
Hide file tree
Showing 65 changed files with 98 additions and 263 deletions.
2 changes: 0 additions & 2 deletions components/src/preact/aggregatedData/aggregate.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const meta: Meta<AggregateProps> = {
fields: [{ control: 'object' }],
width: { control: 'text' },
height: { control: 'text' },
headline: { control: 'text' },
initialSortField: { control: 'text' },
initialSortDirection: { control: 'radio', options: ['ascending', 'descending'] },
pageSize: { control: 'object' },
Expand Down Expand Up @@ -55,7 +54,6 @@ export const Default: StoryObj<AggregateProps> = {
},
width: '100%',
height: '700px',
headline: 'Aggregate',
initialSortField: 'count',
initialSortDirection: 'descending',
pageSize: 10,
Expand Down
15 changes: 3 additions & 12 deletions components/src/preact/aggregatedData/aggregate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { LapisUrlContext } from '../LapisUrlContext';
import { CsvDownloadButton } from '../components/csv-download-button';
import { ErrorBoundary } from '../components/error-boundary';
import { ErrorDisplay } from '../components/error-display';
import Headline from '../components/headline';
import Info from '../components/info';
import { LoadingDisplay } from '../components/loading-display';
import { NoDataDisplay } from '../components/no-data-display';
Expand All @@ -22,7 +21,6 @@ export type InitialSort = { field: string; direction: 'ascending' | 'descending'
export type AggregateProps = {
width: string;
height: string;
headline?: string;
} & AggregateInnerProps;

export interface AggregateInnerProps {
Expand All @@ -34,20 +32,13 @@ export interface AggregateInnerProps {
pageSize: boolean | number;
}

export const Aggregate: FunctionComponent<AggregateProps> = ({
width,
height,
headline = 'Mutations',
...innerProps
}) => {
export const Aggregate: FunctionComponent<AggregateProps> = ({ width, height, ...innerProps }) => {
const size = { height, width };

return (
<ErrorBoundary size={size} headline={headline}>
<ErrorBoundary size={size}>
<ResizeContainer size={size}>
<Headline heading={headline}>
<AggregateInner {...innerProps} />
</Headline>
<AggregateInner {...innerProps} />
</ResizeContainer>
</ErrorBoundary>
);
Expand Down
8 changes: 2 additions & 6 deletions components/src/preact/components/error-boundary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,37 @@ const meta: Meta = {
argTypes: {
size: { control: 'object' },
defaultSize: { control: 'object' },
headline: { control: 'text' },
},
args: {
size: { height: '600px', width: '100%' },
headline: 'Some headline',
},
};

export default meta;

export const ErrorBoundaryWithoutErrorStory: StoryObj = {
render: (args) => (
<ErrorBoundary size={args.size} headline={args.headline}>
<ErrorBoundary size={args.size}>
<div>Some content</div>
</ErrorBoundary>
),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const content = canvas.getByText('Some content', { exact: false });
await waitFor(() => expect(content).toBeInTheDocument());
await waitFor(() => expect(canvas.queryByText('Some headline')).not.toBeInTheDocument());
},
};

export const ErrorBoundaryWithErrorStory: StoryObj = {
render: (args) => (
<ErrorBoundary size={args.size} headline={args.headline}>
<ErrorBoundary size={args.size}>
<ContentThatThrowsError />
</ErrorBoundary>
),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const content = canvas.queryByText('Some content.', { exact: false });
await waitFor(() => expect(content).not.toBeInTheDocument());
await waitFor(() => expect(canvas.getByText('Some headline')).toBeInTheDocument());
await waitFor(() => expect(canvas.getByText('Error')).toBeInTheDocument());
},
};
Expand Down
7 changes: 2 additions & 5 deletions components/src/preact/components/error-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ import { useErrorBoundary } from 'preact/hooks';

import { ErrorDisplay } from './error-display';
import { ResizeContainer, type Size } from './resize-container';
import Headline from '../components/headline';

export const ErrorBoundary: FunctionComponent<{ size: Size; headline?: string }> = ({ size, headline, children }) => {
export const ErrorBoundary: FunctionComponent<{ size: Size }> = ({ size, children }) => {
const [internalError] = useErrorBoundary();

if (internalError) {
return (
<ResizeContainer size={size}>
<Headline heading={headline}>
<ErrorDisplay error={internalError} />
</Headline>
<ErrorDisplay error={internalError} />
</ResizeContainer>
);
}
Expand Down
47 changes: 0 additions & 47 deletions components/src/preact/components/headline.stories.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions components/src/preact/components/headline.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const meta: Meta<MutationComparisonProps> = {
},
width: { control: 'text' },
height: { control: 'text' },
headline: { control: 'text' },
pageSize: { control: 'object' },
},
parameters: {
Expand Down Expand Up @@ -85,7 +84,6 @@ const Template: StoryObj<MutationComparisonProps> = {
views={args.views}
width={args.width}
height={args.height}
headline={args.headline}
pageSize={args.pageSize}
/>
</ReferenceGenomeContext.Provider>
Expand Down Expand Up @@ -115,7 +113,6 @@ export const TwoVariants: StoryObj<MutationComparisonProps> = {
views: ['table', 'venn'],
width: '100%',
height: '700px',
headline: 'Mutation comparison',
pageSize: 10,
},
};
Expand Down
15 changes: 3 additions & 12 deletions components/src/preact/mutationComparison/mutation-comparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { type DisplayedSegment, SegmentSelector, useDisplayedSegments } from '..
import { CsvDownloadButton } from '../components/csv-download-button';
import { ErrorBoundary } from '../components/error-boundary';
import { ErrorDisplay } from '../components/error-display';
import Headline from '../components/headline';
import Info from '../components/info';
import { LoadingDisplay } from '../components/loading-display';
import { type DisplayedMutationType, MutationTypeSelector } from '../components/mutation-type-selector';
Expand All @@ -27,7 +26,6 @@ export type View = 'table' | 'venn';
export interface MutationComparisonProps extends MutationComparisonInnerProps {
width: string;
height: string;
headline?: string;
}

export interface MutationComparisonInnerProps {
Expand All @@ -37,20 +35,13 @@ export interface MutationComparisonInnerProps {
pageSize: boolean | number;
}

export const MutationComparison: FunctionComponent<MutationComparisonProps> = ({
width,
height,
headline = 'Mutation comparison',
...innerProps
}) => {
export const MutationComparison: FunctionComponent<MutationComparisonProps> = ({ width, height, ...innerProps }) => {
const size = { height, width };

return (
<ErrorBoundary size={size} headline={headline}>
<ErrorBoundary size={size}>
<ResizeContainer size={size}>
<Headline heading={headline}>
<MutationComparisonInner {...innerProps} />
</Headline>
<MutationComparisonInner {...innerProps} />
</ResizeContainer>
</ErrorBoundary>
);
Expand Down
3 changes: 0 additions & 3 deletions components/src/preact/mutations/mutations.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const meta: Meta<MutationsProps> = {
},
width: { control: 'text' },
height: { control: 'text' },
headline: { control: 'text' },
pageSize: { control: 'object' },
},
};
Expand All @@ -41,7 +40,6 @@ const Template = {
views={args.views}
width={args.width}
height={args.height}
headline={args.headline}
pageSize={args.pageSize}
/>
</ReferenceGenomeContext.Provider>
Expand All @@ -57,7 +55,6 @@ export const Default: StoryObj<MutationsProps> = {
views: ['grid', 'table', 'insertions'],
width: '100%',
height: '700px',
headline: 'Mutations',
pageSize: 10,
},
parameters: {
Expand Down
15 changes: 3 additions & 12 deletions components/src/preact/mutations/mutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { type DisplayedSegment, SegmentSelector, useDisplayedSegments } from '..
import { CsvDownloadButton } from '../components/csv-download-button';
import { ErrorBoundary } from '../components/error-boundary';
import { ErrorDisplay } from '../components/error-display';
import Headline from '../components/headline';
import Info from '../components/info';
import { LoadingDisplay } from '../components/loading-display';
import { type DisplayedMutationType, MutationTypeSelector } from '../components/mutation-type-selector';
Expand All @@ -41,23 +40,15 @@ export interface MutationsInnerProps {
export interface MutationsProps extends MutationsInnerProps {
width: string;
height: string;
headline?: string;
}

export const Mutations: FunctionComponent<MutationsProps> = ({
width,
height,
headline = 'Mutations',
...innerProps
}) => {
export const Mutations: FunctionComponent<MutationsProps> = ({ width, height, ...innerProps }) => {
const size = { height, width };

return (
<ErrorBoundary size={size} headline={headline}>
<ErrorBoundary size={size}>
<ResizeContainer size={size}>
<Headline heading={headline}>
<MutationsInner {...innerProps} />
</Headline>
<MutationsInner {...innerProps} />
</ResizeContainer>
</ErrorBoundary>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const Template: StoryObj<NumberSequencesOverTimeProps> = {
views={args.views}
width={args.width}
height={args.height}
headline={args.headline}
granularity={args.granularity}
smoothingWindow={args.smoothingWindow}
pageSize={args.pageSize}
Expand All @@ -50,7 +49,6 @@ const Template: StoryObj<NumberSequencesOverTimeProps> = {
lapisDateField: 'date',
width: '100%',
height: '700px',
headline: 'Number of sequences over time',
smoothingWindow: 0,
granularity: 'month',
pageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { LapisUrlContext } from '../LapisUrlContext';
import { CsvDownloadButton } from '../components/csv-download-button';
import { ErrorBoundary } from '../components/error-boundary';
import { ErrorDisplay } from '../components/error-display';
import Headline from '../components/headline';
import Info, { InfoHeadline1, InfoParagraph } from '../components/info';
import { LoadingDisplay } from '../components/loading-display';
import { NoDataDisplay } from '../components/no-data-display';
Expand All @@ -28,7 +27,6 @@ type NumberSequencesOverTimeView = 'bar' | 'line' | 'table';
export interface NumberSequencesOverTimeProps extends NumberSequencesOverTimeInnerProps {
width: string;
height: string;
headline: string;
}

interface NumberSequencesOverTimeInnerProps {
Expand All @@ -40,15 +38,13 @@ interface NumberSequencesOverTimeInnerProps {
pageSize: boolean | number;
}

export const NumberSequencesOverTime = ({ width, height, headline, ...innerProps }: NumberSequencesOverTimeProps) => {
export const NumberSequencesOverTime = ({ width, height, ...innerProps }: NumberSequencesOverTimeProps) => {
const size = { height, width };

return (
<ErrorBoundary size={size} headline={headline}>
<ErrorBoundary size={size}>
<ResizeContainer size={size}>
<Headline heading={headline}>
<NumberSequencesOverTimeInner {...innerProps} />
</Headline>
<NumberSequencesOverTimeInner {...innerProps} />
</ResizeContainer>
</ErrorBoundary>
);
Expand Down
Loading

0 comments on commit 77bac6a

Please sign in to comment.