🧒
Sunbird ED
new release -7.0.0 (Jun 2024)Askdot
release-6.0.0
release-6.0.0
  • Learn
    • Overview
    • Capabilities
      • Learning Apps
      • Asset Sourcing
      • Organised Collections
      • Discover Content - Digital & Phygital
      • User Engagement
      • Rich and diverse content
      • Versatile Question Bank
      • Observability
      • Launch Course
      • Verifiable Credentials
      • Multi-Channel Chatbot
      • Targeted Programs
      • Manage Learn
        • Overview
        • What is an entity?
        • What is a Program?
        • What is a Project?
        • What is Observation?
        • What is a Survey?
        • What is Observation as a task inside a Project?
      • Product and Developer's Guide
        • Learning apps
          • Workflows
            • Onboarding of Users
            • Discovery of Content
            • Play content
            • Track progress and Earn credentials
            • Interacting / Collaborating
        • Asset Sourcing
        • Organised Collections
        • Discover Content - Digital & Phygital
        • User Engagement
        • Rich and Diverse Content
        • Versatile Question Bank
        • Observability
        • Launch Courses
        • Verifiable Credentials
        • Multi-Channel Chatbot
        • Targeted Programs
        • Manage Learn
          • Overview
          • Component Diagram
          • ML Core Service
          • ML Project Service
          • ML Survey Service
          • ML Report Service
          • ML Analytics Service
    • Tech Overview
      • Design Principles
      • Technical Architecture Diagram
      • Tech Stack
    • Adopters
      • DIKSHA
    • Roadmap
  • USE
    • Getting started
      • Deployment Overview
      • Pre-requisites
      • Install
        • Provision Cloud Infrastructure
        • Setup Jenkins
        • Update Ansible Variables
        • Build, Provision and Deploy
        • Functional Configurations
    • Latest Release - 6.0.1
      • Release notes
      • Updating Sunbird Releases
        • 5.2.0 to 6.0.1
      • Release Calendar 6.0.1
      • Demo of released items
    • Developer Guide
      • Architecture - Component Diagram
      • System Requirements
      • Install Locally
        • SunbirdED Mobile
        • SunbirdED Portal
      • Easy Installer
      • Configuration
        • SunbirdEd Portal
        • Sunbird Mobile
      • Portal
        • Component Diagram
      • Desktop
        • Component Diagram
      • Mobile
        • Component Diagram
        • sunbird-mobile-sdk
        • Sunbird-mobile-app plugins
        • Configurations to setup mobile app
      • Form service
        • Component Diagram
        • Data model
        • API's
      • Manage Learn
        • ML Core Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Project Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Survey Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Report Service
          • Overview
          • User Flow Diagram
          • Component Diagram
          • Data Model
          • Folder Structure
          • API's
          • Deployment Overview
          • Local Service Setup Guide
        • ML Analytics Service
          • Overview
          • Component Diagram
          • Data Model
          • Setup Guide
            • ENV Variables ( Config.ini)
          • Ingestions
          • Folder Structure
          • Report creation and Updation Scripts
          • Deployment Overview
      • UI (User interface)
        • Angular Material
          • Overview
          • Installation
          • Material Icons
          • Components Usage
          • Theming
          • Theme Setup
          • Customization
            • Palette
            • Theme
            • Accessibility
            • Colors
            • Typography
            • Components
              • Buttons
              • Card
              • Toolbar
              • Dialog
              • Menu
          • CC Components
            • Card
            • Chips
            • Expansion Panel
        • Component Style Guide Version 1
          • Accordion
          • Buttons
          • Cards
          • Forms
          • Grid & Layout
          • Labels
          • Modals
          • Pagination
          • Rating
          • Search Box
          • Select Box
          • Tables
          • Tabs
          • Toast messages
          • Tooltip
          • Typography
        • SB-Styles: A Comprehensive Design Resource
        • SB-Themes Repository: Unifying Design Across Platforms
          • Classical Theme in Sunbird-Ed portal
          • Joyful Theme in Sunbird-Ed portal:
      • Reference Apps
        • Independent Libraries
          • Common Consumption Components
          • SunbirdEd Forms
          • Sunbird Client Services
          • Sunbird Styles
          • Sunbird Themes
          • Sunbird Tag Manager
      • API's
      • Admin Dashboard Reports
      • CSP changes
      • Reports
      • Other
        • Minimal forms
        • Telemetry
          • Trackable Collection
        • Platform
        • Learning Apps
    • Learn More
      • Dependencies
      • Specifications
        • SOFIE
        • SOFIE Implementation
  • Engage
    • Discuss
    • Contribute to ED
    • Extend / Contribute to Sunbird
    • Issue tracker/ Create Issue
  • Misc
    • Templates
      • Upgrade Sunbird release document
      • Release Notes
    • Misc Pages
      • Portal - Manage Learn - Reports
      • App - Manage Learn - component diagram
        • Projects
        • Observation & Survey
        • Program
      • Portal - Manage Learn - component diagram
      • Mobile form configurations
      • Content Indexing Flow
      • What are multiple databases used for
      • Course completion, reports and certificate issue
      • How to access Flink UI
      • What are all the flink jobs for
      • How does data flow into Druid
      • Minimal build properties
    • Archived
      • High Level Capabilities
      • Workflows
      • Where Sunbird ED helps you
      • ED - Mobile App (going to archive)
        • 4.10.3 to 5.0.0
        • 5.0.0 to 5.1.0
      • Setting up Sunbird ED
      • Developer Documentation
      • API Reference Documentation
      • Detailed Documentation
      • Source Code
      • Actors & Actions
      • Detailed Capabilities
      • Data
      • Terminology
      • 5.1.0-hotfix (OCI )
Powered by GitBook
On this page
  1. USE
  2. Developer Guide
  3. UI (User interface)
  4. Angular Material
  5. Customization
  6. Components

Dialog

Last updated 1 year ago

A "" is a user interface component provided by Angular Material that facilitates the creation of modal dialog boxes in web applications. Modal dialogs are typically used to display additional information, request user input, or present critical messages without navigating to a new page. Mat dialogs are often employed for tasks like form submissions, confirmations, or detailed information display. Key features and characteristics of mat dialogs include:

  1. Modal Behavior: Mat dialogs are modal, meaning they temporarily block interaction with the underlying content until the dialog is closed, ensuring the user's focus remains on the dialog.

  2. Custom Content: You can populate mat dialogs with custom content, including forms, messages, tables, or any other components and elements as needed for your specific use case.

  3. Actions and Buttons: Mat dialogs often contain buttons for actions like confirmation, cancellation, or any custom action you define. These buttons can trigger specific behavior upon interaction.

  4. Theming and Styling: Angular Material provides theming and styling options, allowing you to customize the appearance of mat dialogs to align with your application's design and branding.

  5. Accessibility: Mat dialogs are designed with accessibility in mind, ensuring keyboard navigation and screen reader compatibility.

Mat dialogs are commonly used in various contexts, including:

  • Form Submission: Confirming or editing form submissions before saving data.

  • Information Display: Displaying detailed information or reports.

  • User Prompts: Requesting user input for important actions.

  • Alerts and Notifications: Displaying alerts, warnings, or success messages.

Here's a basic example of how you can use the mat-dialog component in an Angular Material application:

Before writing code in our HTML components, we initially imported and declared the MatChipsModule in "material.module.ts".

import {MatDialogModule} from '@angular/material/dialog';

@NgModule({
  declarations: [
    PillsGridComponent,
    PillItemComponent
  ],
  imports: [
    MatDialogModule
  ],
  exports: [
    PillsGridComponent,
    PillItemComponent
  ]
})
location-selection.component.html
<app-modal-wrapper *ngIf="showModal && !isStepper"
  [config]="{disableClose: true, width: '45rem', id: locationSelectionModalId, panelClass: ['location-selection-modal', 'material-modal']}"
  (dismiss)="closeModal()">
  <ng-template sbModalContent let-data>

    <div mat-dialog-title class="flex-jc-center flex-dc mb-0">
      <ng-content select="[slot=popup-header]"></ng-content>
      <button mat-mini-fab color="warn" class="ml-auto" aria-label="close dialog" mat-dialog-close
        *ngIf="isClosable"><mat-icon>close</mat-icon></button>
    </div>

    <mat-dialog-content class="pt-0">
      <p class="mat-subheading-2 mb-0 text-left" tabindex="0"><ng-content select="[slot=popup-sub-header]" class="mt-8"></ng-content></p>
      <div class="w-100" [appTelemetryImpression]="telemetryImpression">
        <sb-form
          *ngIf="sbFormLocationSelectionDelegate.locationFormConfig && sbFormLocationSelectionDelegate.locationFormConfig.length"
          [config]="sbFormLocationSelectionDelegate.locationFormConfig"
          (initialize)="sbFormLocationSelectionDelegate.onFormInitialize($event)"
          (valueChanges)="sbFormLocationSelectionDelegate.onFormValueChange($event)"
          (dataLoadStatus)="sbFormLocationSelectionDelegate.onDataLoadStatusChange($event)">
        </sb-form>
      </div>
    </mat-dialog-content>

    <mat-dialog-actions align="end">
      <ng-content select="[slot=popup-footer]" class="text-left mb-8" tabindex="0"></ng-content>
      <button mat-raised-button type="button" class="button-rounded text-uppercase" type="button"
        [class.sb-btn-disabled]="sbFormLocationSelectionDelegate.isLocationFormLoading"
        [disabled]="sbFormLocationSelectionDelegate.isLocationFormLoading" (click)="clearUserLocationSelections()"
        tabindex="0">{{resourceService?.frmelmnts?.btn?.clear}}
      </button>
      <button mat-raised-button color="accent" type="button" class="button-rounded text-uppercase ml-8" type="submit"
        [class.sb-btn-disabled]="sbFormLocationSelectionDelegate.isLocationFormLoading || sbFormLocationSelectionDelegate.formGroup?.invalid"
        [disabled]="sbFormLocationSelectionDelegate.isLocationFormLoading || sbFormLocationSelectionDelegate.formGroup?.invalid"
        (click)="updateUserLocation()" tabindex="0">{{resourceService?.frmelmnts?.btn?.submit}}
        <mat-icon>arrow_right_alt</mat-icon>
      </button>
    </mat-dialog-actions>

  </ng-template>
</app-modal-wrapper>

The appearance of the above basic dialog appears as follows.

Dialog with Custom Styling

We established a mixin named "theme-mat-modal" in "_mat-dialog.scss" situated within the "mat-themes" folder. Subsequently, this "_mat-dialog.scss" was imported into the "includes.scss" file.

_mat-dialog.scss
@use "@angular/material"as mat;
@use 'sass:map';

@mixin theme-mat-modal($theme) {
  // Get the color config from the theme.
  $color-config: mat.get-color-config($theme);
  // Get the primary color palette from the color-config.
  $primary: map.get($color-config, 'primary');
  $accent: map.get($color-config, 'accent');
  $warn: map.get($color-config, 'warn');
  $background: map.get($color-config, 'background');

  .cdk-overlay-pane.fullscreen-modal {
    width: 100% !important;
    max-width: 100% !important;
  }

  .mat-dialog-container {
    position: relative;
    padding: 0;
    background-color: var(--sbt-body-bg);
    border-radius: 1.5rem;
  }

  .mat-dialog-title {
    // background-color: mat.get-color-from-palette($primary, 500);
    color: mat.get-color-from-palette($accent);
    margin: 0;
    padding: 1rem 1rem;
    display: flex;
    align-items: center;

    h2 {
      margin-bottom: 0 !important;
    }
  }
  .mat-dialog-content {
    padding: 1rem;
    margin: 0;
    text-align: left;
    ::ng-deep html[dir="rtl"]{
      text-align: right;
      text-align: unset;
    }
  }
  .mat-dialog-actions {
    padding: 1rem 1rem;
    margin: 0;
  }
}
includes.scss
@import './mat-dialog';

A mixin was crafted and then imported into the "themes.scss" file within the "app-themes" section.

themes.scss
 @include theme-mat-modal($theme);

The end result will be as follows:

mat-dialog