-
Notifications
You must be signed in to change notification settings - Fork 4
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
cindyli
merged 33 commits into
inclusive-design:main
from
cindyli:feat/create-bmw-encoding
Feb 1, 2024
Merged
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 71498eb
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli ef00b17
feat: add the global message handler
cindyli a78a44c
fix: linted
cindyli 834fa54
doc: improve code comments
cindyli 2f415ea
doc: add code comments for GlobalMessageHandler
cindyli c848240
fix: add tests for ContentBmwEncoding and GlobalMessageHandler compon…
cindyli 704bc14
Merge branch 'feat/add-cellType-registry' into feat/create-bmw-encoding
cindyli 0dbbab5
fix: merge missing files in the previous commit
cindyli 28c3577
fix: display proper BlissSymbol in encoding area
cindyli 011502c
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli 08c1c71
fix: adjust style
cindyli 47bb906
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli df7cb68
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli b5ddde5
fix: improve css for Bliss symbols and fix tests
cindyli 2f86063
Merge remote-tracking branch 'joseph/feat/create-palette-from-json' i…
cindyli c94e4aa
test: add tests for showing Bliss symbols in the content area
cindyli f079472
fix: add the type check for addBmwCode payload
cindyli 77e4709
Merge branch 'main' into feat/create-bmw-encoding
cindyli f9f2921
feat: use preact context to coordinate the addition/removal/clearing …
cindyli a48c887
feat: add unit tests and integration tests
cindyli d9835ea
fix: improve styling
cindyli bbe43d3
fix: code clean up
cindyli bd77ddd
feat: announce the label of the selected Bliss symbol
cindyli 5ad860d
fix: address review comments
cindyli 241b738
fix: improve css of the grid palette
cindyli 07aed46
fix: the width of the display area no longer changes when appending s…
cindyli e56aba6
fix: fix the palette test
cindyli 4fbcf01
fix: the display area now has role="textbox"
cindyli 16c2c36
fix: fix the test for ContentBmwEncoding
cindyli f14cbaa
fix: address more review comments
cindyli 1f73831
fix: improve function comments and copyright messages
cindyli a1badc7
fix: improve a code comment
cindyli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
`; | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should speak "clear".