Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic implementation for navigation among palette layers (resolves #5) #6

Merged
merged 39 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7105026
feat: select from a set of palettes
klown Oct 30, 2023
6f25a5f
fix: palette json definition files for "people" and "myfamily"
klown Oct 31, 2023
0adab7b
Merge branch 'feat/create-palette-from-json' into MultiPalettes
klown Nov 3, 2023
f7530a8
feat: added main "palette of palettes" for choosing other palettes
klown Nov 13, 2023
f01e7e0
Merge branch 'feat/create-palette-from-json' into MultiPalettes
klown Nov 20, 2023
094f434
fix: actually add the new `ActionBranchToPalette` component
klown Nov 21, 2023
e43465c
Merge branch 'feat/create-palette-from-json' into MultiPalettes
klown Nov 28, 2023
5e3743f
Merge branch 'feat/create-palette-from-json' into MultiPalettes
klown Nov 30, 2023
4752e51
Merge branch 'feat/create-palette-from-json' into MultiPalettes
klown Dec 19, 2023
4305b13
Merge branch 'main' into MultiPalettes
klown Dec 20, 2023
d5df467
feat: load palette json files when clicking on palette selection cells
klown Dec 20, 2023
10a95a8
chore: add note about "singing" palette cell as a test
klown Dec 20, 2023
30b570a
Merge branch 'feat/create-bmw-encoding' into multipaletteAndOutput
klown Jan 17, 2024
4c91168
chore: modify to work with branch feat/create-bmw-encoding
klown Jan 19, 2024
10e33c5
fix: use "isPresentational" for the symbols in the content display area
klown Jan 22, 2024
a73e48a
chore: modfiy palette json to expand to fit the display
klown Jan 24, 2024
7201c22
Merge branch 'feat/create-bmw-encoding' into multipaletteAndOutput
klown Jan 26, 2024
9555c79
feat: implement basic navigation/layer tracking with back button
klown Jan 30, 2024
0357a3c
Merge branch 'feat/create-bmw-encoding' into multipaletteAndOutput
klown Feb 1, 2024
15b899f
fix: change style class of "back button" to be a command style
klown Feb 1, 2024
4594254
Merge branch 'main' into multipaletteAndOutput
klown Feb 1, 2024
a7c6d83
feat: unit tests for basic navigation/layer tracking
klown Feb 5, 2024
8776a1b
feat: implement navigation by layers (demo)
klown Feb 9, 2024
82d7cd6
feat: implement lazy loading of palettes as needed
klown Feb 9, 2024
08d262c
fix: add style file for ActionBranchToPalette component
klown Feb 12, 2024
1ea48b5
fix: make names of cells consistent
klown Feb 12, 2024
de1028a
feat: test that back button can be in verious locations
klown Feb 12, 2024
84ca4f6
fix: replace fetch() with import() for accessing local files.
klown Feb 20, 2024
946ee4e
fix: implement dynamic `import()` based on restrictions
klown Feb 21, 2024
44c960c
feat: implement the ability to peek at the bottom of the NavigationStack
klown Feb 26, 2024
b30c693
feat: add tests of the handlers for "go-to" and "go-back" cells
klown Feb 26, 2024
bdf503a
feat: store id of main palette area in global data for go-back naviga…
klown Feb 29, 2024
3b832fd
fix: move `importPaletteFromJsonFile()` from `GlobalData.ts` to `Glob…
klown Mar 1, 2024
7380960
fix: format a comment properly
klown Mar 1, 2024
4f7cc54
fix: use bliss letters "BMW" for bliss symbol for BWM go-to-palette b…
klown Mar 6, 2024
49a10b0
feat: define return types for all functions
klown Mar 8, 2024
4e3a17f
feat: implement aria-controls for clear and delete cells
klown Mar 11, 2024
13b87f7
feat: rename "keyboards" folder to "palettes"
klown Mar 11, 2024
2e4c520
feat: decompose types into reusable parts and combine as appropriate
klown Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
<title>Adaptive Palette</title>
</head>
<body>
<h2>Palette Based on JSON</h1>
<div id="bmwKeyCodes">
<h2>Palettes Based on JSON</h1>
<div id="outputArea">
<div id="output_palette"></div>
</div>
<div id="backupArea">
<div id="backup_palette"></div>
</div>
<div id="mainPaletteDisplayArea">
<script type="module">
import "./src/index.js";
</script>
Expand Down
6 changes: 3 additions & 3 deletions src/ActionBmwCodeCell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { html } from "htm/preact";
import { initAdaptivePaletteGlobals } from "./GlobalData";
import { ActionBmwCodeCell } from "./ActionBmwCodeCell";

describe("ActionBmwCodeDell render tests", () => {
describe("ActionBmwCodeDell render tests", (): void => {

const TEST_CELL_ID = "uuid-of-some-kind";
const testCell = {
Expand All @@ -30,11 +30,11 @@ describe("ActionBmwCodeDell render tests", () => {
}
};

beforeAll(async () => {
beforeAll(async (): Promise<void> => {
await initAdaptivePaletteGlobals();
});

test("Single ActionBmwCodeCell rendering", async () => {
test("Single ActionBmwCodeCell rendering", async (): Promise<void> => {

render(html`
<${ActionBmwCodeCell}
Expand Down
7 changes: 4 additions & 3 deletions src/ActionBmwCodeCell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

import { VNode } from "preact";
import { html } from "htm/preact";
import { BlissSymbolCellType } from "./index.d";
import { BlissSymbolInfoType, LayoutInfoType } from "./index.d";
import { BlissSymbol } from "./BlissSymbol";
import { usePaletteState } from "./GlobalData";
import { generateGridStyle, speak } from "./GlobalUtils";
Expand All @@ -19,10 +20,10 @@ import "./ActionBmwCodeCell.scss";

type ActionBmwCodeCellPropsType = {
id: string,
options: BlissSymbolCellType
options: BlissSymbolInfoType & LayoutInfoType
};

export function ActionBmwCodeCell (props: ActionBmwCodeCellPropsType) {
export function ActionBmwCodeCell (props: ActionBmwCodeCellPropsType): VNode {
const paletteState = usePaletteState();

const {
Expand Down
17 changes: 17 additions & 0 deletions src/ActionBranchToPaletteCell.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* You may obtain a copy of the License at
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

.actionBranchToPaletteCell {
border: 2px solid blue;
background-color: chartreuse;
padding-inline: 0.5rem;
text-align: center;
}
65 changes: 65 additions & 0 deletions src/ActionBranchToPaletteCell.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* You may obtain a copy of the License at
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

import { render, screen } from "@testing-library/preact";
import "@testing-library/jest-dom";
import { html } from "htm/preact";

import { initAdaptivePaletteGlobals } from "./GlobalData";
import { ActionBranchToPaletteCell } from "./ActionBranchToPaletteCell";

describe("ActionBranchToPaletteCell render tests", (): void => {

const TEST_CELL_ID = "uuid-of-some-kind";
const goToPaletteCell = {
options: {
"label": "Animals",
"branchTo": "Animals",
"rowStart": "100",
"rowSpan": "12",
"columnStart": "33",
"columnSpan": "11",
"bciAvId": [ 16161, "/", 9011 ]
}
};

beforeAll(async () => {
await initAdaptivePaletteGlobals();
});

test("ActionBranchToPaletteCell rendering", async (): Promise<void> => {

render(html`
<${ActionBranchToPaletteCell}
id="${TEST_CELL_ID}"
options=${goToPaletteCell.options}
/>`
);

// Check the rendered cell
const button = await screen.findByRole("button", {name: goToPaletteCell.options.label});

// Check that the ActionBmwCodeCell/button is rendered and has the correct
// attributes and text.
expect(button).toBeVisible();
expect(button).toBeValid();
expect(button.id).toBe(TEST_CELL_ID);
expect(button.getAttribute("class")).toBe("actionBranchToPaletteCell");
expect(button.textContent).toBe(goToPaletteCell.options.label);

// Check the grid cell styles.
expect(button.style["grid-column"]).toBe(`${goToPaletteCell.options.columnStart} / span ${goToPaletteCell.options.columnSpan}`);
expect(button.style["grid-row"]).toBe(`${goToPaletteCell.options.rowStart} / span ${goToPaletteCell.options.rowSpan}`);

// Check disabled state (should be enabled)
expect(button.getAttribute("disabled")).toBe(null);
});
});
66 changes: 66 additions & 0 deletions src/ActionBranchToPaletteCell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* You may obtain a copy of the License at
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

import { render, VNode } from "preact";
import { html } from "htm/preact";
import { BlissSymbolCellType } from "./index.d";
import { adaptivePaletteGlobals } from "./GlobalData";
import { importPaletteFromJsonFile } from "./GlobalUtils";
import { Palette } from "./Palette";
import { BlissSymbol } from "./BlissSymbol";
import { speak } from "./GlobalUtils";
import "./ActionBranchToPaletteCell.scss";

type ActionBranchToPalettePropsType = {
id: string,
options: BlissSymbolCellType
};

/*
* Event handler for an ActionBranchToPaletteCell button/cell that, when clicked,
* finds and renders the palette referenced by this cell.
*/
const navigateToPalette = async (event: Event): Promise<void> => {
const { paletteStore, navigationStack } = adaptivePaletteGlobals;
const button = event.currentTarget as HTMLElement;
speak(button.innerText);

const branchToPaletteName = button.getAttribute("data-branchto");
const paletteDefinition = await paletteStore.getNamedPalette(branchToPaletteName, importPaletteFromJsonFile);
if (paletteDefinition) {
const displayElement = button.parentElement.parentElement;
navigationStack.push(navigationStack.currentPalette);
render (html`<${Palette} json=${paletteDefinition}/>`, displayElement);
navigationStack.currentPalette = paletteDefinition;
}
else {
console.error(`navigateToPalette(): Unable to locate the palette definition for ${branchToPaletteName}`);
}
};

export function ActionBranchToPaletteCell (props: ActionBranchToPalettePropsType): VNode {
const {
columnStart, columnSpan, rowStart, rowSpan, branchTo, bciAvId, label
} = props.options;

const gridStyles = `
grid-column: ${columnStart} / span ${columnSpan};
grid-row: ${rowStart} / span ${rowSpan};
`;

return html`
<button
id="${props.id}" class="actionBranchToPaletteCell" style="${gridStyles}"
data-branchto="${branchTo}" onClick=${navigateToPalette}>
<${BlissSymbol} bciAvId=${bciAvId} label=${label} />
</button>
`;
}
12 changes: 6 additions & 6 deletions src/BlissSymbol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { html } from "htm/preact";
import { initAdaptivePaletteGlobals } from "./GlobalData";
import { BlissSymbol, GRAPHIC_ROLE } from "./BlissSymbol";

describe("BlissSymbol render tests", () => {
describe("BlissSymbol render tests", (): void => {
const singleBciAvId = {
bciAvId: 12335,
label: "VERB"
Expand All @@ -34,7 +34,7 @@ describe("BlissSymbol render tests", () => {
await initAdaptivePaletteGlobals();
});

test(`BlissSymbol defined by a single BCI_AV_ID (${singleBciAvId.label})`, async () => {
test(`BlissSymbol defined by a single BCI_AV_ID (${singleBciAvId.label})`, async (): Promise<void> => {
render(html`
<${BlissSymbol}
bciAvId="${singleBciAvId.bciAvId}"
Expand All @@ -52,7 +52,7 @@ describe("BlissSymbol render tests", () => {
expect(parentChildren[0].nodeName).toBe("svg");
});

test("BlissSymbol when the SVG is unknown", async () => {
test("BlissSymbol when the SVG is unknown", async (): Promise<void> => {
render(html`
<${BlissSymbol}
bciAvId="${UNKNOWN_BCI_AV_ID}"
Expand All @@ -67,7 +67,7 @@ describe("BlissSymbol render tests", () => {
expect(svgElement).toBe(null);
});

test(`BlissSymbol defined by an of BCI_AV_IDs (${arrayBciAvId.label})`, async () => {
test(`BlissSymbol defined by an of BCI_AV_IDs (${arrayBciAvId.label})`, async (): Promise<void> => {
render(html`
<${BlissSymbol}
bciAvId="${arrayBciAvId.bciAvId}"
Expand All @@ -83,7 +83,7 @@ describe("BlissSymbol render tests", () => {
expect(parentChildren[0].nodeName).toBe("svg");
});

test("BlissSymbol aria: when svg has no role)", async () => {
test("BlissSymbol aria: when svg has no role)", async (): Promise<void> => {
render(html`
<${BlissSymbol}
bciAvId="${arrayBciAvId.bciAvId}"
Expand All @@ -98,7 +98,7 @@ describe("BlissSymbol render tests", () => {
expect(svgElement.getAttribute("aria-labelledby")).toBe(null);
});

test("BlissSymbol aria: when svg has a graphic role)", async () => {
test("BlissSymbol aria: when svg has a graphic role)", async (): Promise<void> => {
render(html`
<${BlissSymbol}
bciAvId="${arrayBciAvId.bciAvId}"
Expand Down
5 changes: 3 additions & 2 deletions src/BlissSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

import { VNode } from "preact";
import { html } from "htm/preact";
import { getSvgElement } from "./SvgUtils";
import { BciAvIdType } from "./index.d";
Expand All @@ -26,7 +27,7 @@ type BlissSymbolPropsType = {
labelledBy?: string
}

export function BlissSymbol (props: BlissSymbolPropsType) {
export function BlissSymbol (props: BlissSymbolPropsType): VNode {
const { bciAvId, label, isPresentation, labelledBy } = props;
const svgElement = getSvgElement(bciAvId);

Expand All @@ -35,7 +36,7 @@ export function BlissSymbol (props: BlissSymbolPropsType) {
// Deal with aria markup, depending on whether the SVG is for presentation only or
// associates with a labelled area.
if (isPresentation === "true") {
svgElement.setAttribute("aria-hidden", true);
svgElement.setAttribute("aria-hidden", "true");
} else {
svgElement.setAttribute("role", `${GRAPHIC_ROLE}`);
svgElement.setAttribute("aria-labelledby", labelledBy);
Expand Down
10 changes: 7 additions & 3 deletions src/CommandClearEncoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { html } from "htm/preact";
import { initAdaptivePaletteGlobals } from "./GlobalData";
import { CommandClearEncoding } from "./CommandClearEncoding";

describe("CommandClearEncoding render tests", () => {
describe("CommandClearEncoding render tests", (): void => {

const TEST_CELL_ID = "command-del-last-encoding";
const testCell = {
Expand All @@ -26,15 +26,16 @@ describe("CommandClearEncoding render tests", () => {
"rowStart": 2,
"rowSpan": 1,
"columnStart": 14,
"columnSpan": 1
"columnSpan": 1,
"ariaControls": "content-area"
}
};

beforeAll(async () => {
await initAdaptivePaletteGlobals();
});

test("CommandClearEncoding rendering", async () => {
test("CommandClearEncoding rendering", async (): Promise<void> => {

render(html`
<${CommandClearEncoding}
Expand All @@ -58,6 +59,9 @@ describe("CommandClearEncoding render tests", () => {
expect(button.style["grid-column"]).toBe("14 / span 1");
expect(button.style["grid-row"]).toBe("2 / span 1");

// Check aria-controls
expect(button.getAttribute("aria-controls")).toBe(testCell.options.ariaControls);

// Check disabled state (should be enabled)
expect(button.getAttribute("disabled")).toBe(null);
});
Expand Down
22 changes: 15 additions & 7 deletions src/CommandClearEncoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,42 @@
* https://github.com/inclusive-design/adaptive-palette/blob/main/LICENSE
*/

import { VNode } from "preact";
import { html } from "htm/preact";
import { BlissSymbol } from "./BlissSymbol";
import { usePaletteState } from "./GlobalData";
import { BlissSymbolCellType } from "./index.d";
import { BlissSymbolInfoType, LayoutInfoType } from "./index.d";
import { generateGridStyle, speak } from "./GlobalUtils";

type CommandClearEncodingProps = {
id: string,
options: BlissSymbolCellType
options: BlissSymbolInfoType & LayoutInfoType & {
ariaControls: string
}
}

export function CommandClearEncoding (props: CommandClearEncodingProps) {
export function CommandClearEncoding (props: CommandClearEncodingProps): VNode {
const { id, options } = props;
const { label, bciAvId, columnStart, columnSpan, rowStart, rowSpan } = options;
const { label, bciAvId, columnStart, columnSpan, rowStart, rowSpan, ariaControls } = options;

const paletteState = usePaletteState();
const setFullEncoding = paletteState?.setFullEncoding;

const gridStyles = generateGridStyle(columnStart, columnSpan, rowStart, rowSpan);

const cellClicked = () => {
const cellClicked = (): void => {
setFullEncoding([]);
speak(label);
};

return html`
<button id="${id}" class="btn-command" style="${gridStyles}" onClick=${cellClicked}>
<${BlissSymbol} bciAvId=${bciAvId} label=${label}/>
<button
id="${id}"
class="btn-command"
style="${gridStyles}"
aria-controls=${ariaControls}
onClick=${cellClicked}>
<${BlissSymbol} bciAvId=${bciAvId} label=${label} />
</button>
`;
}
Loading
Loading