🧒
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
  • What is theming?
  • Defining a theme
  • Sass
  • Partials
  • Import Partials
  1. USE
  2. Developer Guide
  3. UI (User interface)
  4. Angular Material

Theming

Last updated 1 year ago

What is theming?

Angular Material's theming system lets you customize color, typography, and density styles for components in your application. The theming system is based on Google's Material Design specification.

Here are some key aspects of Angular Material Theming:

  1. Predefined Themes: Angular Material provides a set of predefined themes that developers can choose from to quickly style their applications. These themes include various color schemes and typography settings. Developers can select a theme that best matches their application's branding or design requirements.

  2. Custom Theming: While the predefined themes are a good starting point, Angular Material also allows developers to create custom themes tailored to their specific needs. This involves defining custom color palettes, typography settings, and component styles.

  3. Theme Variables: To create custom themes, Angular Material relies on CSS variables, also known as CSS custom properties. These variables make it easy to define and change the theme's colors and styles in a consistent and maintainable way.

  4. Dynamic Theming: Angular Material also supports dynamic theming, allowing you to change the theme of your application at runtime. This can be useful for implementing features like dark mode or offering users the ability to choose their preferred theme.

Defining a theme

A theme is a collection of color, typography, and density options. Each theme includes three palettes that determine component colors:

  • A primary palette for the color that appears most frequently throughout your application

  • An accent, or secondary, palette used to selectively highlight key parts of your UI

  • A warn, or error, palette used for warnings and error states

Sass

Angular Material's theming APIs are built with Sass. This document assumes familiarity with CSS and Sass basics, including variables, functions, and mixins.

For more information about sass, please visit the following link:

Partials

Sass partials are small, reusable snippets of CSS that can be included in other Sass files, aiding in the modularization and organization of your stylesheets. These partial files are typically named with an underscore prefix, such as _partial.scss, to indicate to the Sass compiler that they should not be compiled into standalone CSS files.

Here are some key points to note about Sass partials:

  • Partial File Naming Convention: Sass partials are named with an underscore prefix (e.g., _partial.scss) to distinguish them from standalone CSS files.

  • Modularization: Partials allow you to break down your styles into smaller, focused pieces, making it easier to manage specific aspects of your project, such as typography, colors, buttons, forms, or individual components.

  • Reusability: You can import partials into multiple Sass files, promoting code reuse and ensuring consistent styles throughout your project.

  • Organization: By grouping related partials and creating directories, you can maintain a logical and structured organization of your project's styles, enhancing readability and maintenance.

To implement theming in a Sunbird Ed Angular Material application, you generally leverage the Angular Material theming capabilities offered by the library. In our setup, we've established a folder named "mat-themes," which contains all the custom theme assets and configurations. Below is a list of partials:

  1. _buttons.scss

  2. _colors.scss

  3. _mat-badge.scss

  4. _mat-card.scss

  5. _mat-chips.scss

  6. _mat-dialog.scss

  7. _mat-expansion-panel

  8. _mat-form-field.scss

  9. _mat-list.scss

  10. _mat-sidebar.scss

  11. _mat-tab-group.scss

  12. _palette.scss

  13. _search.scss

  14. _template_bg.scss

  15. _toolbar-menu.scss

  16. _toolbar-pageback.scss

  17. _typography.scss

We will delve into each individual partial file in upcoming sessions.

Import Partials

To include a Sass partial within another Sass file, you can utilize the @import directive followed by the partial's filename, excluding the underscore and the .scss extension. As an example, we imported all the previously mentioned partials into the "includes.scss" file, which is subsequently included in the "mat-themes" folder.

@use "@angular/material" as mat;
@use "sass:map";
@import "./buttons";
@import "./colors";
@import './mat-badge';
@import './mat-card';
@import './mat-chips';
@import './mat-dialog';
@import './mat-expansion-panel';
@import './mat-form-field';
@import './mat-list';
@import './mat-sidebar';
@import './mat-tab-group';
@import './search';
@use './template_bg' as *;
@import "./toolbar-menu";
@import "./toolbar-pageback";
@import "./typography";

In summary, while @import is still valid in Sass, @use is recommended for modern projects as it provides better encapsulation, organization, and performance. It's particularly useful in larger codebases where avoiding naming conflicts and optimizing output CSS are essential considerations.

@use "@angular/material" as mat;

The line of code you provided is using the @use directive in Sass to import the Angular Material library and create an alias mat for it. This alias allows you to reference Angular Material's styles, variables, mixins, and components in your Sass or SCSS files more easily and with better encapsulation.

Here's a breakdown of the code:

  • @use: This is the Sass directive used to import external modules or files.

  • "@angular/material": This is the path to the Angular Material library. It's enclosed in double quotes to specify a module or package name. You can use the correct path to the Angular Material library in your project.

  • as mat: This part of the code creates an alias mat for the imported Angular Material library. The alias allows you to access Angular Material's features using the mat namespace. For example, you can use mat.button to reference Angular Material's button styles or components.

@use "sass:map";

The line of code @use "sass:map"; in Sass is importing the built-in Sass module called map. This module provides functionality for working with Sass maps, which are a data structure in Sass used to store key-value pairs.

In summary, Using Sass partials helps you maintain a well-organized, modular, and maintainable codebase for your styles, which is particularly useful in larger web development projects.

https://sass-lang.com/guide/