-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from cindyli/feat/create-bmw-encoding
feat: implement a content display area and associated buttons (resolves #2)
- Loading branch information
Showing
30 changed files
with
1,836 additions
and
811 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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); | ||
}); | ||
|
||
}); |
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,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); | ||
}; | ||
|
||
return html` | ||
<button id="${id}" class="btn-command" style="${gridStyles}" onClick=${cellClicked}> | ||
<${BlissSymbol} bciAvId=${bciAvId} label=${label}/> | ||
</button> | ||
`; | ||
} |
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,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); | ||
}); | ||
|
||
}); |
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,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(); | ||
|
||
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> | ||
`; | ||
} |
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,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; | ||
} | ||
} |
Oops, something went wrong.