feat(#3159): add JSDocs to React and Angular component wrappers#3715
feat(#3159): add JSDocs to React and Angular component wrappers#3715
Conversation
d245d76 to
ba51038
Compare
Co-Authored-By: Copilot <198982749+Copilot@users.noreply.github.com>
ba51038 to
1813a47
Compare
| @Input() ml?: Spacing; | ||
| /** Sets the right margin spacing token. */ | ||
| @Input() mr?: Spacing; | ||
| /** Sets the test id rendered on the underlying web component. */ |
There was a problem hiding this comment.
the comment should be Sets the data-testid attribute for automated testing. because the attribute we render is data-testid not test id
There was a problem hiding this comment.
Updated in b76d497: /** Sets the data-testid attribute for automated testing. */
| * // similar to app-footer-meta-section & app-footer-nav-section | ||
| */ | ||
| export class GoabFormItemSlot { | ||
| /** Sets which form-item slot this content should render into. */ |
There was a problem hiding this comment.
Should this have the @required in the comment?
There was a problem hiding this comment.
Added @required to the slot comment in b76d497: /** @required Sets which form-item slot this content should render into. */
| private cdr = inject(ChangeDetectorRef); | ||
|
|
||
| /** Defines the context and colour of the badge. */ | ||
| @Input() type?: GoabBadgeType; |
There was a problem hiding this comment.
We should update type, content, icon, iconType to begins vs Sets the ... like the rest of some properties
There was a problem hiding this comment.
Updated type comment from "Defines the..." to "Sets the..." in b76d497. The content, icon, and iconType comments didn't use "Defines the..." so they were already consistent.
| export class GoabBadge extends GoabBaseComponent implements OnInit { | ||
| private cdr = inject(ChangeDetectorRef); | ||
|
|
||
| /** Defines the context and colour of the badge. */ |
There was a problem hiding this comment.
I checked locally and the Docs site props table still shows the description and logic from Svelte web component *under extract-api.ts
For example Badge has type not required but on the docs we have this:
I think for this ticket we need to update the extract-api to make sure if we choose the language Angular we use the js docs from Angular, and React is from React js docs.
I think this is the scope of this ticket too ? cc @twjeffery and @Spark450 for the clarification. If we don't handle in this ticket, we will need another story to make sure we update the docs probs table according to React/Angular wrapper JS Docs comments.
There was a problem hiding this comment.
@vanessatran-ddi I have a separate PR for updating the docs: #3754
There was a problem hiding this comment.
@bdfranck Thank you.
@chrisolsen For the PR #3754 should we remove JS Docs comments on Svelte files too? Or we just leave those comments there.
There was a problem hiding this comment.
@vanessatran-ddi We have the "Web components" section in our new docs so we may as well keep them. I'll make sure #3754 includes the Web Components version.
|
@copilot Make the following changes:
|
- Change 'Defines the...' to 'Sets the...' in Angular and React wrappers - Fix testId comment in base.component.ts to 'Sets the data-testid attribute for automated testing.' - Add @required to GoabFormItemSlot slot comment Agent-Logs-Url: https://github.com/GovAlta/ui-components/sessions/7e34d1c9-e70e-42de-8686-0ee52733ec88 Co-authored-by: bdfranck <1479091+bdfranck@users.noreply.github.com>
Done in b76d497:
|
|
|
||
| /** Sets the context and colour of the badge. */ | ||
| @Input() type?: GoabBadgeType; | ||
| /** Text label of the badge. */ |
There was a problem hiding this comment.
Should be Sets the text label of the badge
| // Ensure boolean input; attribute only set when true so default behaviour is false | ||
| /** @deprecated Use icontype instead. Includes an icon in the badge. */ | ||
| @Input({ transform: booleanAttribute }) icon?: boolean; | ||
| /** Icon type to display in the badge. */ |
There was a problem hiding this comment.
Should be Sets the icon type to display in the badge
| @Input() size?: GoabBadgeSize = "medium"; | ||
| /** Sets the visual emphasis. 'subtle' for less prominent, 'strong' for more emphasis. @default "strong" */ | ||
| @Input() emphasis?: GoabBadgeEmphasis = "strong"; | ||
| /** Accessible label for screen readers. */ |
There was a problem hiding this comment.
Should be Sets the accessible label for screen readers
| export class GoabBlock extends GoabBaseComponent implements OnInit { | ||
| private cdr = inject(ChangeDetectorRef); | ||
|
|
||
| /** Spacing between items. Uses design system spacing tokens. */ |
There was a problem hiding this comment.
Should starts vs Sets the ...
|
|
||
| /** Spacing between items. Uses design system spacing tokens. */ | ||
| @Input() gap?: Spacing; | ||
| /** Stacking direction of child components. */ |
There was a problem hiding this comment.
Should starts vs Sets the ...
| @Input() gap?: Spacing; | ||
| /** Stacking direction of child components. */ | ||
| @Input() direction?: GoabBlockDirection; | ||
| /** Primary axis alignment of child components. */ |
There was a problem hiding this comment.
Should start vs Sets the ....
|
|
||
| /** Sets the visual style of the button. Use "primary" for main actions, "secondary" for alternative actions, "tertiary" for low-emphasis actions, and "start" for prominent call-to-action buttons. @default "primary" */ | ||
| @Input() type?: GoabButtonType = "primary"; | ||
| /** Controls the size of the button. Use "compact" for inline actions or space-constrained layouts. @default "normal" */ |
There was a problem hiding this comment.
Should starts vs Sets the size...
| @Input() size?: GoabButtonSize; | ||
| /** Sets the color variant for semantic meaning. Use "destructive" for delete or irreversible actions, "inverse" for dark backgrounds. @default "normal" */ | ||
| @Input() variant?: GoabButtonVariant; | ||
| /** When true, prevents user interaction and applies disabled styling. */ |
There was a problem hiding this comment.
Should be Sets the disabled state...
| @Input() variant?: GoabButtonVariant; | ||
| /** When true, prevents user interaction and applies disabled styling. */ | ||
| @Input({ transform: booleanAttribute }) disabled?: boolean; | ||
| /** Icon displayed before the button text. */ |
There was a problem hiding this comment.
Should be Sets the icon displayed...
vanessatran-ddi
left a comment
There was a problem hiding this comment.
I see some properties in angular documented as Sets the ... while some are not. I checked this rule https://github.com/GovAlta/ui-components/blob/dev/CLAUDE.md?plain=1#L109 and looks like we should follow the rule starts vs Sets the .. pattern. However it is not a blocker for me.
|
|
||
| export interface GoabAccordionProps extends Margins, DataAttributes { | ||
| /** @required Sets the heading text. */ | ||
| heading: string; |
There was a problem hiding this comment.
heading is required in React but not in Angular, think we should make this heading optional in this React wrapper too
| @Input({ required: true, transform: booleanAttribute }) open!: boolean; | ||
| /** @required The position of the drawer. */ | ||
| @Input({ required: true }) position!: GoabDrawerPosition; | ||
| /** @required The heading text displayed at the top of the drawer. */ |
There was a problem hiding this comment.
heading is optional for both react and angular, so this comment @required is not correct
| /** @required The name of the uploaded file to display. */ | ||
| @Input({ required: true }) filename!: string; | ||
| /** The file size in bytes. Displayed in a human-readable format (KB, MB). */ | ||
| @Input({ transform: numberAttribute }) size?: number; |
There was a problem hiding this comment.
size is a required attribute, so we miss it in Angular here, can you add required: true to the Input and update the comment
| /** Sets the id attribute on the file upload input element. */ | ||
| @Input() id?: string = ""; | ||
| /** @required The input display variant. "dragdrop" shows a drag-and-drop area, "button" shows a simple button. */ | ||
| @Input({ required: true }) variant!: GoabFileUploadInputVariant; |
There was a problem hiding this comment.
variant is set required in angular but not in React. Checking from Svelte, I think we can make this variant here optional
| * The modal will always use role="dialog". | ||
| */ | ||
| @Input() role?: string; | ||
| /** @required The heading text displayed at the top of the modal. */ |
There was a problem hiding this comment.
this heading is not required so this JS doc @required is not correct
This PR adds JSDocs to our React and Angular wrappers. Changes include...
Review feedback addressed
"Defines the..."JSDoc comments to"Sets the..."across Angular (badge.ts,input.ts,input-number.ts) and React (badge.tsx,modal.tsx,callout.tsx) wrapperstestIdcomment inbase.component.tsto"Sets the data-testid attribute for automated testing."@requiredtag to theGoabFormItemSlotslotproperty comment inform-item-slot.tsBefore (the change)
JSDoc comments were missing from React and Angular wrapper components, and some existing comments used inconsistent phrasing ("Defines the..." instead of "Sets the...").
After (the change)
All React and Angular wrapper components, properties, and common types have JSDoc comments. Comments consistently use "Sets the..." phrasing,
testIdcomments correctly referencedata-testid, and required slot inputs are marked with@required.Make sure that you've checked the boxes below before you submit the PR
Steps needed to test
Open a React or Angular project consuming
@abgov/react-componentsor@abgov/angular-componentsand verify that hovering over component names and props in your IDE shows the updated JSDoc descriptions.