Skip to content

feat(api): adds directive closeButton and update buttons demo with ne… #132

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

Merged
merged 2 commits into from
Jul 17, 2025

Conversation

pavankjadda
Copy link
Contributor

…w Close Button component

@pavankjadda pavankjadda requested a review from Copilot July 17, 2025 01:43
Copy link

netlify bot commented Jul 17, 2025

Deploy Preview for ng-kit ready!

Name Link
🔨 Latest commit ded3092
🔍 Latest deploy log https://app.netlify.com/projects/ng-kit/deploys/687855e97df628000867353a
😎 Deploy Preview https://deploy-preview-132--ng-kit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pavankjadda pavankjadda self-assigned this Jul 17, 2025
@pavankjadda pavankjadda added the feature New Feature label Jul 17, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new Close Button directive to the component library and wires it into the demo, while updating the public API to expose the new directive and reordering some existing exports.

  • Exposes CloseButtonDirective and new button components in public-api.ts
  • Implements CloseButtonDirective to automatically add a secondary-button class
  • Updates the demo component to import the directive, enable OnPush change detection, and show a <button closeButton>

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
projects/ng-kit/src/public-api.ts Reordered spinner exports and added CloseButtonDirective and new button exports
projects/ng-kit/src/lib/components/buttons/close-button/close-button.directive.ts Added CloseButtonDirective implementation
projects/ng-kit-demo/src/app/buttons-demo/buttons-demo.component.ts Imported CloseButtonDirective, MatButtonModule, and set OnPush change detection
projects/ng-kit-demo/src/app/buttons-demo/buttons-demo.component.html Added a <button closeButton> example
Comments suppressed due to low confidence (1)

projects/ng-kit/src/lib/components/buttons/close-button/close-button.directive.ts:1

  • [nitpick] Add unit tests for CloseButtonDirective to verify that the secondary-button class is correctly added to the host element when the directive is instantiated.
import { Directive, ElementRef, inject } from '@angular/core';

Comment on lines 1 to 10
import { Directive, ElementRef, inject } from '@angular/core';

@Directive({
selector: '[closeButton]',
})
export class CloseButtonDirective {
elementRef = inject(ElementRef);

constructor() {
this.elementRef.nativeElement.classList.add('secondary-button');
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Use Angular's Renderer2 (injected) instead of direct ElementRef.nativeElement manipulation to add classes, ensuring proper abstraction and avoiding direct DOM access.

Suggested change
import { Directive, ElementRef, inject } from '@angular/core';
@Directive({
selector: '[closeButton]',
})
export class CloseButtonDirective {
elementRef = inject(ElementRef);
constructor() {
this.elementRef.nativeElement.classList.add('secondary-button');
import { Directive, ElementRef, Renderer2, inject } from '@angular/core';
@Directive({
selector: '[closeButton]',
})
export class CloseButtonDirective {
elementRef = inject(ElementRef);
renderer = inject(Renderer2);
constructor() {
this.renderer.addClass(this.elementRef.nativeElement, 'secondary-button');

Copilot uses AI. Check for mistakes.

@@ -34,8 +36,11 @@ import {
SearchButtonComponent,
SuccessButtonComponent,
DeleteButtonComponent,
CloseButtonDirective,
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Add standalone: true to the @Component decorator so that the imports array (including CloseButtonDirective and MatButtonModule) is applied correctly.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,12 @@
import { Directive, ElementRef, inject } from '@angular/core';

@Directive({
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Mark this directive as standalone by adding standalone: true in the decorator so it can be imported directly without NgModule declarations.

Copilot uses AI. Check for mistakes.

@pavankjadda pavankjadda merged commit fcf4e12 into main Jul 17, 2025
6 of 7 checks passed
Copy link

🎉 This PR is included in version 20.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

1 participant