Skip to content

Commit

Permalink
feat(components): add react support
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Sep 25, 2024
1 parent 6677533 commit 32bf97d
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 6 deletions.
10 changes: 10 additions & 0 deletions components/src/web-components/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { provide } from '@lit/context';
import { Task } from '@lit/task';
import { html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { lapisContext } from './lapis-context';
import { referenceGenomeContext } from './reference-genome-context';
Expand Down Expand Up @@ -74,3 +75,12 @@ declare global {
'gs-app': App;
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-app': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}
10 changes: 10 additions & 0 deletions components/src/web-components/input/gs-date-range-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { DateRangeSelector, type DateRangeSelectorProps } from '../../preact/dateRangeSelector/date-range-selector';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -126,6 +127,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-date-range-selector': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type CustomSelectOptionsMatches = Expect<
Equals<
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/input/gs-lineage-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { LineageFilter, type LineageFilterProps } from '../../preact/lineageFilter/lineage-filter';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -79,6 +80,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-lineage-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type InitialValueMatches = Expect<
Equals<typeof LineageFilterComponent.prototype.initialValue, LineageFilterProps['initialValue']>
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/input/gs-location-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { LocationFilter, type LocationFilterProps } from '../../preact/locationFilter/location-filter';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -88,6 +89,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-location-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type InitialValueMatches = Expect<
Equals<typeof LocationFilterComponent.prototype.initialValue, LocationFilterProps['initialValue']>
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/input/gs-mutation-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { ReferenceGenomesAwaiter } from '../../preact/components/ReferenceGenomesAwaiter';
import {
Expand Down Expand Up @@ -111,6 +112,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type InitialValueMatches = Expect<
Equals<typeof MutationFilterComponent.prototype.initialValue, MutationFilterProps['initialValue']>
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/input/gs-text-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { TextInput, type TextInputProps } from '../../preact/textInput/text-input';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -73,6 +74,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-text-input-changed': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type InitialValueMatches = Expect<
Equals<typeof TextInputComponent.prototype.initialValue, TextInputProps['initialValue']>
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/visualization/gs-aggregate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import type { DetailedHTMLProps, HTMLAttributes } from 'react';

import { Aggregate, type AggregateProps, type View } from '../../preact/aggregatedData/aggregate';
import { type LapisFilter } from '../../types';
Expand Down Expand Up @@ -104,6 +105,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-aggregate-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type FieldsMatches = Expect<Equals<typeof AggregateComponent.prototype.fields, AggregateProps['fields']>>;
type ViewsMatches = Expect<Equals<typeof AggregateComponent.prototype.views, AggregateProps['views']>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { MutationComparison, type MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -102,6 +103,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type LapisFiltersMatches = Expect<
Equals<typeof MutationComparisonComponent.prototype.lapisFilters, MutationComparisonProps['lapisFilters']>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { MutationsOverTime, type MutationsOverTimeProps } from '../../preact/mutationsOverTime/mutations-over-time';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -104,6 +105,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutations-over-time-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type LapisFilterMatches = Expect<
Equals<typeof MutationsOverTimeComponent.prototype.lapisFilter, MutationsOverTimeProps['lapisFilter']>
Expand Down
10 changes: 10 additions & 0 deletions components/src/web-components/visualization/gs-mutations.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { Mutations, type MutationsProps } from '../../preact/mutations/mutations';
import type { Equals, Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -96,6 +97,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-mutations-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type LapisFilterMatches = Expect<
Equals<typeof MutationsComponent.prototype.lapisFilter, MutationsProps['lapisFilter']>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import {
NumberSequencesOverTime,
Expand Down Expand Up @@ -124,6 +125,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type LapisFilterMatches = Expect<
Equals<typeof NumberSequencesOverTimeComponent.prototype.lapisFilter, NumberSequencesOverTimeProps['lapisFilter']>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import { PrevalenceOverTime, type PrevalenceOverTimeProps } from '../../preact/prevalenceOverTime/prevalence-over-time';
import { type Equals, type Expect } from '../../utils/typeAssertions';
Expand Down Expand Up @@ -187,6 +188,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type NumeratorMatches = Expect<
Equals<typeof PrevalenceOverTimeComponent.prototype.numeratorFilter, PrevalenceOverTimeProps['numeratorFilter']>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { customElement, property } from 'lit/decorators.js';
import { type DetailedHTMLProps, type HTMLAttributes } from 'react';

import {
RelativeGrowthAdvantage,
Expand Down Expand Up @@ -143,6 +144,15 @@ declare global {
}
}

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}

/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */
type NumeratorMatches = Expect<
Equals<
Expand Down
12 changes: 6 additions & 6 deletions examples/React/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ function App() {
fields='["region", "country", "division", "location"]'
></gs-location-filter>
<gs-date-range-selector initialValue='last6Months'></gs-date-range-selector>
<div style={{display: 'flex', flexDirection: 'row'}}>
<div style={{ display: 'flex', flexDirection: 'row' }}>
<div>
<h1 className="text-xl bold">Prevalence over time</h1>
<h1 className='text-xl bold'>Prevalence over time</h1>
<gs-prevalence-over-time
numeratorFilter={JSON.stringify(numerator)}
denominatorFilter={JSON.stringify(denominator)}
Expand All @@ -74,8 +74,8 @@ function App() {
height='300px'
></gs-prevalence-over-time>
</div>
<div style={{height: '300px', width: '1000px'}}>
<h1 className="text-xl bold">Prevalence over time</h1>
<div style={{ height: '300px', width: '1000px' }}>
<h1 className='text-xl bold'>Prevalence over time</h1>
<gs-prevalence-over-time
numeratorFilter={JSON.stringify(numerator)}
denominatorFilter={JSON.stringify(denominator)}
Expand All @@ -87,7 +87,7 @@ function App() {
></gs-prevalence-over-time>
</div>
</div>
<h1 className="text-xl bold">Prevalence over time</h1>
<h1 className='text-xl bold'>Prevalence over time</h1>
<div>
<gs-prevalence-over-time
numeratorFilter={JSON.stringify(numerator)}
Expand All @@ -97,7 +97,7 @@ function App() {
views='["line", "table"]'
></gs-prevalence-over-time>
</div>
<h1 className="text-xl bold">Relative Growth Advantage</h1>
<h1 className='text-xl bold'>Relative Growth Advantage</h1>
<gs-relative-growth-advantage
numeratorFilter='{ "country": "Switzerland", "pangoLineage": "B.1.1.7", "dateFrom": "2020-12-01" }'
denominatorFilter='{ "country": "Switzerland", "dateFrom": "2020-12-01" }'
Expand Down

0 comments on commit 32bf97d

Please sign in to comment.