@genspectrum/dashboard-components 0.6.5 → 0.6.6

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 (26) hide show
  1. package/custom-elements.json +35 -3
  2. package/dist/dashboard-components.js +142 -23
  3. package/dist/dashboard-components.js.map +1 -1
  4. package/dist/style.css +50 -2
  5. package/package.json +1 -1
  6. package/src/constants.ts +1 -0
  7. package/src/preact/components/tooltip.stories.tsx +12 -2
  8. package/src/preact/components/tooltip.tsx +37 -13
  9. package/src/preact/mutationsOverTime/__mockData__/aggregated_byDay.json +38 -0
  10. package/src/preact/mutationsOverTime/__mockData__/aggregated_byWeek.json +122 -0
  11. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_20_01_2024.json +6778 -0
  12. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_21_01_2024.json +7129 -0
  13. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_22_01_2024.json +4681 -0
  14. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_23_01_2024.json +10738 -0
  15. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_24_01_2024.json +11710 -0
  16. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_25_01_2024.json +11557 -0
  17. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutations_26_01_2024.json +8596 -0
  18. package/src/preact/mutationsOverTime/__mockData__/nucleotideMutations_week3_2024.json +8812 -0
  19. package/src/preact/mutationsOverTime/__mockData__/nucleotideMutations_week4_2024.json +9730 -0
  20. package/src/preact/mutationsOverTime/__mockData__/nucleotideMutations_week5_2024.json +9865 -0
  21. package/src/preact/mutationsOverTime/__mockData__/nucleotideMutations_week6_2024.json +11314 -0
  22. package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +26 -8
  23. package/src/preact/mutationsOverTime/mutations-over-time.tsx +32 -8
  24. package/src/utils/temporal.spec.ts +3 -4
  25. package/src/utils/temporal.ts +9 -4
  26. package/src/web-components/visualization/gs-mutations-over-time.stories.ts +254 -2
package/dist/style.css CHANGED
@@ -2767,6 +2767,9 @@ input.tab:checked + .tab-content,
2767
2767
  .visible {
2768
2768
  visibility: visible;
2769
2769
  }
2770
+ .invisible {
2771
+ visibility: hidden;
2772
+ }
2770
2773
  .static {
2771
2774
  position: static;
2772
2775
  }
@@ -2782,18 +2785,39 @@ input.tab:checked + .tab-content,
2782
2785
  .-top-3 {
2783
2786
  top: -0.75rem;
2784
2787
  }
2788
+ .bottom-full {
2789
+ bottom: 100%;
2790
+ }
2785
2791
  .left-0 {
2786
2792
  left: 0px;
2787
2793
  }
2794
+ .left-1\/2 {
2795
+ left: 50%;
2796
+ }
2797
+ .left-full {
2798
+ left: 100%;
2799
+ }
2800
+ .right-0 {
2801
+ right: 0px;
2802
+ }
2788
2803
  .right-2 {
2789
2804
  right: 0.5rem;
2790
2805
  }
2806
+ .right-full {
2807
+ right: 100%;
2808
+ }
2791
2809
  .top-0 {
2792
2810
  top: 0px;
2793
2811
  }
2812
+ .top-1\/2 {
2813
+ top: 50%;
2814
+ }
2794
2815
  .top-2 {
2795
2816
  top: 0.5rem;
2796
2817
  }
2818
+ .top-full {
2819
+ top: 100%;
2820
+ }
2797
2821
  .z-10 {
2798
2822
  z-index: 10;
2799
2823
  }
@@ -2822,18 +2846,30 @@ input.tab:checked + .tab-content,
2822
2846
  margin-top: 1rem;
2823
2847
  margin-bottom: 1rem;
2824
2848
  }
2849
+ .mb-1 {
2850
+ margin-bottom: 0.25rem;
2851
+ }
2825
2852
  .mb-2 {
2826
2853
  margin-bottom: 0.5rem;
2827
2854
  }
2855
+ .ml-1 {
2856
+ margin-left: 0.25rem;
2857
+ }
2828
2858
  .ml-2\.5 {
2829
2859
  margin-left: 0.625rem;
2830
2860
  }
2831
2861
  .ml-3 {
2832
2862
  margin-left: 0.75rem;
2833
2863
  }
2864
+ .mr-1 {
2865
+ margin-right: 0.25rem;
2866
+ }
2834
2867
  .mr-2 {
2835
2868
  margin-right: 0.5rem;
2836
2869
  }
2870
+ .mt-1 {
2871
+ margin-top: 0.25rem;
2872
+ }
2837
2873
  .mt-4 {
2838
2874
  margin-top: 1rem;
2839
2875
  }
@@ -2892,6 +2928,14 @@ input.tab:checked + .tab-content,
2892
2928
  .grow {
2893
2929
  flex-grow: 1;
2894
2930
  }
2931
+ .translate-x-\[-50\%\] {
2932
+ --tw-translate-x: -50%;
2933
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
2934
+ }
2935
+ .translate-y-\[-50\%\] {
2936
+ --tw-translate-y: -50%;
2937
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
2938
+ }
2895
2939
  .resize {
2896
2940
  resize: both;
2897
2941
  }
@@ -2992,6 +3036,10 @@ input.tab:checked + .tab-content,
2992
3036
  --tw-border-opacity: 1;
2993
3037
  border-color: rgb(239 68 68 / var(--tw-border-opacity));
2994
3038
  }
3039
+ .bg-red-200 {
3040
+ --tw-bg-opacity: 1;
3041
+ background-color: rgb(254 202 202 / var(--tw-bg-opacity));
3042
+ }
2995
3043
  .bg-white {
2996
3044
  --tw-bg-opacity: 1;
2997
3045
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -3154,8 +3202,8 @@ input.tab:checked + .tab-content,
3154
3202
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
3155
3203
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
3156
3204
  }
3157
- .peer:hover ~ .peer-hover\:block {
3158
- display: block;
3205
+ .peer:hover ~ .peer-hover\:visible {
3206
+ visibility: visible;
3159
3207
  }.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08)}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
3160
3208
  /*rtl:begin:ignore*/left:0/*
3161
3209
  /*rtl:end:ignore*/}/*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
package/src/constants.ts CHANGED
@@ -2,5 +2,6 @@ export const LAPIS_URL = 'https://lapis.cov-spectrum.org/open/v2';
2
2
 
3
3
  export const AGGREGATED_ENDPOINT = `${LAPIS_URL}/sample/aggregated`;
4
4
  export const NUCLEOTIDE_MUTATIONS_ENDPOINT = `${LAPIS_URL}/sample/nucleotideMutations`;
5
+ export const AMINO_ACID_MUTATIONS_ENDPOINT = `${LAPIS_URL}/sample/aminoAcidMutations`;
5
6
  export const NUCLEOTIDE_INSERTIONS_ENDPOINT = `${LAPIS_URL}/sample/nucleotideInsertions`;
6
7
  export const REFERENCE_GENOME_ENDPOINT = `${LAPIS_URL}/sample/referenceGenome`;
@@ -7,6 +7,15 @@ const meta: Meta<TooltipProps> = {
7
7
  title: 'Component/Tooltip',
8
8
  component: Tooltip,
9
9
  parameters: { fetchMock: {} },
10
+ argTypes: {
11
+ content: { control: 'text' },
12
+ position: {
13
+ control: {
14
+ type: 'radio',
15
+ },
16
+ options: ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'right'],
17
+ },
18
+ },
10
19
  };
11
20
 
12
21
  export default meta;
@@ -17,12 +26,13 @@ export const TooltipStory: StoryObj<TooltipProps> = {
17
26
  render: (args) => (
18
27
  <div class='flex justify-center px-4 py-16'>
19
28
  <Tooltip {...args}>
20
- <div>Hover me</div>
29
+ <div className='bg-red-200'>Hover me</div>
21
30
  </Tooltip>
22
31
  </div>
23
32
  ),
24
33
  args: {
25
34
  content: tooltipContent,
35
+ position: 'bottom',
26
36
  },
27
37
  };
28
38
 
@@ -38,7 +48,7 @@ export const RendersStringContent: StoryObj<TooltipProps> = {
38
48
  },
39
49
  };
40
50
 
41
- export const RendersComponentConent: StoryObj<TooltipProps> = {
51
+ export const RendersComponentContent: StoryObj<TooltipProps> = {
42
52
  ...TooltipStory,
43
53
  args: {
44
54
  content: <div>{tooltipContent}</div>,
@@ -1,27 +1,51 @@
1
- import { flip, offset, shift } from '@floating-ui/dom';
2
1
  import { type FunctionComponent } from 'preact';
3
- import { useRef } from 'preact/hooks';
4
2
  import { type JSXInternal } from 'preact/src/jsx';
5
3
 
6
- import { dropdownClass } from './dropdown';
7
- import { useFloatingUi } from '../shared/floating-ui/hooks';
4
+ export type TooltipPosition =
5
+ | 'top'
6
+ | 'top-start'
7
+ | 'top-end'
8
+ | 'bottom'
9
+ | 'bottom-start'
10
+ | 'bottom-end'
11
+ | 'left'
12
+ | 'right';
8
13
 
9
14
  export type TooltipProps = {
10
15
  content: string | JSXInternal.Element;
16
+ position?: TooltipPosition;
11
17
  };
12
18
 
13
- const Tooltip: FunctionComponent<TooltipProps> = ({ children, content }) => {
14
- const referenceRef = useRef<HTMLDivElement>(null);
15
- const floatingRef = useRef<HTMLDivElement>(null);
16
-
17
- useFloatingUi(referenceRef, floatingRef, [offset(5), shift(), flip()]);
19
+ function getPositionCss(position?: TooltipPosition) {
20
+ switch (position) {
21
+ case 'top':
22
+ return 'bottom-full translate-x-[-50%] left-1/2 mb-1';
23
+ case 'top-start':
24
+ return 'bottom-full mr-1 mb-1';
25
+ case 'top-end':
26
+ return 'bottom-full right-0 ml-1 mb-1';
27
+ case 'bottom':
28
+ return 'top-full translate-x-[-50%] left-1/2 mt-1';
29
+ case 'bottom-start':
30
+ return 'mr-1 mt-1';
31
+ case 'bottom-end':
32
+ return 'right-0 ml-1 mt-1';
33
+ case 'left':
34
+ return 'right-full translate-y-[-50%] top-1/2 mr-1';
35
+ case 'right':
36
+ return 'left-full translate-y-[-50%] top-1/2 ml-1';
37
+ case undefined:
38
+ return '';
39
+ }
40
+ }
18
41
 
42
+ const Tooltip: FunctionComponent<TooltipProps> = ({ children, content, position = 'bottom' }) => {
19
43
  return (
20
44
  <div className='relative'>
21
- <div className='peer' ref={referenceRef}>
22
- {children}
23
- </div>
24
- <div ref={floatingRef} className={`${dropdownClass} hidden peer-hover:block`}>
45
+ <div className='peer'>{children}</div>
46
+ <div
47
+ className={`absolute z-10 w-max bg-white p-4 border border-gray-200 rounded-md invisible peer-hover:visible ${getPositionCss(position)}`}
48
+ >
25
49
  {content}
26
50
  </div>
27
51
  </div>
@@ -0,0 +1,38 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "count": 447,
5
+ "date": "2024-01-20"
6
+ },
7
+ {
8
+ "count": 1096,
9
+ "date": "2024-01-22"
10
+ },
11
+ {
12
+ "count": 1008,
13
+ "date": "2024-01-23"
14
+ },
15
+ {
16
+ "count": 526,
17
+ "date": "2024-01-21"
18
+ },
19
+ {
20
+ "count": 866,
21
+ "date": "2024-01-24"
22
+ },
23
+ {
24
+ "count": 819,
25
+ "date": "2024-01-25"
26
+ },
27
+ {
28
+ "count": 622,
29
+ "date": "2024-01-26"
30
+ }
31
+ ],
32
+ "info": {
33
+ "dataVersion": "1721588457",
34
+ "requestId": "4181b443-024d-4520-a68b-a4f0e2249d3a",
35
+ "requestInfo": "sars_cov-2_nextstrain_open on lapis.cov-spectrum.org at 2024-07-22T16:24:29.959383752",
36
+ "reportTo": "Please report to https://github.com/GenSpectrum/LAPIS/issues in case you encounter any unexpected issues. Please include the request ID and the requestInfo in your report."
37
+ }
38
+ }
@@ -0,0 +1,122 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "count": 622,
5
+ "date": "2024-01-26"
6
+ },
7
+ {
8
+ "count": 819,
9
+ "date": "2024-01-25"
10
+ },
11
+ {
12
+ "count": 683,
13
+ "date": "2024-02-02"
14
+ },
15
+ {
16
+ "count": 526,
17
+ "date": "2024-01-21"
18
+ },
19
+ {
20
+ "count": 580,
21
+ "date": "2024-01-19"
22
+ },
23
+ {
24
+ "count": 434,
25
+ "date": "2024-01-27"
26
+ },
27
+ {
28
+ "count": 947,
29
+ "date": "2024-01-30"
30
+ },
31
+ {
32
+ "count": 831,
33
+ "date": "2024-01-18"
34
+ },
35
+ {
36
+ "count": 447,
37
+ "date": "2024-01-20"
38
+ },
39
+ {
40
+ "count": 803,
41
+ "date": "2024-02-01"
42
+ },
43
+ {
44
+ "count": 332,
45
+ "date": "2024-02-11"
46
+ },
47
+ {
48
+ "count": 967,
49
+ "date": "2024-01-17"
50
+ },
51
+ {
52
+ "count": 993,
53
+ "date": "2024-02-06"
54
+ },
55
+ {
56
+ "count": 714,
57
+ "date": "2024-02-08"
58
+ },
59
+ {
60
+ "count": 1008,
61
+ "date": "2024-01-23"
62
+ },
63
+ {
64
+ "count": 381,
65
+ "date": "2024-02-10"
66
+ },
67
+ {
68
+ "count": 914,
69
+ "date": "2024-01-31"
70
+ },
71
+ {
72
+ "count": 1071,
73
+ "date": "2024-01-29"
74
+ },
75
+ {
76
+ "count": 402,
77
+ "date": "2024-01-28"
78
+ },
79
+ {
80
+ "count": 408,
81
+ "date": "2024-02-04"
82
+ },
83
+ {
84
+ "count": 966,
85
+ "date": "2024-02-05"
86
+ },
87
+ {
88
+ "count": 901,
89
+ "date": "2024-01-15"
90
+ },
91
+ {
92
+ "count": 866,
93
+ "date": "2024-01-24"
94
+ },
95
+ {
96
+ "count": 936,
97
+ "date": "2024-01-16"
98
+ },
99
+ {
100
+ "count": 836,
101
+ "date": "2024-02-07"
102
+ },
103
+ {
104
+ "count": 1096,
105
+ "date": "2024-01-22"
106
+ },
107
+ {
108
+ "count": 636,
109
+ "date": "2024-02-09"
110
+ },
111
+ {
112
+ "count": 438,
113
+ "date": "2024-02-03"
114
+ }
115
+ ],
116
+ "info": {
117
+ "dataVersion": "1721588457",
118
+ "requestId": "52863f95-fe58-427e-8010-b11ffa5600ce",
119
+ "requestInfo": "sars_cov-2_nextstrain_open on lapis.cov-spectrum.org at 2024-07-22T16:17:18.523742468",
120
+ "reportTo": "Please report to https://github.com/GenSpectrum/LAPIS/issues in case you encounter any unexpected issues. Please include the request ID and the requestInfo in your report."
121
+ }
122
+ }