Docs: Material - rollthecloudinc/quell GitHub Wiki

Documentation for Angular Material Library


Table of Contents

  1. Introduction
  2. Installation
  3. Overview
  4. Key Concepts
    • Material Module
    • Responsive Stepper Component
  5. Core Components
    • MaterialModule
    • ResponsiveStepperComponent
  6. Usage
    • Setting Up Material in Your App
    • Using the Responsive Stepper
  7. API Reference
  8. Examples
  9. Testing

1. Introduction

The Angular Material Library enhances Angular applications by providing ready-to-use Material Design components via MaterialModule and a custom-built ResponsiveStepperComponent. The library includes all essential Angular Material components along with support for advanced features like responsive steppers for guided workflows.


2. Installation

Install the library and Angular Material dependencies:

npm install @angular/material @angular/cdk

3. Overview

This library simplifies the integration of Material Design components into Angular applications.

Features:

  • MaterialModule: A centralized Angular module bundling commonly used Angular Material modules.
  • ResponsiveStepperComponent: A custom stepper component that provides vertical/horizontal orientation and responsive design.

4. Key Concepts

4.1 Material Module

The MaterialModule serves as a centralized library module bundling Angular Material components. It makes importing Material components convenient and modular.


4.2 Responsive Stepper Component

The ResponsiveStepperComponent extends Angular Material's built-in MatStepper. It allows switching between horizontal and vertical stepper orientations dynamically, adding enhanced responsiveness. The stepper supports linear progression, custom styling, and step selection.


5. Core Components

5.1 MaterialModule

The MaterialModule bundles Angular Material components and other experimental CDK modules. It also exports the ResponsiveStepperComponent.

Modules Included:

  • Basic Modules: Buttons, icons, input fields, etc.
  • Advanced Modules: Stepper, drag-and-drop, progressive list, etc.
  • CDK Modules: Accessibility, scrolling, stepper, etc.

Features:

  • Centralized module simplifies Material imports.
  • Reduces boilerplate in application modules.

Configuration Example:

import { MaterialModule } from './material.module';

@NgModule({
  imports: [MaterialModule],
})
export class AppModule {}

5.2 ResponsiveStepperComponent

The ResponsiveStepperComponent offers a configurable vertical/horizontal step layout. It provides:

  • Dynamic Orientation: Switch between vertical and horizontal layouts.
  • Step Headers: Configurable clickable/non-clickable headers.
  • Events: Emits selectionChange, animationDone, and orientationChange.

Key Inputs:

Input Description
orientation Defines stepper layout (horizontal/vertical).
linear Enables linear step progression.
selectedIndex Index of the selected step.

Key Outputs:

Output Description
selectionChange Emits when the step selection changes.
animationDone Emits when a step animation finishes.
orientationChange Emits when orientation changes dynamically.

6. Usage

6.1 Setting Up Material in Your App

Import the MaterialModule into your application's AppModule to access Angular Material components globally:

import { MaterialModule } from './material.module';

@NgModule({
  imports: [MaterialModule],
  declarations: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

6.2 Using the Responsive Stepper

Add the ResponsiveStepperComponent to any workflow requiring a step-by-step guided experience.

Template:

<responsive-stepper 
    [orientation]="'horizontal'" 
    [linear]="true" 
    (selectionChange)="onStepChange($event)">
</responsive-stepper>

Component Script:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  onStepChange(event: any) {
    console.log('Current Step Changed:', event);
  }
}

7. API Reference

MaterialModule

Property Description
exports Exports all Angular Material modules and Responsive Stepper.

ResponsiveStepperComponent

Input & Output Type Description
orientation 'horizontal' | 'vertical' Layout direction of the stepper.
linear boolean Enables linear progression.
selectedIndex number Set selected step index.
selectionChange EventEmitter Emits step selection changes.
animationDone EventEmitter Emits step animation completion events.
orientationChange EventEmitter Emits changes in stepper orientation.

8. Examples

Example: Responsive Stepper Component

Usage Example:

<responsive-stepper 
  [orientation]="'vertical'" 
  [linear]="false" 
  [selectedIndex]="0" 
  (selectionChange)="onStepChange($event)">
</responsive-stepper>

Component Logic:

import { Component } from '@angular/core';

@Component({
  selector: 'app-stepper-demo',
  templateUrl: './stepper-demo.component.html',
})
export class StepperDemoComponent {
  onStepChange(event: any) {
    console.log('Stepper event:', event);
  }
}

Example: MaterialModule

Access Material components globally after importing MaterialModule into your application.

<mat-toolbar color="primary">
  <mat-icon>home</mat-icon>
  <span>Angular Material Header</span>
</mat-toolbar>

9. Testing

Example: Using Responsive Stepper Component Test Suite

The ResponsiveStepperComponent has unit tests verifying layout configuration, event emissions, and step selection.

Test Example:

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ResponsiveStepperComponent } from './responsive-stepper.component';

describe('ResponsiveStepperComponent', () => {
  let component: ResponsiveStepperComponent;
  let fixture: ComponentFixture<ResponsiveStepperComponent>;

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [ResponsiveStepperComponent],
    }).compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(ResponsiveStepperComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create stepper component', () => {
    expect(component).toBeTruthy();
  });

  it('should switch orientation', () => {
    component.orientation = 'vertical';
    fixture.detectChanges();
    expect(component.orientation).toBe('vertical');
  });
});

Conclusion

The Angular Material Library combines the strengths of Angular Material components and custom-built responsive steppers to empower developers with flexible and dynamic UI workflows. By using MaterialModule and ResponsiveStepperComponent, developers can ensure consistent Material Design across their application UI.

For contributions or issues, feel free to reach out!

⚠️ **GitHub.com Fallback** ⚠️