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: implement a content display area and associated buttons (resolves #2) #4

Merged
merged 33 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4a15121
feat: initial implementation of BMW encoding area
cindyli Oct 13, 2023
71498eb
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli Oct 13, 2023
ef00b17
feat: add the global message handler
cindyli Oct 14, 2023
a78a44c
fix: linted
cindyli Oct 14, 2023
834fa54
doc: improve code comments
cindyli Oct 14, 2023
2f415ea
doc: add code comments for GlobalMessageHandler
cindyli Oct 16, 2023
c848240
fix: add tests for ContentBmwEncoding and GlobalMessageHandler compon…
cindyli Oct 16, 2023
704bc14
Merge branch 'feat/add-cellType-registry' into feat/create-bmw-encoding
cindyli Oct 23, 2023
0dbbab5
fix: merge missing files in the previous commit
cindyli Oct 23, 2023
28c3577
fix: display proper BlissSymbol in encoding area
cindyli Oct 23, 2023
011502c
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli Oct 23, 2023
08c1c71
fix: adjust style
cindyli Oct 24, 2023
47bb906
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli Oct 24, 2023
df7cb68
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli Nov 2, 2023
b5ddde5
fix: improve css for Bliss symbols and fix tests
cindyli Nov 21, 2023
2f86063
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli Nov 21, 2023
c94e4aa
test: add tests for showing Bliss symbols in the content area
cindyli Nov 21, 2023
f079472
fix: add the type check for addBmwCode payload
cindyli Nov 22, 2023
77e4709
Merge branch 'main' into feat/create-bmw-encoding
cindyli Dec 20, 2023
f9f2921
feat: use preact context to coordinate the addition/removal/clearing …
cindyli Jan 3, 2024
a48c887
feat: add unit tests and integration tests
cindyli Jan 4, 2024
d9835ea
fix: improve styling
cindyli Jan 5, 2024
bbe43d3
fix: code clean up
cindyli Jan 5, 2024
bd77ddd
feat: announce the label of the selected Bliss symbol
cindyli Jan 10, 2024
5ad860d
fix: address review comments
cindyli Jan 23, 2024
241b738
fix: improve css of the grid palette
cindyli Jan 29, 2024
07aed46
fix: the width of the display area no longer changes when appending s…
cindyli Jan 29, 2024
e56aba6
fix: fix the palette test
cindyli Jan 29, 2024
4fbcf01
fix: the display area now has role="textbox"
cindyli Jan 29, 2024
16c2c36
fix: fix the test for ContentBmwEncoding
cindyli Jan 29, 2024
f14cbaa
fix: address more review comments
cindyli Jan 29, 2024
1f73831
fix: improve function comments and copyright messages
cindyli Jan 31, 2024
a1badc7
fix: improve a code comment
cindyli Feb 1, 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
1,861 changes: 1,114 additions & 747 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setupFetchForJest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand Down
13 changes: 3 additions & 10 deletions src/ActionBmwCodeCell.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand All @@ -11,14 +11,7 @@

.actionBmwCodeCell {
border: 2px solid blue;
background-color: gray;
border-radius: 5px;
padding: 1rem;
font-size: 1rem;
background-color: beige;
padding-inline: 0.5rem;
text-align: center;

&:hover, &:focus {
background-color: lightblue;
color: #0000aa;
}
}
2 changes: 1 addition & 1 deletion src/ActionBmwCodeCell.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand Down
28 changes: 20 additions & 8 deletions src/ActionBmwCodeCell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand All @@ -10,28 +10,40 @@
*/

import { html } from "htm/preact";
import { OptionsType } from "./index.d";
import { BlissSymbolCellType } from "./index.d";
import { BlissSymbol } from "./BlissSymbol";
import { usePaletteState } from "./GlobalData";
import { generateGridStyle, speak } from "./GlobalUtils";
import "./ActionBmwCodeCell.scss";


type ActionBmwCodeCellPropsType = {
id: string,
options: OptionsType
options: BlissSymbolCellType
};

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

const {
columnStart, columnSpan, rowStart, rowSpan, bciAvId, label
} = props.options;

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

const cellClicked = () => {
const payload = {
"id": props.id,
"label": props.options.label,
"bciAvId": props.options.bciAvId
};
const fullEncoding = paletteState.fullEncoding;
paletteState.setFullEncoding([...fullEncoding, payload]);
speak(props.options.label);
};

return html`
<button id="${props.id}" class="actionBmwCodeCell" style="${gridStyles}" >
<button id="${props.id}" class="actionBmwCodeCell" style="${gridStyles}" onClick=${cellClicked}>
<${BlissSymbol}
bciAvId=${bciAvId}
label=${label}
Expand Down
3 changes: 1 addition & 2 deletions src/BlissSymbol.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand Down Expand Up @@ -114,4 +114,3 @@ describe("BlissSymbol render tests", () => {
expect(svgElement.getAttribute("aria-hidden")).toBe(null);
});
});

5 changes: 3 additions & 2 deletions src/BlissSymbol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Inclusive Design Research Centre, OCAD University
* Copyright 2023-2024 Inclusive Design Research Centre, OCAD University
* All rights reserved.
*
* Licensed under the New BSD license. You may not use this file except in
Expand Down Expand Up @@ -32,7 +32,8 @@ export function BlissSymbol (props: BlissSymbolPropsType) {

let svgMarkupString = "";
if (svgElement) {
// Deal with aria markup, depending on whether the SVG
// 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);
} else {
Expand Down
65 changes: 65 additions & 0 deletions src/CommandClearEncoding.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 { CommandClearEncoding } from "./CommandClearEncoding";

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

const TEST_CELL_ID = "command-del-last-encoding";
const testCell = {
options: {
"label": "Clear",
"bciAvId": 13665,
"rowStart": 2,
"rowSpan": 1,
"columnStart": 14,
"columnSpan": 1
}
};

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

test("CommandClearEncoding rendering", async () => {

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

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

// Check that the CommandClearEncoding/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("btn-command");
expect(button.textContent).toBe(testCell.options.label);

// Check the grid cell styles.
expect(button.style["grid-column"]).toBe("14 / span 1");
expect(button.style["grid-row"]).toBe("2 / span 1");

// Check disabled state (should be enabled)
expect(button.getAttribute("disabled")).toBe(null);
});

});
42 changes: 42 additions & 0 deletions src/CommandClearEncoding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2023-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 { html } from "htm/preact";
import { BlissSymbol } from "./BlissSymbol";
import { usePaletteState } from "./GlobalData";
import { BlissSymbolCellType } from "./index.d";
import { generateGridStyle, speak } from "./GlobalUtils";

type CommandClearEncodingProps = {
id: string,
options: BlissSymbolCellType
}

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

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

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

const cellClicked = () => {
setFullEncoding([]);
speak(label);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should speak "clear".


return html`
<button id="${id}" class="btn-command" style="${gridStyles}" onClick=${cellClicked}>
<${BlissSymbol} bciAvId=${bciAvId} label=${label}/>
</button>
`;
}
65 changes: 65 additions & 0 deletions src/CommandDelLastEncoding.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 { CommandDelLastEncoding } from "./CommandDelLastEncoding";

describe("CommandDelLastEncoding render tests", () => {

const TEST_CELL_ID = "command-del-last-encoding";
const testCell = {
options: {
"label": "Delete",
"bciAvId": 12613,
"rowStart": 2,
"rowSpan": 1,
"columnStart": 13,
"columnSpan": 1
}
};

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

test("CommandDelLastEncoding rendering", async () => {

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

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

// Check that the CommandDelLastEncoding/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("btn-command");
expect(button.textContent).toBe(testCell.options.label);

// Check the grid cell styles.
expect(button.style["grid-column"]).toBe("13 / span 1");
expect(button.style["grid-row"]).toBe("2 / span 1");

// Check disabled state (should be enabled)
expect(button.getAttribute("disabled")).toBe(null);
});

});
43 changes: 43 additions & 0 deletions src/CommandDelLastEncoding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023-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 { html } from "htm/preact";
import { BlissSymbol } from "./BlissSymbol";
import { usePaletteState } from "./GlobalData";
import { BlissSymbolCellType } from "./index.d";
import { generateGridStyle, speak } from "./GlobalUtils";

type CommandDelLastEncodingProps = {
id: string,
options: BlissSymbolCellType
}

export function CommandDelLastEncoding (props: CommandDelLastEncodingProps) {
const { id, options } = props;
const { label, bciAvId, columnStart, columnSpan, rowStart, rowSpan } = options;

const paletteState = usePaletteState();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment no longer applies -- there are no separate lines. Did you find a way around having to use separate lines?

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

const cellClicked = () => {
const newEncoding = [...paletteState.fullEncoding];
newEncoding.pop();
paletteState.setFullEncoding(newEncoding);
speak(label);
};

return html`
<button id="${id}" class="btn-command" style="${gridStyles}" onClick=${cellClicked}>
<${BlissSymbol} bciAvId=${bciAvId} label=${label}/>
</button>
`;
}
30 changes: 30 additions & 0 deletions src/ContentBmwEncoding.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023-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
*/

.bmwEncodingArea {
align-items: center;
background-color: #fff;
border: 3px solid #ccc;
color: #000;
display: flex;
overflow: auto; /* Add scrollbar when content overflows */
white-space: nowrap;

&:hover {
background-color: limegreen;
color: white;
}

.blissSymbol {
margin: 0 0.5rem;
text-align: center;
}
}
Loading
Loading