Skip to content

Conversation

@dchyun
Copy link
Contributor

@dchyun dchyun commented Jul 10, 2025

📌 Summary

If merged, this PR would convert the following pages in the utilities folder of the Showcase to TypeScript

  • DisclosurePrimitive
  • PopoverPrimitive
  • DismissButton
  • Base level utilities route

The 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

  • Percy was checked for any visual regression

💬 Please consider using conventional comments when reviewing this PR.

📋 PCI review checklist
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

@vercel
Copy link

vercel bot commented Jul 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Jul 14, 2025 4:56pm
hds-website ✅ Ready (Inspect) Visit Preview Jul 14, 2025 4:56pm

model() {
const DETECTIONS: HdsAnchoredPositionOptions['enableCollisionDetection'][] =
[false, true, 'flip', 'shift', 'auto'];
const STRATEGIES: HdsAnchoredPositionOptions['strategy'][] = [
Copy link
Contributor Author

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>
Copy link
Contributor Author

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|}}
Copy link
Contributor Author

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'][] =
Copy link
Contributor Author

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|}}
Copy link
Contributor Author

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)}}
Copy link
Contributor Author

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}}
Copy link
Contributor Author

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.

@dchyun dchyun merged commit 7ca7912 into main Jul 14, 2025
16 checks passed
@dchyun dchyun deleted the dchyun/showcase-utilities-ts-conversion branch July 14, 2025 19:08
Copy link
Contributor

@didoo didoo left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor

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)}}
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ref. comment: #3004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants