@genspectrum/dashboard-components 0.1.3 → 0.1.5

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 (78) hide show
  1. package/custom-elements.json +488 -117
  2. package/dist/dashboard-components.js +904 -466
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/genspectrum-components.d.ts +473 -67
  5. package/dist/style.css +273 -153
  6. package/package.json +11 -7
  7. package/src/preact/aggregatedData/aggregate.stories.tsx +7 -5
  8. package/src/preact/aggregatedData/aggregate.tsx +16 -7
  9. package/src/preact/components/ReferenceGenomesAwaiter.tsx +25 -0
  10. package/src/preact/components/csv-download-button.tsx +8 -2
  11. package/src/preact/components/headline.stories.tsx +19 -1
  12. package/src/preact/components/headline.tsx +25 -5
  13. package/src/preact/components/info.stories.tsx +24 -3
  14. package/src/preact/components/info.tsx +49 -5
  15. package/src/preact/components/min-max-range-slider.tsx +4 -4
  16. package/src/preact/components/percent-intput.tsx +2 -3
  17. package/src/preact/components/resize-container.tsx +23 -0
  18. package/src/preact/components/table.tsx +1 -0
  19. package/src/preact/components/tabs.stories.tsx +2 -2
  20. package/src/preact/components/tabs.tsx +47 -24
  21. package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +36 -4
  22. package/src/preact/dateRangeSelector/date-range-selector.tsx +67 -53
  23. package/src/preact/locationFilter/location-filter.tsx +2 -2
  24. package/src/preact/mutationComparison/getMutationComparisonTableData.spec.ts +5 -5
  25. package/src/preact/mutationComparison/getMutationComparisonTableData.ts +45 -10
  26. package/src/preact/mutationComparison/mutation-comparison-table.tsx +20 -22
  27. package/src/preact/mutationComparison/mutation-comparison-venn.tsx +6 -3
  28. package/src/preact/mutationComparison/mutation-comparison.stories.tsx +11 -1
  29. package/src/preact/mutationComparison/mutation-comparison.tsx +16 -7
  30. package/src/preact/mutationFilter/mutation-filter.stories.tsx +70 -31
  31. package/src/preact/mutationFilter/mutation-filter.tsx +62 -14
  32. package/src/preact/mutations/getInsertionsTableData.spec.ts +6 -4
  33. package/src/preact/mutations/getInsertionsTableData.ts +1 -1
  34. package/src/preact/mutations/getMutationsTableData.spec.ts +9 -19
  35. package/src/preact/mutations/getMutationsTableData.ts +1 -1
  36. package/src/preact/mutations/mutations-insertions-table.tsx +3 -1
  37. package/src/preact/mutations/mutations-table.tsx +3 -1
  38. package/src/preact/mutations/mutations.stories.tsx +11 -1
  39. package/src/preact/mutations/mutations.tsx +24 -7
  40. package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +1 -0
  41. package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +1 -0
  42. package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +1 -0
  43. package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +8 -0
  44. package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +31 -13
  45. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +8 -5
  46. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +15 -0
  47. package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +62 -12
  48. package/src/preact/shared/sort/sortInsertions.spec.ts +11 -10
  49. package/src/preact/shared/sort/sortInsertions.ts +10 -17
  50. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.spec.ts +19 -10
  51. package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +45 -12
  52. package/src/preact/textInput/text-input.stories.tsx +22 -1
  53. package/src/preact/textInput/text-input.tsx +3 -1
  54. package/src/utils/typeAssertions.spec.ts +31 -0
  55. package/src/utils/typeAssertions.ts +16 -0
  56. package/src/web-components/PreactLitAdapter.tsx +0 -1
  57. package/src/web-components/app.stories.ts +129 -0
  58. package/src/web-components/app.ts +27 -6
  59. package/src/web-components/display/aggregate-component.stories.ts +24 -11
  60. package/src/web-components/display/aggregate-component.tsx +26 -5
  61. package/src/web-components/display/mutation-comparison-component.stories.ts +32 -11
  62. package/src/web-components/display/mutation-comparison-component.tsx +79 -4
  63. package/src/web-components/display/mutations-component.stories.ts +40 -19
  64. package/src/web-components/display/mutations-component.tsx +71 -4
  65. package/src/web-components/display/prevalence-over-time-component.stories.ts +44 -18
  66. package/src/web-components/display/prevalence-over-time-component.tsx +105 -5
  67. package/src/web-components/display/relative-growth-advantage-component.stories.ts +32 -10
  68. package/src/web-components/display/relative-growth-advantage-component.tsx +66 -3
  69. package/src/web-components/input/date-range-selector-component.stories.ts +51 -9
  70. package/src/web-components/input/date-range-selector-component.tsx +69 -4
  71. package/src/web-components/input/location-filter-component.stories.ts +15 -4
  72. package/src/web-components/input/location-filter-component.tsx +2 -6
  73. package/src/web-components/input/mutation-filter-component.stories.ts +33 -12
  74. package/src/web-components/input/mutation-filter-component.tsx +60 -4
  75. package/src/web-components/input/text-input-component.stories.ts +26 -6
  76. package/src/web-components/input/text-input-component.tsx +34 -3
  77. package/src/web-components/display/aggregate-component.mdx +0 -25
  78. package/src/web-components/input/location-filter.mdx +0 -25
@@ -0,0 +1,129 @@
1
+ import { consume } from '@lit/context';
2
+ import { withActions } from '@storybook/addon-actions/decorator';
3
+ import { expect, waitFor, within } from '@storybook/test';
4
+ import type { Meta, StoryObj } from '@storybook/web-components';
5
+ import { html, LitElement } from 'lit';
6
+ import { customElement } from 'lit/decorators.js';
7
+
8
+ import './app';
9
+
10
+ import { lapisContext } from './lapis-context';
11
+ import { referenceGenomeContext } from './reference-genome-context';
12
+ import { withComponentDocs } from '../../.storybook/ComponentDocsBlock';
13
+ import { LAPIS_URL, REFERENCE_GENOME_ENDPOINT } from '../constants';
14
+ import type { ReferenceGenome } from '../lapisApi/ReferenceGenome';
15
+ import referenceGenome from '../lapisApi/__mockData__/referenceGenome.json';
16
+
17
+ const codeExample = String.raw`
18
+ <gs-app lapis="https://url.to.lapis">
19
+ <p>Your application code goes here.</p>
20
+ </gs-app>`;
21
+
22
+ const meta: Meta = {
23
+ title: 'Wrapper/App',
24
+ component: 'gs-app',
25
+ parameters: withComponentDocs({
26
+ fetchMock: {},
27
+ componentDocs: {
28
+ tag: 'gs-app',
29
+ opensShadowDom: false,
30
+ expectsChildren: true,
31
+ codeExample,
32
+ },
33
+ }),
34
+ decorators: [withActions],
35
+ tags: ['autodocs'],
36
+ };
37
+
38
+ export default meta;
39
+
40
+ const Template: StoryObj<{ lapis: string }> = {
41
+ render: (args) => {
42
+ return html` <gs-app lapis="${args.lapis}">
43
+ <gs-app-display></gs-app-display>
44
+ </gs-app>`;
45
+ },
46
+ args: {
47
+ lapis: LAPIS_URL,
48
+ },
49
+ };
50
+
51
+ export const Default: StoryObj<{ lapis: string }> = {
52
+ ...Template,
53
+ play: async ({ canvasElement }) => {
54
+ const canvas = within(canvasElement);
55
+
56
+ await waitFor(() => {
57
+ expect(canvas.getByText(LAPIS_URL)).toBeVisible();
58
+ expect(canvas.getByText('"name": "ORF1a",', { exact: false })).toBeVisible();
59
+ });
60
+ },
61
+ };
62
+
63
+ export const DelayFetchingReferenceGenome: StoryObj<{ lapis: string }> = {
64
+ ...Template,
65
+ parameters: {
66
+ fetchMock: {
67
+ mocks: [
68
+ {
69
+ matcher: {
70
+ name: 'referenceGenome',
71
+ url: REFERENCE_GENOME_ENDPOINT,
72
+ },
73
+ response: {
74
+ status: 200,
75
+ body: referenceGenome,
76
+ },
77
+ options: {
78
+ delay: 5000,
79
+ },
80
+ },
81
+ ],
82
+ },
83
+ },
84
+ };
85
+
86
+ export const FailsToFetchReferenceGenome: StoryObj<{ lapis: string }> = {
87
+ ...Template,
88
+ args: {
89
+ lapis: 'definitely-not-a-valid-url',
90
+ },
91
+ play: async ({ canvasElement }) => {
92
+ const canvas = within(canvasElement);
93
+
94
+ await waitFor(() => {
95
+ expect(canvas.getByText('Error')).toBeVisible();
96
+ });
97
+ },
98
+ };
99
+
100
+ @customElement('gs-app-display')
101
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars -- it is used in the story above
102
+ class AppDisplay extends LitElement {
103
+ @consume({ context: lapisContext })
104
+ lapis: string = '';
105
+
106
+ @consume({ context: referenceGenomeContext, subscribe: true })
107
+ referenceGenome: ReferenceGenome = {
108
+ nucleotideSequences: [],
109
+ genes: [],
110
+ };
111
+
112
+ override render() {
113
+ return html`
114
+ <h1 class="text-xl font-bold">Dummy component</h1>
115
+ <p>
116
+ What you can see here is a dummy component that displays the values of the wrapping "gs-app". Actually
117
+ "gs-app" doesn't display anything.
118
+ </p>
119
+ <h2 class="text-lg font-bold">LAPIS URL</h2>
120
+ <p>${this.lapis}</p>
121
+ <h2 class="text-lg font-bold">Reference genomes</h2>
122
+ <pre><code>${JSON.stringify(this.referenceGenome, null, 2)}</code></pre>
123
+ `;
124
+ }
125
+
126
+ override createRenderRoot() {
127
+ return this;
128
+ }
129
+ }
@@ -8,18 +8,43 @@ import { referenceGenomeContext } from './reference-genome-context';
8
8
  import { type ReferenceGenome } from '../lapisApi/ReferenceGenome';
9
9
  import { fetchReferenceGenome } from '../lapisApi/lapisApi';
10
10
 
11
+ /**
12
+ * ## Context
13
+ *
14
+ * This component provides the main application context.
15
+ * All other `gs-*` components must be (possibly nested) children of this component.
16
+ * It makes use of the [Lit Context](https://lit.dev/docs/data/context/) to
17
+ * - provide the URL to the LAPIS instance to all its children
18
+ * - fetch the reference genomes from LAPIS and provide it to all its children
19
+ *
20
+ * This will show an error message if the reference genome cannot be fetched
21
+ * (e.g., due to an invalid LAPIS URL).
22
+ *
23
+ * ## Shadow DOM
24
+ *
25
+ * This component does __not__ use a shadow DOM. Children of this component will be rendered directly in the light DOM.
26
+ */
11
27
  @customElement('gs-app')
12
28
  export class App extends LitElement {
29
+ /**
30
+ * The URL of the LAPIS instance that all children of this component will use.
31
+ */
13
32
  @provide({ context: lapisContext })
14
33
  @property()
15
34
  lapis: string = '';
16
35
 
36
+ /**
37
+ * @internal
38
+ */
17
39
  @provide({ context: referenceGenomeContext })
18
40
  referenceGenome: ReferenceGenome = {
19
41
  nucleotideSequences: [],
20
42
  genes: [],
21
43
  };
22
44
 
45
+ /**
46
+ * @internal
47
+ */
23
48
  private updateReferenceGenome = new Task(this, {
24
49
  task: async () => {
25
50
  this.referenceGenome = await fetchReferenceGenome(this.lapis);
@@ -29,13 +54,9 @@ export class App extends LitElement {
29
54
 
30
55
  override render() {
31
56
  return this.updateReferenceGenome.render({
32
- complete: () => {
33
- return html` <slot></slot>`;
34
- },
57
+ complete: () => html` <slot></slot>`,
35
58
  error: () => html`<p>Error</p>`, // TODO(#143): Add more advanced error handling
36
- pending: () => {
37
- return html`<p>Loading...</p>`;
38
- },
59
+ pending: () => html` <p>Loading reference genomes...</p> `,
39
60
  });
40
61
  }
41
62
 
@@ -1,9 +1,11 @@
1
1
  import { type Meta, type StoryObj } from '@storybook/web-components';
2
2
  import { html } from 'lit';
3
3
 
4
+ import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
4
5
  import { AGGREGATED_ENDPOINT, LAPIS_URL } from '../../constants';
5
6
  import aggregatedData from '../../preact/aggregatedData/__mockData__/aggregated.json';
6
7
  import type { AggregateProps } from '../../preact/aggregatedData/aggregate';
8
+
7
9
  import './aggregate-component';
8
10
  import '../app';
9
11
 
@@ -16,8 +18,10 @@ const meta: Meta<AggregateProps> = {
16
18
  options: ['table'],
17
19
  control: { type: 'check' },
18
20
  },
21
+ size: [{ control: 'object' }],
22
+ headline: { control: 'text' },
19
23
  },
20
- parameters: {
24
+ parameters: withComponentDocs({
21
25
  fetchMock: {
22
26
  mocks: [
23
27
  {
@@ -36,22 +40,29 @@ const meta: Meta<AggregateProps> = {
36
40
  },
37
41
  ],
38
42
  },
39
- },
43
+ componentDocs: {
44
+ tag: 'gs-aggregate-component',
45
+ opensShadowDom: true,
46
+ expectsChildren: false,
47
+ codeExample: `<gs-aggregate-component fields='["division", "host"]' filter='{"country": "USA"}' views='["table"]'></gs-aggregate-component>`,
48
+ },
49
+ }),
50
+ tags: ['autodocs'],
40
51
  };
41
52
 
42
53
  export default meta;
43
54
 
44
55
  export const Table: StoryObj<AggregateProps> = {
45
56
  render: (args) => html`
46
- <div class="w-11/12 h-11/12">
47
- <gs-app lapis="${LAPIS_URL}">
48
- <gs-aggregate-component
49
- .fields=${args.fields}
50
- .filter=${args.filter}
51
- .views=${args.views}
52
- ></gs-aggregate-component>
53
- </gs-app>
54
- </div>
57
+ <gs-app lapis="${LAPIS_URL}">
58
+ <gs-aggregate-component
59
+ .fields=${args.fields}
60
+ .filter=${args.filter}
61
+ .views=${args.views}
62
+ .size=${args.size}
63
+ .headline=${args.headline}
64
+ ></gs-aggregate-component>
65
+ </gs-app>
55
66
  `,
56
67
  args: {
57
68
  fields: ['division', 'host'],
@@ -59,5 +70,7 @@ export const Table: StoryObj<AggregateProps> = {
59
70
  filter: {
60
71
  country: 'USA',
61
72
  },
73
+ size: { width: '100%', height: '700px' },
74
+ headline: 'Aggregate',
62
75
  },
63
76
  };
@@ -5,10 +5,6 @@ import { type LapisFilter } from '../../types';
5
5
  import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
6
6
 
7
7
  /**
8
- * ## Tag
9
- *
10
- * `gs-aggregate-component`
11
- *
12
8
  * ## Context
13
9
  *
14
10
  * This component displays aggregated data, which can provide an overview of the underlying data.
@@ -39,8 +35,33 @@ export class AggregateComponent extends PreactLitAdapterWithGridJsStyles {
39
35
  @property({ type: Object })
40
36
  filter: LapisFilter = {};
41
37
 
38
+ /**
39
+ * The size of the component.
40
+ *
41
+ * If not set, the component will take the full width of its container with height 700px.
42
+ *
43
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
44
+ * If the unit is %, the size will be relative to the container of the component.
45
+ */
46
+ @property({ type: Object })
47
+ size: { width?: string; height?: string } | undefined = undefined;
48
+
49
+ /**
50
+ * The headline of the component. Set to an empty string to hide the headline.
51
+ */
52
+ @property({ type: String })
53
+ headline: string | undefined = 'Aggregate';
54
+
42
55
  override render() {
43
- return <Aggregate fields={this.fields} views={this.views} filter={this.filter} />;
56
+ return (
57
+ <Aggregate
58
+ fields={this.fields}
59
+ views={this.views}
60
+ filter={this.filter}
61
+ size={this.size}
62
+ headline={this.headline}
63
+ />
64
+ );
44
65
  }
45
66
  }
46
67
 
@@ -4,12 +4,20 @@ import { html } from 'lit';
4
4
 
5
5
  import './mutation-comparison-component';
6
6
  import '../app';
7
+ import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
7
8
  import { LAPIS_URL, NUCLEOTIDE_MUTATIONS_ENDPOINT } from '../../constants';
8
9
  import nucleotideMutationsOtherVariant from '../../preact/mutationComparison/__mockData__/nucleotideMutationsOtherVariant.json';
9
10
  import nucleotideMutationsSomeVariant from '../../preact/mutationComparison/__mockData__/nucleotideMutationsSomeVariant.json';
10
11
  import { type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
11
12
  import { withinShadowRoot } from '../withinShadowRoot.story';
12
13
 
14
+ const codeExample = String.raw`
15
+ <gs-mutation-comparison-component
16
+ variants='[{ "displayName": "variant1", "lapisFilter": { "country": "Switzerland" }}, { "displayName": "variant2", "lapisFilter": { "country": "Germany" }}]'
17
+ sequenceType="nucleotide"
18
+ views='["table", "venn"]'
19
+ ></gs-mutation-comparison-component>`;
20
+
13
21
  const meta: Meta<MutationComparisonProps> = {
14
22
  title: 'Visualization/Mutation comparison',
15
23
  component: 'gs-mutation-comparison-component',
@@ -23,22 +31,33 @@ const meta: Meta<MutationComparisonProps> = {
23
31
  options: ['table', 'venn'],
24
32
  control: { type: 'check' },
25
33
  },
34
+ size: { control: 'object' },
35
+ headline: { control: 'text' },
26
36
  },
37
+ parameters: withComponentDocs({
38
+ componentDocs: {
39
+ tag: 'gs-mutation-comparison-component',
40
+ opensShadowDom: true,
41
+ expectsChildren: false,
42
+ codeExample,
43
+ },
44
+ }),
45
+ tags: ['autodocs'],
27
46
  };
28
47
 
29
48
  export default meta;
30
49
 
31
50
  const Template: StoryObj<MutationComparisonProps> = {
32
51
  render: (args) => html`
33
- <div class="w-11/12 h-11/12">
34
- <gs-app lapis="${LAPIS_URL}">
35
- <gs-mutation-comparison-component
36
- .variants=${args.variants}
37
- .sequenceType=${args.sequenceType}
38
- .views=${args.views}
39
- ></gs-mutation-comparison-component>
40
- </gs-app>
41
- </div>
52
+ <gs-app lapis="${LAPIS_URL}">
53
+ <gs-mutation-comparison-component
54
+ .variants=${args.variants}
55
+ .sequenceType=${args.sequenceType}
56
+ .views=${args.views}
57
+ .size=${args.size}
58
+ .headline=${args.headline}
59
+ ></gs-mutation-comparison-component>
60
+ </gs-app>
42
61
  `,
43
62
  };
44
63
 
@@ -65,6 +84,8 @@ export const Default: StoryObj<MutationComparisonProps> = {
65
84
  ],
66
85
  sequenceType: 'nucleotide',
67
86
  views: ['table', 'venn'],
87
+ size: { width: '100%', height: '700px' },
88
+ headline: 'Mutation comparison',
68
89
  },
69
90
  parameters: {
70
91
  fetchMock: {
@@ -124,9 +145,9 @@ export const VennDiagram: StoryObj<MutationComparisonProps> = {
124
145
  const canvas = await withinShadowRoot(canvasElement, 'gs-mutation-comparison-component');
125
146
 
126
147
  await step('Switch to Venn diagram view', async () => {
127
- await waitFor(() => expect(canvas.getByLabelText('Venn', { selector: 'input' })).toBeInTheDocument());
148
+ await waitFor(() => expect(canvas.getByRole('button', { name: 'Venn' })).toBeInTheDocument());
128
149
 
129
- await fireEvent.click(canvas.getByLabelText('Venn', { selector: 'input' }));
150
+ await fireEvent.click(canvas.getByRole('button', { name: 'Venn' }));
130
151
 
131
152
  await waitFor(() =>
132
153
  expect(
@@ -6,21 +6,88 @@ import {
6
6
  type View,
7
7
  } from '../../preact/mutationComparison/mutation-comparison';
8
8
  import { type SequenceType } from '../../types';
9
+ import { type Equals, type Expect } from '../../utils/typeAssertions';
9
10
  import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles';
10
11
 
12
+ /**
13
+ * This component allows to compare mutations between different variants.
14
+ * A variant is defined by its LAPIS filter.
15
+ *
16
+ * It only shows substitutions and deletions, it does not show insertions.
17
+ *
18
+ * ## Views
19
+ *
20
+ * ### Table View
21
+ *
22
+ * The table view shows mutations
23
+ * and the proportions with which the mutation occurs in the respective variant.
24
+ * It only shows mutations that are present in at least one of the variants
25
+ * and where the proportion is within the selected proportion interval for at least one variant.
26
+ *
27
+ * ### Venn View
28
+ *
29
+ * The Venn view shows the overlap of mutations between the variants in a Venn diagram.
30
+ * A variant is considered to have a certain mutation,
31
+ * if the proportion of the mutation in the variant is within the selected proportion interval.
32
+ * Thus, changing the proportion interval may change a mutations from being "common" between variant
33
+ * to being "for one variant only".
34
+ */
11
35
  @customElement('gs-mutation-comparison-component')
12
36
  export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles {
37
+ /**
38
+ * An array of variants to compare.
39
+ *
40
+ * The `lapisFilter` will be sent as is to LAPIS to filter the mutation data.
41
+ * It must be a valid LAPIS filter object.
42
+ *
43
+ * The `displayName` will be used as the label for the variant in the views.
44
+ * It should be human-readable.
45
+ */
13
46
  @property({ type: Array })
14
- variants: MutationComparisonVariant[] = [];
47
+ variants: {
48
+ lapisFilter: Record<string, string | number | null | boolean>;
49
+ displayName: string;
50
+ }[] = [];
15
51
 
52
+ /**
53
+ * The type of the sequence for which the mutations should be shown.
54
+ */
16
55
  @property({ type: String })
17
- sequenceType: SequenceType = 'nucleotide';
56
+ sequenceType: 'nucleotide' | 'amino acid' = 'nucleotide';
18
57
 
58
+ /**
59
+ * A list of tabs with views that this component should provide.
60
+ */
19
61
  @property({ type: Array })
20
- views: View[] = ['table'];
62
+ views: ('table' | 'venn')[] = ['table'];
63
+
64
+ /**
65
+ * The size of the component.
66
+ *
67
+ * If not set, the component will take the full width of its container with height 700px.
68
+ *
69
+ * The width and height should be a string with a unit in css style, e.g. '100%', '500px' or '50vh'.
70
+ * If the unit is %, the size will be relative to the container of the component.
71
+ */
72
+ @property({ type: Object })
73
+ size: { width?: string; height?: string } | undefined = undefined;
74
+
75
+ /**
76
+ * The headline of the component. Set to an empty string to hide the headline.
77
+ */
78
+ @property({ type: String })
79
+ headline: string | undefined = 'Mutation comparison';
21
80
 
22
81
  override render() {
23
- return <MutationComparison variants={this.variants} sequenceType={this.sequenceType} views={this.views} />;
82
+ return (
83
+ <MutationComparison
84
+ variants={this.variants}
85
+ sequenceType={this.sequenceType}
86
+ views={this.views}
87
+ size={this.size}
88
+ headline={this.headline}
89
+ />
90
+ );
24
91
  }
25
92
  }
26
93
 
@@ -29,3 +96,11 @@ declare global {
29
96
  'gs-mutation-comparison-component': MutationComparisonComponent;
30
97
  }
31
98
  }
99
+
100
+ /* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
101
+ type VariantsMatches = Expect<
102
+ Equals<typeof MutationComparisonComponent.prototype.variants, MutationComparisonVariant[]>
103
+ >;
104
+ type SequenceTypeMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.sequenceType, SequenceType>>;
105
+ type ViewsMatches = Expect<Equals<typeof MutationComparisonComponent.prototype.views, View[]>>;
106
+ /* eslint-enable @typescript-eslint/no-unused-vars, no-unused-vars */
@@ -4,15 +4,23 @@ import { html } from 'lit';
4
4
 
5
5
  import './mutations-component';
6
6
  import '../app';
7
+ import { withComponentDocs } from '../../../.storybook/ComponentDocsBlock';
7
8
  import { LAPIS_URL, NUCLEOTIDE_INSERTIONS_ENDPOINT, NUCLEOTIDE_MUTATIONS_ENDPOINT } from '../../constants';
8
9
  import nucleotideInsertions from '../../preact/mutations/__mockData__/nucleotideInsertions.json';
9
10
  import nucleotideMutations from '../../preact/mutations/__mockData__/nucleotideMutations.json';
10
11
  import { type MutationsProps } from '../../preact/mutations/mutations';
11
12
  import { withinShadowRoot } from '../withinShadowRoot.story';
12
13
 
14
+ const codeExample = String.raw`
15
+ <gs-mutations
16
+ variant='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateTo": "2022-01-01" }'
17
+ sequenceType="nucleotide"
18
+ views='["grid", "table", "insertions"]'
19
+ ></gs-mutations>`;
20
+
13
21
  const meta: Meta<MutationsProps> = {
14
22
  title: 'Visualization/Mutations',
15
- component: 'gs-mutations',
23
+ component: 'gs-mutations-component',
16
24
  argTypes: {
17
25
  variant: { control: 'object' },
18
26
  sequenceType: {
@@ -23,32 +31,45 @@ const meta: Meta<MutationsProps> = {
23
31
  options: ['table', 'grid', 'insertions'],
24
32
  control: { type: 'check' },
25
33
  },
34
+ size: { control: 'object' },
35
+ headline: { control: 'text' },
36
+ },
37
+ args: {
38
+ variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
39
+ sequenceType: 'nucleotide',
40
+ views: ['grid', 'table', 'insertions'],
41
+ size: { width: '100%', height: '700px' },
42
+ headline: 'Mutations',
26
43
  },
44
+ parameters: withComponentDocs({
45
+ componentDocs: {
46
+ tag: 'gs-mutations-component',
47
+ opensShadowDom: true,
48
+ expectsChildren: false,
49
+ codeExample,
50
+ },
51
+ }),
52
+ tags: ['autodocs'],
27
53
  };
28
54
 
29
55
  export default meta;
30
56
 
31
57
  const Template: StoryObj<MutationsProps> = {
32
58
  render: (args) => html`
33
- <div class="w-11/12 h-11/12">
34
- <gs-app lapis="${LAPIS_URL}">
35
- <gs-mutations-component
36
- .variant=${args.variant}
37
- .sequenceType=${args.sequenceType}
38
- .views=${args.views}
39
- ></gs-mutations-component>
40
- </gs-app>
41
- </div>
59
+ <gs-app lapis="${LAPIS_URL}">
60
+ <gs-mutations-component
61
+ .variant=${args.variant}
62
+ .sequenceType=${args.sequenceType}
63
+ .views=${args.views}
64
+ .size=${args.size}
65
+ .headline=${args.headline}
66
+ ></gs-mutations-component>
67
+ </gs-app>
42
68
  `,
43
69
  };
44
70
 
45
71
  export const Default: StoryObj<MutationsProps> = {
46
72
  ...Template,
47
- args: {
48
- variant: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo: '2022-01-01' },
49
- sequenceType: 'nucleotide',
50
- views: ['grid', 'table', 'insertions'],
51
- },
52
73
  parameters: {
53
74
  fetchMock: {
54
75
  mocks: [
@@ -89,9 +110,9 @@ export const OnTableTab: StoryObj<MutationsProps> = {
89
110
  play: async ({ canvasElement }) => {
90
111
  const canvas = await withinShadowRoot(canvasElement, 'gs-mutations-component');
91
112
 
92
- await waitFor(() => expect(canvas.getByLabelText('Table', { selector: 'input' })).toBeInTheDocument());
113
+ await waitFor(() => expect(canvas.getByRole('button', { name: 'Table' })).toBeInTheDocument());
93
114
 
94
- await fireEvent.click(canvas.getByLabelText('Table', { selector: 'input' }));
115
+ await fireEvent.click(canvas.getByRole('button', { name: 'Table' }));
95
116
  },
96
117
  };
97
118
 
@@ -100,8 +121,8 @@ export const OnInsertionsTab: StoryObj<MutationsProps> = {
100
121
  play: async ({ canvasElement }) => {
101
122
  const canvas = await withinShadowRoot(canvasElement, 'gs-mutations-component');
102
123
 
103
- await waitFor(() => expect(canvas.getByLabelText('Insertions', { selector: 'input' })).toBeInTheDocument());
124
+ await waitFor(() => expect(canvas.getByRole('button', { name: 'Insertions' })).toBeInTheDocument());
104
125
 
105
- await fireEvent.click(canvas.getByLabelText('Insertions', { selector: 'input' }));
126
+ await fireEvent.click(canvas.getByRole('button', { name: 'Insertions' }));
106
127
  },
107
128
  };