Skip to content

Commit

Permalink
Use typescript interfaces instead of classes
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Dec 19, 2024
1 parent 5358296 commit b45837b
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 143 deletions.
36 changes: 10 additions & 26 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { RibbonGroup, RibbonModel, RibbonSubject } from "./globals/models";
export { RibbonGroup, RibbonModel, RibbonSubject } from "./globals/models";
import { IRibbonGroup, IRibbonModel, IRibbonSubject } from "./globals/models";
export { IRibbonGroup, IRibbonModel, IRibbonSubject } from "./globals/models";
export namespace Components {
interface WcGoAutocomplete {
/**
Expand Down Expand Up @@ -129,13 +129,13 @@ export namespace Components {
binaryColor: boolean;
classLabels: string;
colorBy: number;
group: RibbonGroup;
group: IRibbonGroup;
hovered: boolean;
maxColor: string;
maxHeatLevel: number;
minColor: string;
selected: boolean;
subject: RibbonSubject;
subject: IRibbonSubject;
}
interface WcRibbonStrips {
/**
Expand Down Expand Up @@ -180,7 +180,7 @@ export namespace Components {
maxColor: string;
maxHeatLevel: number;
minColor: string;
ribbonSummary: RibbonModel;
ribbonSummary: IRibbonModel;
selectGroup: (group_id: any) => Promise<void>;
/**
* If no value is provided, the ribbon will load without any group selected. If a value is provided, the ribbon will show the requested group as selected The value should be the id of the group to be selected
Expand Down Expand Up @@ -210,15 +210,7 @@ export namespace Components {
}
interface WcRibbonSubject {
newTab: boolean;
subject: {
id: string;
label: string;
taxon_id: string;
taxon_label: string;
nb_classes: number;
nb_annotations: number;
groups: [{}];
};
subject: IRibbonSubject;
subjectBaseURL: string;
}
interface WcRibbonTable {
Expand Down Expand Up @@ -627,13 +619,13 @@ declare namespace LocalJSX {
binaryColor?: boolean;
classLabels?: string;
colorBy?: number;
group?: RibbonGroup;
group?: IRibbonGroup;
hovered?: boolean;
maxColor?: string;
maxHeatLevel?: number;
minColor?: string;
selected?: boolean;
subject?: RibbonSubject;
subject?: IRibbonSubject;
}
interface WcRibbonStrips {
/**
Expand Down Expand Up @@ -702,7 +694,7 @@ declare namespace LocalJSX {
* This event is triggered whenever the mouse leaves a group cell area
*/
onGroupLeave?: (event: WcRibbonStripsCustomEvent<any>) => void;
ribbonSummary?: RibbonModel;
ribbonSummary?: IRibbonModel;
/**
* If no value is provided, the ribbon will load without any group selected. If a value is provided, the ribbon will show the requested group as selected The value should be the id of the group to be selected
*/
Expand Down Expand Up @@ -735,15 +727,7 @@ declare namespace LocalJSX {
* This event is triggered whenever a subject label is clicked Can call preventDefault() to avoid the default behavior (opening the linked subject page)
*/
onSubjectClick?: (event: WcRibbonSubjectCustomEvent<any>) => void;
subject?: {
id: string;
label: string;
taxon_id: string;
taxon_label: string;
nb_classes: number;
nb_annotations: number;
groups: [{}];
};
subject?: IRibbonSubject;
subjectBaseURL?: string;
}
interface WcRibbonTable {
Expand Down
28 changes: 14 additions & 14 deletions src/components/go-ribbon-cell/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ------------------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------------- |
| `annotationLabels` | `annotation-labels` | | `string` | `"annotation,annotations"` |
| `available` | `available` | If set to true, won't show any color and can not be hovered or selected This is used for group that can not have annotation for a given subject | `boolean` | `true` |
| `binaryColor` | `binary-color` | | `boolean` | `false` |
| `classLabels` | `class-labels` | | `string` | `"term,terms"` |
| `colorBy` | `color-by` | | `number` | `COLOR_BY.CLASS_COUNT` |
| `group` | -- | | `RibbonGroup` | `undefined` |
| `hovered` | `hovered` | | `boolean` | `false` |
| `maxColor` | `max-color` | | `string` | `"24,73,180"` |
| `maxHeatLevel` | `max-heat-level` | | `number` | `48` |
| `minColor` | `min-color` | | `string` | `"255,255,255"` |
| `selected` | `selected` | | `boolean` | `false` |
| `subject` | -- | | `RibbonSubject` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ------------------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------------------------- |
| `annotationLabels` | `annotation-labels` | | `string` | `"annotation,annotations"` |
| `available` | `available` | If set to true, won't show any color and can not be hovered or selected This is used for group that can not have annotation for a given subject | `boolean` | `true` |
| `binaryColor` | `binary-color` | | `boolean` | `false` |
| `classLabels` | `class-labels` | | `string` | `"term,terms"` |
| `colorBy` | `color-by` | | `number` | `COLOR_BY.CLASS_COUNT` |
| `group` | -- | | `IRibbonGroup` | `undefined` |
| `hovered` | `hovered` | | `boolean` | `false` |
| `maxColor` | `max-color` | | `string` | `"24,73,180"` |
| `maxHeatLevel` | `max-heat-level` | | `number` | `48` |
| `minColor` | `min-color` | | `string` | `"255,255,255"` |
| `selected` | `selected` | | `boolean` | `false` |
| `subject` | -- | | `IRibbonSubject` | `undefined` |

## Dependencies

Expand Down
6 changes: 3 additions & 3 deletions src/components/go-ribbon-cell/ribbon-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Component, Prop, Element } from "@stencil/core";
import { heatColor, darken } from "./utils";
import { CELL_TYPES, COLOR_BY } from "../../globals/enums";

import { RibbonGroup, RibbonSubject } from "../../globals/models";
import { IRibbonGroup, IRibbonSubject } from "../../globals/models";
import { Watch } from "@stencil/core";

@Component({
Expand All @@ -16,8 +16,8 @@ import { Watch } from "@stencil/core";
export class RibbonCell {
@Element() el: HTMLElement;

@Prop() subject: RibbonSubject;
@Prop() group: RibbonGroup;
@Prop() subject: IRibbonSubject;
@Prop() group: IRibbonGroup;

@Prop() classLabels = "term,terms";
@Prop() annotationLabels = "annotation,annotations";
Expand Down
Loading

0 comments on commit b45837b

Please sign in to comment.