-
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: basic implementation for navigation among palette layers (resolves #5) #6
Conversation
Also, clean up index.html and move most of the functionality to index.js.
- renamed `ActionBranchToPalette` component to` ActionBranchToPaletteCell`, - adjusted file names, code, and palette json files as apprppriate for the name change.
✅ Deploy Preview for adaptive-palette ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
import { initAdaptivePaletteGlobals } from "./GlobalData"; | ||
import { ActionBranchToPaletteCell } from "./ActionBranchToPaletteCell"; | ||
|
||
describe("ActionBranchToPaletteCell render tests", () => { |
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.
It would be nice to also test the click event of the ActionBranchToPaletteCell
that leads to the rendering of the palette at the next layer.
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.
Yes, and I decided that the best place to do that is in Palette.integration.test
since the go-to button affects other areas of the screen and involves other objects.
src/CommandGoBackCell.test.ts
Outdated
import { initAdaptivePaletteGlobals } from "./GlobalData"; | ||
import { CommandGoBackCell } from "./CommandGoBackCell"; | ||
|
||
describe("ActionBmwCodeDell render tests", () => { |
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.
Would be nice to test the click event of the go back button. Since this test involves paletteStore
and navigationStack
, it may fit better in the integration test file Palette.integration.test.ts
?
The same idea applies in the comment above about testing the click event for ActionBranchToPaletteCell
.
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.
As above with the ActionBranchToPaletteCell
, the go-back button test is in Palette.integration.test
.
src/ActionBranchToPaletteCell.ts
Outdated
// TODO: this is identical to `ActionBmwCodeCellPropsType`. Should it be? | ||
type ActionBranchToPalettePropsType = { |
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.
I'm thinking if we should expand the options
section for every type component as this part is not defined and verified by typescript. What do you think?
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.
I agree, and will start work on it next. I also noticed that we don't define the return type of many of our functions. Should we?
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.
It's a great idea to define the return type for functions.
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.
I've done them all. The one that was problematic was the return type for the htm()
template function used by all of the component Functions. I thought htm
returned a string
type, but it does not. Its return type is something like TemplateStringsArray
, but when I looked into the project's repository, I found issue #73, Question: How well does this work with TypeScript?. The main answer is given in the first response: "there aren't typings for htm / html, but there are extremely basic types for the react and preact integrations." The rest of the discussion is about TypeScript's effort to support a tagged template type. That work is ongoing.
I did some more debugging and it looks like, in the case of Preact, the htm
return type is VNode
, or "virtual DOM node". I'm currently using that for the return type.
As for the expanding the options, I'm still working on that.
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.
I'm thinking if we should expand the
options
section for every type component as this part is not defined and verified by typescript. What do you think?
For "expanding the options section", I took the full BlissSymbolCellType
and created new types from its parts. Since these are not palette cell types, I used "Info" in their type names; for example, a LayoutInfoType
that contains only the grid-styles information. Then, one can define cell types by combining the info types as needed.
Let me know what you think.
src/GlobalData.ts
Outdated
* @return {JsonPaletteType} - The palette itself, or `null` if it could not be | ||
* loaded. | ||
*/ | ||
export async function importPaletteFromJsonFile (jsonFile: string, path: string) { |
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.
Would this function better belong to GlobalUtils.ts
?
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.
Yes, that makes sense. I moved it there.
src/NavigationStack.ts
Outdated
|
||
/** | ||
* Return the palette at the top of the stack without changing the stack | ||
* tself. If an index is given, the palette at that index is returned. Note |
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.
typo: "tself -> itself".
Another question is, if an index of zero denotes the top of the stack, what if someone wants to peek the palette at the bottom of the stack that actually uses the index zero?
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.
I added a peekLast()
function to look at the bottom of the stack. I first thought that a special index value such as -1
defined as the constant LAST_INDEX
could be used, e.g., const palette = navStack.peek(LAST_INDEX)
, but that felt less transparent than a function for peeking at the bottom of the stack. So I switched to peekLast()
.
src/index.js
Outdated
|
||
adaptivePaletteGlobals.navigationStack.currentPalette = firstLayer; | ||
render(html`<${Palette} json=${goBackCell} />`, document.getElementById("backup_palette")); | ||
//render(html`<${Palette} json=${outputPalette} />`, document.getElementById("output_palette")); |
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.
This commented line can be removed? Same as other related spots: line 29 in this file and this div container in index.html
?
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.
Right. All of them have been removed.
When loading the palette page in a browser, the console log reports this error:
The error might come from this line. |
…tion - initialize the globals with an optional id (of the main palette area), - set the `aria-controls` attribute of all go-back buttons to this id, - when going back use the `aria-controls` to find the container element to render the palette into.
The error does come from that line. As far as I can tell, "BMW" does not have a blissary id nor Blissymbol. If it does, let me know. But this points to another issue: Since the Should the |
@cindyli Ready for another round of review. I decided to change the click handlers for both the |
I feel if there isn't a value for the The cell that has |
I think adding |
…utton Also tweak the label of the "Famliy" button and the bliss symbol "People" of the button.
You meant ``[8552, "/", 8563, "/", 8573]` :-). After thinking about it, I agree that a |
I came up with a solution that adds another property in the .json palette definition called Let me know what you think. |
}; | ||
|
||
export type BlissSymbolCellType = LayoutInfoType & BranchToInfoType & BlissSymbolInfoType; |
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.
Great finding of this useful feature.
Ready for another review, @cindyli. |
This basic implementation uses a stack to keep track of the palette layers that the user has chosen. When a user activates a cell that leads to another layer, the palette containing the activated "go-to-layer" cell is pushed onto the stack. Whenever the user activates a "go-back" cell, the palette at top of the stack is popped off and navigated to.