-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-viz): highcharts a11y (#4053)
* feat(data-viz): initial modules impl * chore(website): fix typos in variables * fix(docs): ignore case sensitivity on getFeature * feat(docs-viz): add documentation * chore(data-viz): changeset * chore(docs): typos * chore(data-viz): disable chromatic checks and add aria desc * chore(data-viz): changeset * chore(data-viz): test update * chore(pr): linting issues * chore(pr): address comments * Update packages/paste-website/src/pages/foundations/data-visualization/index.mdx Co-authored-by: Sarah <[email protected]> * chore(pr): address comments --------- Co-authored-by: Sarah <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
26e425a
commit b20a3a1
Showing
21 changed files
with
214 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/data-visualization-library": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[Data Visualization]: added a new helper function, applyPasteHighchartsModules, that applies any number of modules to Highcharts setting accesibility required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/paste-libraries/data-visualization/__test__/modules.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { applyPasteHighchartsModules } from "../src"; | ||
|
||
type MockHighcarts = { | ||
modules: Set<string>; | ||
}; | ||
|
||
let mockHighcarts: MockHighcarts; | ||
|
||
const a11yModule = (highcharts: MockHighcarts): void => { | ||
highcharts.modules.add("accessibility"); | ||
}; | ||
|
||
const exportingModule = (highcharts: MockHighcarts): void => { | ||
highcharts.modules.add("exporting"); | ||
}; | ||
|
||
const sankeyModule = (highcharts: MockHighcarts): void => { | ||
highcharts.modules.add("sankeyModule"); | ||
}; | ||
|
||
describe("applyPasteHighchartsModules hook", () => { | ||
beforeEach(() => { | ||
mockHighcarts = { | ||
modules: new Set(), | ||
}; | ||
}); | ||
|
||
it("should fail when Highcarts is not present", () => { | ||
expect(applyPasteHighchartsModules).toThrow( | ||
"[applyPasteHighchartsModules]: Must provide highcharts into this function.", | ||
); | ||
}); | ||
|
||
it("should apply modules", () => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
applyPasteHighchartsModules(mockHighcarts, a11yModule, exportingModule, sankeyModule); | ||
expect(mockHighcarts.modules).toEqual(new Set(["accessibility", "exporting", "sankeyModule"])); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/paste-libraries/data-visualization/src/applyPasteHighchartsModules.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Highcharts from "highcharts"; | ||
|
||
/** | ||
* A hook to apply any Highcharts modules iwth accessibility being mandatory. | ||
*/ | ||
export const applyPasteHighchartsModules = ( | ||
highcharts: typeof Highcharts, | ||
accessibilityModule: (highcharts: typeof Highcharts) => void, | ||
...rest: Array<(highcharts: typeof Highcharts) => void> | ||
): void => { | ||
if (highcharts === undefined) { | ||
throw new Error("[applyPasteHighchartsModules]: Must provide highcharts into this function."); | ||
} | ||
|
||
if (accessibilityModule === undefined) { | ||
throw new Error( | ||
'[applyPasteHighchartsModules]: Must provide accessibility module into this function. You can do this using `import HighchartsAccessibility Module from "highcharts/modules/accessibility"`', | ||
); | ||
} | ||
|
||
accessibilityModule(highcharts); | ||
rest.forEach((module) => module(highcharts)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { usePasteHighchartsTheme } from "./usePasteHighchartsTheme"; | ||
export { applyPasteHighchartsModules } from "./applyPasteHighchartsModules"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.