-
Notifications
You must be signed in to change notification settings - Fork 51
Showcase - Convert utilities pages to TypeScript #3004
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
8849ae5 to
d31d9fc
Compare
d31d9fc to
aedf7cc
Compare
| model() { | ||
| const DETECTIONS: HdsAnchoredPositionOptions['enableCollisionDetection'][] = | ||
| [false, true, 'flip', 'shift', 'auto']; | ||
| const STRATEGIES: HdsAnchoredPositionOptions['strategy'][] = [ |
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.
[Note] Added the strategies options here as they were being passed in as a string array in the template, which caused issues when compared against the strategy type
| <button type="button" {{on "click" (fn this.toggleState "open")}}>Open</button> | ||
| <button type="button" {{on "click" (fn this.toggleState "close")}}>Close</button> | ||
| <button type="button" {{on "click" this.toggleState}}>Toggle</button> | ||
| <button type="button" {{on "click" (fn this.toggleState "")}}>Toggle</button> |
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.
[Note] this.toggleState expect 2 arguments
| <Shw::Text::H3>Strategy</Shw::Text::H3> | ||
|
|
||
| <Shw::Grid @columns={{4}} @gap="2rem" {{style margin-bottom="8rem"}} as |SF|> | ||
| {{#let (array "absolute" "fixed") as |strategies|}} |
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.
[Note] See comment above about setting this in the route instead
|
|
||
| export default class PageComponentsPopoverPrimitiveRoute extends Route { | ||
| model() { | ||
| const DETECTIONS: HdsAnchoredPositionOptions['enableCollisionDetection'][] = |
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.
[Note] Added the detection options here as they were being passed in as a string array in the template, which caused issues when compared against the detection type
| <Shw::Text::Body>Scroll within the boxes to see the collision detection in action</Shw::Text::Body> | ||
|
|
||
| <Shw::Grid @columns={{4}} @gap="2rem" {{style margin-bottom="6rem"}} as |SF|> | ||
| {{#let (array false true null null "flip" "shift" "auto" null) as |detections|}} |
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.
[Note] See comment above about setting this in the route instead
| </div> | ||
| </Shw::Autoscrollable> | ||
| </SF.Item> | ||
| {{#if (eq detection true)}} |
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.
[Note] This if block is used to maintain the existing grid layout where the first row has two examples in a column of 4, and second row has 3 examples in a column of 4
| <Hds::PopoverPrimitive | ||
| @enableSoftEvents={{eq interaction "soft"}} | ||
| @enableClickEvents={{eq interaction "click"}} | ||
| @enableCollisionDetection={{true}} |
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.
[Note] enableCollisionDetection should be set on the |PP|.setupPrimitivePopover.
aedf7cc to
911fa9f
Compare
c9cf99c to
5826897
Compare
3f957df to
fb52e23
Compare
didoo
left a comment
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.
@dchyun I know the PR is already merged, but I have noticed a bunch of things that may need a follow-up PR to be addressed
/cc @shleewhite
| import type RouterService from '@ember/routing/router-service'; | ||
|
|
||
| export default class PageUtilitiesController extends Controller { | ||
| @service declare readonly router: RouterService; |
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.
[note] in @shleewhite PR #2999 this was @service declare router: RouterService;. Which one is right? can we keep them consistent?
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.
@aklkv suggested using readonly in his comment. @shleewhite do we have a preferred option here?
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 this also have the export type + ModelFrom like the other files? with @shleewhite we discussed that this should become a code pattern/convention: #2999 (comment)
| <button type="button" {{on "click" (fn this.toggleState "open")}}>Open</button> | ||
| <button type="button" {{on "click" (fn this.toggleState "close")}}>Close</button> | ||
| <button type="button" {{on "click" this.toggleState}}>Toggle</button> | ||
| <button type="button" {{on "click" (fn this.toggleState "")}}>Toggle</button> |
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.
[suggestion] instead of this, what if we make the argument optional (which is also more correct from a JS code perspective, since there is an else.
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.
ref. comment: #3004
| <div class="shw-utilities-popover-primitive-fake-popover" {{PP.setupPrimitivePopover}}> | ||
| <div | ||
| class="shw-utilities-popover-primitive-fake-popover" | ||
| {{PP.setupPrimitivePopover anchoredPositionOptions=(hash)}} |
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.
[todo] we should add a comment here, that points to the Jira ticket that proposes making the anchoredPositionOptions optional
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.
ref. comment: #3004
📌 Summary
If merged, this PR would convert the following pages in the
utilitiesfolder of the Showcase to TypeScriptDisclosurePrimitivePopoverPrimitiveDismissButtonThe best way to understand the changes in this PR is to walk through each commit in the "Files changed" tab, I have added comments there explaining why I made the changes.
🔗 External links
Jira ticket: HDS-5076
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.