Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

A guess on Angular Material UI #15

Open
reboottime opened this issue Nov 13, 2023 · 0 comments
Open

A guess on Angular Material UI #15

reboottime opened this issue Nov 13, 2023 · 0 comments
Labels

Comments

@reboottime
Copy link
Owner

reboottime commented Nov 13, 2023

Below is a speculative explanation of how the Material UI button functions, focusing on the mat-raised-button directive, without referring to the actual source code.

  • Define the directives
import { Directive, ElementRef, Renderer2, OnInit } from '@angular/core';

@Directive({
  selector: '[mat-raised-button]'
})
export class MatRaisedButtonDirective implements OnInit {
  
  constructor(private el: ElementRef, private renderer: Renderer2) {}

  ngOnInit() {
    // Add Material Design specific classes
    this.renderer.addClass(this.el.nativeElement, 'mat-button');
    this.renderer.addClass(this.el.nativeElement, 'mat-raised-button');

    // Add any additional styles or attributes necessary for the raised effect
    this.renderer.setStyle(this.el.nativeElement, 'box-shadow', '0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)');
    // ... other styles or event bindings
  }
}
  • define the module
@NgModule({
  declarations: [
    MatRaisedButtonDirective,
    // ... other components and directives
  ],
  // ...
})
export class MaterialModule { }
  • Apply the directive
<button mat-raised-button>Click Me</button>
@reboottime reboottime changed the title A guess on Material UI A guess on Angular Material UI Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant