@genspectrum/dashboard-components 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/custom-elements.json +328 -177
  2. package/dist/dashboard-components.js +376 -129
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/genspectrum-components.d.ts +156 -110
  5. package/dist/style.css +179 -33
  6. package/package.json +1 -2
  7. package/src/constants.ts +1 -1
  8. package/src/lapisApi/lapisApi.ts +46 -2
  9. package/src/lapisApi/lapisTypes.ts +14 -0
  10. package/src/preact/aggregatedData/aggregate.stories.tsx +4 -2
  11. package/src/preact/aggregatedData/aggregate.tsx +8 -6
  12. package/src/preact/components/error-boundary.stories.tsx +6 -14
  13. package/src/preact/components/error-boundary.tsx +2 -11
  14. package/src/preact/components/error-display.stories.tsx +12 -5
  15. package/src/preact/components/error-display.tsx +37 -3
  16. package/src/preact/components/loading-display.stories.tsx +1 -1
  17. package/src/preact/components/resize-container.tsx +5 -14
  18. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +2 -0
  19. package/src/preact/dateRangeSelector/date-range-selector.tsx +11 -8
  20. package/src/preact/locationFilter/fetchAutocompletionList.ts +15 -1
  21. package/src/preact/locationFilter/location-filter.tsx +4 -5
  22. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +6 -3
  23. package/src/preact/mutationComparison/mutation-comparison.tsx +10 -13
  24. package/src/preact/mutationComparison/queryMutationData.ts +2 -3
  25. package/src/preact/mutationFilter/mutation-filter.stories.tsx +8 -8
  26. package/src/preact/mutationFilter/mutation-filter.tsx +7 -6
  27. package/src/preact/mutations/mutations.stories.tsx +6 -3
  28. package/src/preact/mutations/mutations.tsx +8 -6
  29. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +14 -7
  30. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +10 -8
  31. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +6 -3
  32. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +9 -7
  33. package/src/preact/textInput/text-input.stories.tsx +26 -0
  34. package/src/preact/textInput/text-input.tsx +4 -5
  35. package/src/query/queryPrevalenceOverTime.ts +4 -10
  36. package/src/types.ts +4 -1
  37. package/src/web-components/ResizeContainer.mdx +13 -0
  38. package/src/web-components/app.ts +3 -1
  39. package/src/web-components/input/gs-date-range-selector.stories.ts +10 -2
  40. package/src/web-components/input/gs-date-range-selector.tsx +26 -16
  41. package/src/web-components/input/gs-location-filter.stories.ts +5 -3
  42. package/src/web-components/input/gs-location-filter.tsx +5 -6
  43. package/src/web-components/input/gs-mutation-filter.stories.ts +11 -8
  44. package/src/web-components/input/gs-mutation-filter.tsx +38 -26
  45. package/src/web-components/input/gs-text-input.stories.ts +3 -3
  46. package/src/web-components/input/gs-text-input.tsx +10 -10
  47. package/src/web-components/input/introduction.mdx +11 -0
  48. package/src/web-components/introduction.mdx +15 -0
  49. package/src/web-components/visualization/gs-aggregate.stories.ts +19 -6
  50. package/src/web-components/visualization/gs-aggregate.tsx +31 -15
  51. package/src/web-components/visualization/gs-mutation-comparison.stories.ts +13 -7
  52. package/src/web-components/visualization/gs-mutation-comparison.tsx +26 -17
  53. package/src/web-components/visualization/gs-mutations.stories.ts +14 -8
  54. package/src/web-components/visualization/gs-mutations.tsx +18 -8
  55. package/src/web-components/visualization/gs-prevalence-over-time.stories.ts +28 -18
  56. package/src/web-components/visualization/gs-prevalence-over-time.tsx +45 -22
  57. package/src/web-components/visualization/gs-relative-growth-advantage.stories.ts +11 -5
  58. package/src/web-components/visualization/gs-relative-growth-advantage.tsx +21 -9
@@ -11,13 +11,14 @@ import type { ScaleType } from '../shared/charts/getYAxisScale';
11
11
  export type CustomSelectOption<CustomLabel extends string> = { label: CustomLabel; dateFrom: string; dateTo: string };
12
12
 
13
13
  export interface DateRangeSelectorProps<CustomLabel extends string> extends DateRangeSelectorPropsInner<CustomLabel> {
14
- width?: string;
14
+ width: string;
15
15
  }
16
16
 
17
17
  export interface DateRangeSelectorPropsInner<CustomLabel extends string> {
18
18
  customSelectOptions: CustomSelectOption<CustomLabel>[];
19
19
  earliestDate?: string;
20
20
  initialValue?: PresetOptionValues | CustomLabel;
21
+ dateColumn: string;
21
22
  }
22
23
 
23
24
  export const PRESET_VALUE_CUSTOM = 'custom';
@@ -45,17 +46,18 @@ export const DateRangeSelector = <CustomLabel extends string>({
45
46
  earliestDate = '1900-01-01',
46
47
  initialValue,
47
48
  width,
49
+ dateColumn,
48
50
  }: DateRangeSelectorProps<CustomLabel>) => {
49
- const defaultSize = { width: '100%', height: '3rem' };
50
- const size = width === undefined ? undefined : { width, height: defaultSize.height };
51
+ const size = { width, height: '3rem' };
51
52
 
52
53
  return (
53
- <ErrorBoundary defaultSize={defaultSize} size={size}>
54
- <ResizeContainer defaultSize={defaultSize} size={size}>
54
+ <ErrorBoundary size={size}>
55
+ <ResizeContainer size={size}>
55
56
  <DateRangeSelectorInner
56
57
  customSelectOptions={customSelectOptions}
57
58
  earliestDate={earliestDate}
58
59
  initialValue={initialValue}
60
+ dateColumn={dateColumn}
59
61
  />
60
62
  </ResizeContainer>
61
63
  </ErrorBoundary>
@@ -66,7 +68,8 @@ export const DateRangeSelectorInner = <CustomLabel extends string>({
66
68
  customSelectOptions,
67
69
  earliestDate = '1900-01-01',
68
70
  initialValue,
69
- }: DateRangeSelectorProps<CustomLabel>) => {
71
+ dateColumn,
72
+ }: DateRangeSelectorPropsInner<CustomLabel>) => {
70
73
  const fromDatePickerRef = useRef<HTMLInputElement>(null);
71
74
  const toDatePickerRef = useRef<HTMLInputElement>(null);
72
75
  const divRef = useRef<HTMLDivElement>(null);
@@ -165,8 +168,8 @@ export const DateRangeSelectorInner = <CustomLabel extends string>({
165
168
  const dateTo = toYYYYMMDD(dateToPicker?.selectedDates[0]);
166
169
 
167
170
  const detail = {
168
- ...(dateFrom !== undefined && { dateFrom }),
169
- ...(dateTo !== undefined && { dateTo }),
171
+ ...(dateFrom !== undefined && { [`${dateColumn}From`]: dateFrom }),
172
+ ...(dateTo !== undefined && { [`${dateColumn}To`]: dateTo }),
170
173
  };
171
174
 
172
175
  divRef.current?.dispatchEvent(
@@ -1,4 +1,6 @@
1
+ import { LapisError } from '../../lapisApi/lapisApi';
1
2
  import { FetchAggregatedOperator } from '../../operator/FetchAggregatedOperator';
3
+ import { UserFacingError } from '../components/error-display';
2
4
 
3
5
  export async function fetchAutocompletionList(fields: string[], lapis: string, signal?: AbortSignal) {
4
6
  const toAncestorInHierarchyOverwriteValues = Array(fields.length - 1)
@@ -8,7 +10,19 @@ export async function fetchAutocompletionList(fields: string[], lapis: string, s
8
10
 
9
11
  const fetchAggregatedOperator = new FetchAggregatedOperator<Record<string, string | null>>({}, fields);
10
12
 
11
- const data = (await fetchAggregatedOperator.evaluate(lapis, signal)).content;
13
+ let data;
14
+ try {
15
+ data = (await fetchAggregatedOperator.evaluate(lapis, signal)).content;
16
+ } catch (error) {
17
+ if (error instanceof LapisError) {
18
+ throw new UserFacingError(
19
+ `Failed to fetch autocomplete list from LAPIS: ${error.problemDetail.status} ${error.problemDetail.title ?? ''}`,
20
+ error.problemDetail.detail ?? error.message,
21
+ );
22
+ }
23
+ throw error;
24
+ }
25
+
12
26
  const locationValues = data
13
27
  .map((entry) => fields.reduce((acc, field) => ({ ...acc, [field]: entry[field] }), {}))
14
28
  .reduce<Set<string>>((setOfAllHierarchies, entry) => {
@@ -15,16 +15,15 @@ export interface LocationFilterInnerProps {
15
15
  }
16
16
 
17
17
  export interface LocationFilterProps extends LocationFilterInnerProps {
18
- width?: string;
18
+ width: string;
19
19
  }
20
20
 
21
21
  export const LocationFilter: FunctionComponent<LocationFilterProps> = ({ width, initialValue, fields }) => {
22
- const defaultSize = { width: '100%', height: '3rem' };
23
- const size = width === undefined ? undefined : { width, height: defaultSize.height };
22
+ const size = { width, height: '3rem' };
24
23
 
25
24
  return (
26
- <ErrorBoundary defaultSize={defaultSize} size={size}>
27
- <ResizeContainer size={size} defaultSize={defaultSize}>
25
+ <ErrorBoundary size={size}>
26
+ <ResizeContainer size={size}>
28
27
  <LocationFilterInner initialValue={initialValue} fields={fields} />
29
28
  </ResizeContainer>
30
29
  </ErrorBoundary>
@@ -27,7 +27,8 @@ const meta: Meta<MutationComparisonProps> = {
27
27
  options: ['table', 'venn'],
28
28
  control: { type: 'check' },
29
29
  },
30
- size: [{ control: 'object' }],
30
+ width: { control: 'text' },
31
+ height: { control: 'text' },
31
32
  headline: { control: 'text' },
32
33
  },
33
34
  parameters: {
@@ -81,7 +82,8 @@ const Template: StoryObj<MutationComparisonProps> = {
81
82
  variants={args.variants}
82
83
  sequenceType={args.sequenceType}
83
84
  views={args.views}
84
- size={args.size}
85
+ width={args.width}
86
+ height={args.height}
85
87
  headline={args.headline}
86
88
  />
87
89
  </ReferenceGenomeContext.Provider>
@@ -109,7 +111,8 @@ export const TwoVariants: StoryObj<MutationComparisonProps> = {
109
111
  ],
110
112
  sequenceType: 'nucleotide',
111
113
  views: ['table', 'venn'],
112
- size: { width: '100%', height: '700px' },
114
+ width: '100%',
115
+ height: '700px',
113
116
  headline: 'Mutation comparison',
114
117
  },
115
118
  };
@@ -5,7 +5,7 @@ import { getMutationComparisonTableData } from './getMutationComparisonTableData
5
5
  import { MutationComparisonTable } from './mutation-comparison-table';
6
6
  import { MutationComparisonVenn } from './mutation-comparison-venn';
7
7
  import { filterMutationData, type MutationData, queryMutationData } from './queryMutationData';
8
- import { type LapisFilter, type SequenceType } from '../../types';
8
+ import { type NamedLapisFilter, type SequenceType } from '../../types';
9
9
  import { LapisUrlContext } from '../LapisUrlContext';
10
10
  import { type DisplayedSegment, SegmentSelector, useDisplayedSegments } from '../components/SegmentSelector';
11
11
  import { CsvDownloadButton } from '../components/csv-download-button';
@@ -18,24 +18,20 @@ import { type DisplayedMutationType, MutationTypeSelector } from '../components/
18
18
  import { NoDataDisplay } from '../components/no-data-display';
19
19
  import { type ProportionInterval } from '../components/proportion-selector';
20
20
  import { ProportionSelectorDropdown } from '../components/proportion-selector-dropdown';
21
- import { ResizeContainer, type Size } from '../components/resize-container';
21
+ import { ResizeContainer } from '../components/resize-container';
22
22
  import Tabs from '../components/tabs';
23
23
  import { useQuery } from '../useQuery';
24
24
 
25
25
  export type View = 'table' | 'venn';
26
26
 
27
- export interface MutationComparisonVariant {
28
- lapisFilter: LapisFilter;
29
- displayName: string;
30
- }
31
-
32
27
  export interface MutationComparisonProps extends MutationComparisonInnerProps {
33
- size?: Size;
28
+ width: string;
29
+ height: string;
34
30
  headline?: string;
35
31
  }
36
32
 
37
33
  export interface MutationComparisonInnerProps {
38
- variants: MutationComparisonVariant[];
34
+ variants: NamedLapisFilter[];
39
35
  sequenceType: SequenceType;
40
36
  views: View[];
41
37
  }
@@ -44,14 +40,15 @@ export const MutationComparison: FunctionComponent<MutationComparisonProps> = ({
44
40
  variants,
45
41
  sequenceType,
46
42
  views,
47
- size,
43
+ width,
44
+ height,
48
45
  headline = 'Mutation comparison',
49
46
  }) => {
50
- const defaultSize = { height: '600px', width: '100%' };
47
+ const size = { height, width };
51
48
 
52
49
  return (
53
- <ErrorBoundary size={size} defaultSize={defaultSize} headline={headline}>
54
- <ResizeContainer size={size} defaultSize={defaultSize}>
50
+ <ErrorBoundary size={size} headline={headline}>
51
+ <ResizeContainer size={size}>
55
52
  <Headline heading={headline}>
56
53
  <MutationComparisonInner variants={variants} sequenceType={sequenceType} views={views} />
57
54
  </Headline>
@@ -1,6 +1,5 @@
1
- import { type MutationComparisonVariant } from './mutation-comparison';
2
1
  import { querySubstitutionsOrDeletions } from '../../query/querySubstitutionsOrDeletions';
3
- import { type SubstitutionOrDeletionEntry } from '../../types';
2
+ import { type NamedLapisFilter, type SubstitutionOrDeletionEntry } from '../../types';
4
3
  import { type DisplayedSegment } from '../components/SegmentSelector';
5
4
  import { type DisplayedMutationType } from '../components/mutation-type-selector';
6
5
 
@@ -10,7 +9,7 @@ export type MutationData = {
10
9
  };
11
10
 
12
11
  export async function queryMutationData(
13
- variants: MutationComparisonVariant[],
12
+ variants: NamedLapisFilter[],
14
13
  sequenceType: 'nucleotide' | 'amino acid',
15
14
  lapis: string,
16
15
  ) {
@@ -19,11 +19,8 @@ const meta: Meta<MutationFilterProps> = {
19
19
  fetchMock: {},
20
20
  },
21
21
  argTypes: {
22
- size: {
23
- control: {
24
- type: 'object',
25
- },
26
- },
22
+ width: { control: 'text' },
23
+ height: { control: 'text' },
27
24
  initialValue: {
28
25
  control: {
29
26
  type: 'object',
@@ -39,12 +36,13 @@ export const Default: StoryObj<MutationFilterProps> = {
39
36
  render: (args) => (
40
37
  <LapisUrlContext.Provider value={LAPIS_URL}>
41
38
  <ReferenceGenomeContext.Provider value={referenceGenome}>
42
- <MutationFilter size={args.size} initialValue={args.initialValue} />
39
+ <MutationFilter width={args.width} height={args.height} initialValue={args.initialValue} />
43
40
  </ReferenceGenomeContext.Provider>
44
41
  </LapisUrlContext.Provider>
45
42
  ),
46
43
  args: {
47
- size: { width: '100%' },
44
+ width: '100%',
45
+ height: '700px',
48
46
  },
49
47
  };
50
48
 
@@ -155,7 +153,7 @@ export const WithInitialValue: StoryObj<MutationFilterProps> = {
155
153
  render: (args) => (
156
154
  <LapisUrlContext.Provider value={LAPIS_URL}>
157
155
  <ReferenceGenomeContext.Provider value={referenceGenome}>
158
- <MutationFilter initialValue={args.initialValue} />
156
+ <MutationFilter initialValue={args.initialValue} width={args.width} height={args.height} />
159
157
  </ReferenceGenomeContext.Provider>
160
158
  </LapisUrlContext.Provider>
161
159
  ),
@@ -166,6 +164,8 @@ export const WithInitialValue: StoryObj<MutationFilterProps> = {
166
164
  nucleotideInsertions: ['ins_123:AAA'],
167
165
  aminoAcidInsertions: ['ins_S:123:AAA'],
168
166
  },
167
+ width: '100%',
168
+ height: '700px',
169
169
  },
170
170
  play: async ({ canvasElement, step }) => {
171
171
  const { canvas, onBlurListenerMock } = await prepare(canvasElement, step);
@@ -7,7 +7,7 @@ import { type Deletion, type Insertion, type Mutation, type Substitution } from
7
7
  import { ReferenceGenomeContext } from '../ReferenceGenomeContext';
8
8
  import { ErrorBoundary } from '../components/error-boundary';
9
9
  import Info from '../components/info';
10
- import { ResizeContainer, type Size } from '../components/resize-container';
10
+ import { ResizeContainer } from '../components/resize-container';
11
11
  import { singleGraphColorRGBByName } from '../shared/charts/colors';
12
12
  import { DeleteIcon } from '../shared/icons/DeleteIcon';
13
13
 
@@ -16,7 +16,8 @@ export interface MutationFilterInnerProps {
16
16
  }
17
17
 
18
18
  export interface MutationFilterProps extends MutationFilterInnerProps {
19
- size?: Size;
19
+ width: string;
20
+ height: string;
20
21
  }
21
22
 
22
23
  export type SelectedFilters = {
@@ -30,12 +31,12 @@ export type SelectedMutationFilterStrings = {
30
31
  [Key in keyof SelectedFilters]: string[];
31
32
  };
32
33
 
33
- export const MutationFilter: FunctionComponent<MutationFilterProps> = ({ initialValue, size }) => {
34
- const defaultSize = { width: '100%', height: '6.5rem' };
34
+ export const MutationFilter: FunctionComponent<MutationFilterProps> = ({ initialValue, width, height }) => {
35
+ const size = { height, width };
35
36
 
36
37
  return (
37
- <ErrorBoundary size={size} defaultSize={defaultSize}>
38
- <ResizeContainer size={size} defaultSize={defaultSize}>
38
+ <ErrorBoundary size={size}>
39
+ <ResizeContainer size={size}>
39
40
  <MutationFilterInner initialValue={initialValue} />
40
41
  </ResizeContainer>
41
42
  </ErrorBoundary>
@@ -22,7 +22,8 @@ const meta: Meta<MutationsProps> = {
22
22
  options: ['table', 'grid', 'insertions'],
23
23
  control: { type: 'check' },
24
24
  },
25
- size: [{ control: 'object' }],
25
+ width: { control: 'text' },
26
+ height: { control: 'text' },
26
27
  headline: { control: 'text' },
27
28
  },
28
29
  };
@@ -37,7 +38,8 @@ const Template = {
37
38
  variant={args.variant}
38
39
  sequenceType={args.sequenceType}
39
40
  views={args.views}
40
- size={args.size}
41
+ width={args.width}
42
+ height={args.height}
41
43
  headline={args.headline}
42
44
  />
43
45
  </ReferenceGenomeContext.Provider>
@@ -51,7 +53,8 @@ export const Default: StoryObj<MutationsProps> = {
51
53
  variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
52
54
  sequenceType: 'nucleotide',
53
55
  views: ['grid', 'table', 'insertions'],
54
- size: { width: '100%', height: '700px' },
56
+ width: '100%',
57
+ height: '700px',
55
58
  headline: 'Mutations',
56
59
  },
57
60
  parameters: {
@@ -25,7 +25,7 @@ import { type DisplayedMutationType, MutationTypeSelector } from '../components/
25
25
  import { NoDataDisplay } from '../components/no-data-display';
26
26
  import type { ProportionInterval } from '../components/proportion-selector';
27
27
  import { ProportionSelectorDropdown } from '../components/proportion-selector-dropdown';
28
- import { ResizeContainer, type Size } from '../components/resize-container';
28
+ import { ResizeContainer } from '../components/resize-container';
29
29
  import Tabs from '../components/tabs';
30
30
  import { useQuery } from '../useQuery';
31
31
 
@@ -38,7 +38,8 @@ export interface MutationsInnerProps {
38
38
  }
39
39
 
40
40
  export interface MutationsProps extends MutationsInnerProps {
41
- size?: Size;
41
+ width: string;
42
+ height: string;
42
43
  headline?: string;
43
44
  }
44
45
 
@@ -46,14 +47,15 @@ export const Mutations: FunctionComponent<MutationsProps> = ({
46
47
  variant,
47
48
  sequenceType,
48
49
  views,
49
- size,
50
+ width,
51
+ height,
50
52
  headline = 'Mutations',
51
53
  }) => {
52
- const defaultSize = { height: '600px', width: '100%' };
54
+ const size = { height, width };
53
55
 
54
56
  return (
55
- <ErrorBoundary size={size} defaultSize={defaultSize} headline={headline}>
56
- <ResizeContainer size={size} defaultSize={defaultSize}>
57
+ <ErrorBoundary size={size} headline={headline}>
58
+ <ResizeContainer size={size}>
57
59
  <Headline heading={headline}>
58
60
  <MutationsInner variant={variant} sequenceType={sequenceType} views={views} />
59
61
  </Headline>
@@ -29,7 +29,8 @@ export default {
29
29
  options: ['wilson'],
30
30
  control: { type: 'check' },
31
31
  },
32
- size: [{ control: 'object' }],
32
+ width: { control: 'text' },
33
+ height: { control: 'text' },
33
34
  headline: { control: 'text' },
34
35
  },
35
36
  };
@@ -44,7 +45,8 @@ const Template = {
44
45
  smoothingWindow={args.smoothingWindow}
45
46
  views={args.views}
46
47
  confidenceIntervalMethods={args.confidenceIntervalMethods}
47
- size={args.size}
48
+ width={args.width}
49
+ height={args.height}
48
50
  headline={args.headline}
49
51
  />
50
52
  </LapisUrlContext.Provider>
@@ -55,15 +57,16 @@ export const TwoVariants = {
55
57
  ...Template,
56
58
  args: {
57
59
  numerator: [
58
- { displayName: 'EG', country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' },
59
- { displayName: 'JN.1', country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' },
60
+ { displayName: 'EG', lapisFilter: { country: 'USA', pangoLineage: 'EG*', dateFrom: '2023-01-01' } },
61
+ { displayName: 'JN.1', lapisFilter: { country: 'USA', pangoLineage: 'JN.1*', dateFrom: '2023-01-01' } },
60
62
  ],
61
63
  denominator: { country: 'USA', dateFrom: '2023-01-01' },
62
64
  granularity: 'month',
63
65
  smoothingWindow: 0,
64
66
  views: ['bar', 'line', 'bubble', 'table'],
65
67
  confidenceIntervalMethods: ['wilson'],
66
- size: { width: '100%', height: '700px' },
68
+ width: '100%',
69
+ height: '700px',
67
70
  headline: 'Prevalence over time',
68
71
  },
69
72
  parameters: {
@@ -124,13 +127,17 @@ export const TwoVariants = {
124
127
  export const OneVariant = {
125
128
  ...Template,
126
129
  args: {
127
- numerator: { displayName: 'EG', country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
130
+ numerator: {
131
+ displayName: 'EG',
132
+ lapisFilter: { country: 'USA', pangoLineage: 'BA.2.86*', dateFrom: '2023-10-01' },
133
+ },
128
134
  denominator: { country: 'USA', dateFrom: '2023-10-01' },
129
135
  granularity: 'day',
130
136
  smoothingWindow: 7,
131
137
  views: ['bar', 'line', 'bubble', 'table'],
132
138
  confidenceIntervalMethods: ['wilson'],
133
- size: { width: '100%', height: '700px' },
139
+ width: '100%',
140
+ height: '700px',
134
141
  headline: 'Prevalence over time',
135
142
  },
136
143
  parameters: {
@@ -7,7 +7,7 @@ import PrevalenceOverTimeBubbleChart from './prevalence-over-time-bubble-chart';
7
7
  import PrevalenceOverTimeLineChart from './prevalence-over-time-line-chart';
8
8
  import PrevalenceOverTimeTable from './prevalence-over-time-table';
9
9
  import { type PrevalenceOverTimeData, queryPrevalenceOverTime } from '../../query/queryPrevalenceOverTime';
10
- import { type NamedLapisFilter, type TemporalGranularity } from '../../types';
10
+ import { type LapisFilter, type NamedLapisFilter, type TemporalGranularity } from '../../types';
11
11
  import { LapisUrlContext } from '../LapisUrlContext';
12
12
  import { ConfidenceIntervalSelector } from '../components/confidence-interval-selector';
13
13
  import { CsvDownloadButton } from '../components/csv-download-button';
@@ -17,7 +17,7 @@ import Headline from '../components/headline';
17
17
  import Info, { InfoHeadline1, InfoParagraph } from '../components/info';
18
18
  import { LoadingDisplay } from '../components/loading-display';
19
19
  import { NoDataDisplay } from '../components/no-data-display';
20
- import { ResizeContainer, type Size } from '../components/resize-container';
20
+ import { ResizeContainer } from '../components/resize-container';
21
21
  import { ScalingSelector } from '../components/scaling-selector';
22
22
  import Tabs from '../components/tabs';
23
23
  import { type ConfidenceIntervalMethod } from '../shared/charts/confideceInterval';
@@ -27,13 +27,14 @@ import { useQuery } from '../useQuery';
27
27
  export type View = 'bar' | 'line' | 'bubble' | 'table';
28
28
 
29
29
  export interface PrevalenceOverTimeProps extends PrevalenceOverTimeInnerProps {
30
- size?: Size;
30
+ width: string;
31
+ height: string;
31
32
  headline?: string;
32
33
  }
33
34
 
34
35
  export interface PrevalenceOverTimeInnerProps {
35
36
  numerator: NamedLapisFilter | NamedLapisFilter[];
36
- denominator: NamedLapisFilter;
37
+ denominator: LapisFilter;
37
38
  granularity: TemporalGranularity;
38
39
  smoothingWindow: number;
39
40
  views: View[];
@@ -47,14 +48,15 @@ export const PrevalenceOverTime: FunctionComponent<PrevalenceOverTimeProps> = ({
47
48
  smoothingWindow,
48
49
  views,
49
50
  confidenceIntervalMethods,
50
- size,
51
+ width,
52
+ height,
51
53
  headline = 'Prevalence over time',
52
54
  }) => {
53
- const defaultSize = { height: '600px', width: '100%' };
55
+ const size = { height, width };
54
56
 
55
57
  return (
56
- <ErrorBoundary size={size} defaultSize={defaultSize} headline={headline}>
57
- <ResizeContainer size={size} defaultSize={defaultSize}>
58
+ <ErrorBoundary size={size} headline={headline}>
59
+ <ResizeContainer size={size}>
58
60
  <Headline heading={headline}>
59
61
  <PrevalenceOverTimeInner
60
62
  numerator={numerator}
@@ -18,7 +18,8 @@ export default {
18
18
  options: ['line'],
19
19
  control: { type: 'check' },
20
20
  },
21
- size: [{ control: 'object' }],
21
+ width: { control: 'text' },
22
+ height: { control: 'text' },
22
23
  headline: { control: 'text' },
23
24
  },
24
25
  };
@@ -31,7 +32,8 @@ export const Primary = {
31
32
  denominator={args.denominator}
32
33
  generationTime={args.generationTime}
33
34
  views={args.views}
34
- size={args.size}
35
+ width={args.width}
36
+ height={args.height}
35
37
  headline={args.headline}
36
38
  />
37
39
  </LapisUrlContext.Provider>
@@ -41,7 +43,8 @@ export const Primary = {
41
43
  denominator: { country: 'Switzerland', dateFrom: '2020-12-01', dateTo: '2021-03-01' },
42
44
  generationTime: 7,
43
45
  views: ['line'],
44
- size: { width: '100%', height: '700px' },
46
+ width: '100%',
47
+ height: '700px',
45
48
  headline: 'Relative growth advantage',
46
49
  },
47
50
  parameters: {
@@ -14,7 +14,7 @@ import Headline from '../components/headline';
14
14
  import Info, { InfoHeadline1, InfoHeadline2, InfoLink, InfoParagraph } from '../components/info';
15
15
  import { LoadingDisplay } from '../components/loading-display';
16
16
  import { NoDataDisplay } from '../components/no-data-display';
17
- import { ResizeContainer, type Size } from '../components/resize-container';
17
+ import { ResizeContainer } from '../components/resize-container';
18
18
  import { ScalingSelector } from '../components/scaling-selector';
19
19
  import Tabs from '../components/tabs';
20
20
  import { type ScaleType } from '../shared/charts/getYAxisScale';
@@ -23,7 +23,8 @@ import { useQuery } from '../useQuery';
23
23
  export type View = 'line';
24
24
 
25
25
  export interface RelativeGrowthAdvantageProps extends RelativeGrowthAdvantagePropsInner {
26
- size?: Size;
26
+ width: string;
27
+ height: string;
27
28
  headline?: string;
28
29
  }
29
30
 
@@ -36,17 +37,18 @@ export interface RelativeGrowthAdvantagePropsInner {
36
37
 
37
38
  export const RelativeGrowthAdvantage: FunctionComponent<RelativeGrowthAdvantageProps> = ({
38
39
  views,
39
- size,
40
+ width,
41
+ height,
40
42
  numerator,
41
43
  denominator,
42
44
  generationTime,
43
45
  headline = 'Relative growth advantage',
44
46
  }) => {
45
- const defaultSize = { height: '600px', width: '100%' };
47
+ const size = { height, width };
46
48
 
47
49
  return (
48
- <ErrorBoundary size={size} defaultSize={defaultSize} headline={headline}>
49
- <ResizeContainer size={size} defaultSize={defaultSize}>
50
+ <ErrorBoundary size={size} headline={headline}>
51
+ <ResizeContainer size={size}>
50
52
  <Headline heading={headline}>
51
53
  <RelativeGrowthAdvantageInner
52
54
  views={views}
@@ -60,7 +62,7 @@ export const RelativeGrowthAdvantage: FunctionComponent<RelativeGrowthAdvantageP
60
62
  );
61
63
  };
62
64
 
63
- export const RelativeGrowthAdvantageInner: FunctionComponent<RelativeGrowthAdvantageProps> = ({
65
+ export const RelativeGrowthAdvantageInner: FunctionComponent<RelativeGrowthAdvantagePropsInner> = ({
64
66
  numerator,
65
67
  denominator,
66
68
  generationTime,
@@ -33,6 +33,29 @@ const meta: Meta<TextInputProps> = {
33
33
  },
34
34
  },
35
35
  decorators: [withActions],
36
+ argTypes: {
37
+ lapisField: {
38
+ control: {
39
+ type: 'select',
40
+ },
41
+ options: ['host'],
42
+ },
43
+ placeholderText: {
44
+ control: {
45
+ type: 'text',
46
+ },
47
+ },
48
+ initialValue: {
49
+ control: {
50
+ type: 'text',
51
+ },
52
+ },
53
+ width: {
54
+ control: {
55
+ type: 'text',
56
+ },
57
+ },
58
+ },
36
59
  };
37
60
 
38
61
  export default meta;
@@ -44,12 +67,15 @@ export const Default: StoryObj<TextInputProps> = {
44
67
  lapisField={args.lapisField}
45
68
  placeholderText={args.placeholderText}
46
69
  initialValue={args.initialValue}
70
+ width={args.width}
47
71
  />
48
72
  </LapisUrlContext.Provider>
49
73
  ),
50
74
  args: {
51
75
  lapisField: 'host',
52
76
  placeholderText: 'Enter a host name',
77
+ initialValue: '',
78
+ width: '100%',
53
79
  },
54
80
  };
55
81
 
@@ -17,16 +17,15 @@ export interface TextInputInnerProps {
17
17
  }
18
18
 
19
19
  export interface TextInputProps extends TextInputInnerProps {
20
- width?: string;
20
+ width: string;
21
21
  }
22
22
 
23
23
  export const TextInput: FunctionComponent<TextInputProps> = ({ width, lapisField, placeholderText, initialValue }) => {
24
- const defaultSize = { width: '100%', height: '3rem' };
25
- const size = width === undefined ? undefined : { width, height: defaultSize.height };
24
+ const size = { width, height: '3rem' };
26
25
 
27
26
  return (
28
- <ErrorBoundary defaultSize={defaultSize} size={size}>
29
- <ResizeContainer size={size} defaultSize={defaultSize}>
27
+ <ErrorBoundary size={size}>
28
+ <ResizeContainer size={size}>
30
29
  <TextInputInner lapisField={lapisField} placeholderText={placeholderText} initialValue={initialValue} />
31
30
  </ResizeContainer>
32
31
  </ErrorBoundary>