Skip to content

Commit

Permalink
Move AltText type to core; update provenance actions for alttext
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Lanza committed May 24, 2024
1 parent 8b6ddcb commit f0de458
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ sketch
/docs/

# End of https://www.toptal.com/developers/gitignore/api/react,node,joed
.turbo/cookies/0.cookie
47 changes: 38 additions & 9 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ export type Meta = {
*/
export type PlotInformation = {
/** User-generated plot description */
description: string;
description?: string;
/** User-generated name to use for sets in the plot (ie "genres") */
sets: string;
sets?: string;
/** User-generated name for items in the dataset (ie "movies") */
items: string;
items?: string;
/** User-defined plot title */
title?: string;
/** User-defined plot caption (for sighted users) */
caption?: string;
/** Short user-defined plot alttxt (replaces the autogenerated shortDescription) */
userShortText?: string;
/** Long user-defined plot alttxt (replaces the autogenerated longDescription) */
userLongText?: string;
};

export type RowType =
Expand Down Expand Up @@ -226,6 +234,32 @@ export type Plot = Scatterplot | Histogram;

export type Bookmark = { id: string; label: string; size: number }

/**
* Represents the alternative text for an Upset plot.
*/
export type AltText = {
/**
* The long description for the Upset plot.
*/
longDescription: string;

/**
* The short description for the Upset plot.
*/
shortDescription: string;

/**
* The technique description for the Upset plot.
*/
techniqueDescription: string;

/**
* Optional warnings for the Upset plot.
* Not yet implemented by the API as of 4/22/24
*/
warnings?: string;
}

export type UpsetConfig = {
plotInformation: PlotInformation;
horizontal: boolean;
Expand All @@ -252,12 +286,7 @@ export type UpsetConfig = {
};
allSets: Column[];
selected: Row | null;
/** User-defined plot title */
title?: string;
/** User-defined plot caption (for sighted users) */
caption?: string;
/** User-defined plot alttxt (replaces the autogenerated alttxt; for low-vision users) */
userAltText?: string;
userAltText?: AltText;
};

export type AccessibleDataEntry = {
Expand Down
38 changes: 5 additions & 33 deletions packages/upset/src/provenance/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import {
AggregateBy, Plot, PlotInformation, SortBy, SortByOrder, SortVisibleBy, UpsetConfig, DefaultConfig, Row
AggregateBy, Plot, PlotInformation, SortBy, SortByOrder, SortVisibleBy, UpsetConfig, DefaultConfig, Row,
AltText
} from '@visdesignlab/upset2-core';

import { Registry, initializeTrrack } from '@trrack/core';
Expand Down Expand Up @@ -296,30 +297,9 @@ const setSelectedAction = registry.register(
},
);

/**
* Sets the plotInformation title string
*/
const setTitleAction = registry.register(
'set-title',
(state: UpsetConfig, title) => {
state.title = title;
return state;
}
)

/**
* Sets the plotInformation caption string
*/
const setCaptionAction = registry.register(
'set-caption',
(state: UpsetConfig, caption) => {
state.caption = caption;
return state;
}
);

/**
* Sets the alt text for the user
* @param {AltText} altText The alt text to set
*/
const setUserAltTextAction = registry.register(
'set-user-alt-text',
Expand Down Expand Up @@ -385,16 +365,8 @@ export function getActions(provenance: UpsetProvenance) {
'Deselect intersection',
setSelectedAction(intersection)
),
setTitle: (title: string | null) => provenance.apply(
title ? `Set title to "${title}"` : "Cleared title",
setTitleAction(title)
),
setCaption: (caption: string | null) => provenance.apply(
caption ? `Set caption to "${caption}"` : "Cleared caption",
setCaptionAction(caption)
),
setUserAltText: (altText: string | null) => provenance.apply(
altText ? `Set user alt text to "${altText}"` : "Cleared user alt text",
setUserAltText: (altText: AltText | null) => provenance.apply(
altText ? `Set user alt text` : "Cleared user alt text",
setUserAltTextAction(altText)
),
};
Expand Down
26 changes: 0 additions & 26 deletions packages/upset/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,6 @@
import { CoreUpsetData, UpsetConfig } from '@visdesignlab/upset2-core';
import { UpsetProvenance, UpsetActions } from './provenance';

/**
* Represents the alternative text for an Upset plot.
*/
export interface AltText {
/**
* The long description for the Upset plot.
*/
longDescription: string;

/**
* The short description for the Upset plot.
*/
shortDescription: string;

/**
* The technique description for the Upset plot.
*/
techniqueDescription: string;

/**
* Optional warnings for the Upset plot.
* Not yet implemented by the API as of 4/22/24
*/
warnings?: string;
}

export type ContextMenuItem = {
/**
* The label for the context menu item.
Expand Down

0 comments on commit f0de458

Please sign in to comment.