Open abu18saud opened 2 years ago
الثيمات التي يمكن اختيارها: purple-green.css pink-bluegrey.css indigo-pink.css deeppurple-amber.css purple-green.css
محتوى customTheme.scss
// Custom Theming for Angular Material // For more information: https://material.angular.io/guide/theming @use '@angular/material' as mat; // Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only // have to load a single css file for Angular Material in your app. // Be sure that you only ever include this mixin once! @include mat.core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. Available color palettes: https://material.io/design/color/ $portal-primary: mat.define-palette(mat.$teal-palette, 700); $portal-accent: mat.define-palette(mat.$red-palette, 900); $portal-warn: mat.define-palette(mat.$deep-orange-palette, 500);
$portal-theme: mat.define-light-theme(( color: ( primary: $portal-primary, accent: $portal-accent, warn: $portal-warn, ), typography: mat.define-typography-config( $font-family: 'DroidKufi-Regular', ) ));
@include mat.all-component-themes($portal-theme);
//for dark theme $portal-primary-dark: mat.define-palette(mat.$green-palette, 900); $portal-accent-dark: mat.define-palette(mat.$orange-palette); $portal-warn-dark: mat.define-palette(mat.$yellow-palette);
$portal-dark-theme: mat.define-dark-theme((
color: (
primary: $portal-primary-dark,
accent: $portal-accent-dark,
warn: $portal-warn-dark,
),
typography: mat.define-typography-config(
$font-family: 'DroidKufi-Regular',
)
));
.drak-theme-mode{ @include mat.all-component-themes($portal-dark-theme); }
Add Material To Your Prrogect
ng add @angular/material
Add navbar
ng g @angular/material:navigation nav
Add dashboard
ng g @angular/material:dashboard home
Add Address Form
ng generate @angular/material:address-form
Add Table
ng generate @angular/material:table
Add Table
ng generate @angular/material:table
Add Tree
ng generate @angular/material:tree
resource
https://material.angular.io/guide/schematics
reduce
Add Material Moudule
stackblitzes
Command
Date Library
titles
This is heading for h1
This is heading for h2
This is heading for h3
This is heading for h4
Buttons
Toggle Buttons
الفردي
على شكل مجموعة
badges
Progress Spinner
دوران لا نهائي
<mat-spinner *ngIf="showSpinner" color="accent"> <button (click)="loadData()">Load Data
showSpinner = false;
loadData() { this.showSpinner = true; setTimeout(() => { this.showSpinner = false; }, 5000); }
navbar
.navbar { justify-content: space-between; }
span{ padding-right: 1rem; }
Sidenav
opened = false;
log(state:any) { console.log(state); }
menu
<button class="center" mat-flat-button [matMenuTriggerFor]="appMenu">Menu
<mat-menu #subMenu="matMenu">
<mat-menu #backEnd="matMenu">
.center{ margin: 10rem; }
Lists
Heading
Line
Heading
Line
Grid List
<mat-grid-list rowHeight="fit" style="height: 200px" gutterSize="10px" cols="2">
mat-grid-tile{ background-color: lightblue; }
Expansion Panel - أداة رائعة للتوسيع والطي
This is the panel content. Add course details
This is the panel content. Add course details
Cards
Tabs
<mat-tab-group #tabRef (selectedChange)="logChange(tabRef.selectedIndex)">
{{ tabRef.selectedIndex }} logChange(state:any){ console.log(state); }
Stepper
أفقي
عامودي
input
Select
{{selectedValue}}
Autocomplete
الأساسية
الكائنات
];
الفلاتر - لا تعمل بشكل جيد
import { FormControl } from '@angular/forms'; import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators';
myControl = new FormControl(); filteredOptions: Observable<string[]> = {} as Observable<string[]>;
OnInit() { this.filteredOptions = this.myControl.valueChanges.pipe( startWith(''), map(value => this._filter(value)) ); }
private _filter(value: string): string[] { const filterValue = value.toLowerCase(); return this.options.filter(option => option.toLowerCase().includes(filterValue)); }
مربعات الاختيار
أزرار الراديو
منتقي التاريخ
maxDate = new Date(2022, 3, 10); // لإلغاء اختيار نهايات الأسبوع على سبيل المثال dateFilter = date => { const day = date.getDay(); return day != 5 && day != 6;
Tooltip - التلميح
mat-raised-button matTooltip="Welcome to Codevolution" matTooltipPosition="after" matTooltipShowDelay="2000" matTooltipHideDelay="2000">Hello
Snackbar
<button mat-button (click)="openSnackBar('Item deleted', 'Undo')"> Delete
import { MatSnackBar } from "@angular/material/snack-bar"; constructor(private snackBar: MatSnackBar){}
openSnackBar(message: any, action: any) { let snackBarRef = this.snackBar.open(message, action, {duration: 2000});
Custom
@Component({ selector: 'custom-snackbar', template:
<span style='color: orange'>Custom Snackbar</span>
}) export class CustomSnackBarComponent{}openCustomSnackBar(){ this.snackBar.openFromComponent(CustomSnackBarComponent, {duration: 2000}); }
<button mat-button (click)="openCustomSnackBar()"> Show custom snackbar
مربعات الحوار - Dialogs
Cli ng g c dialog-example --skipTests
appModule.ts entryComponents: [DialogExampleComponent],
//--------------------------------------------
ts Dialog Component import { Component, OnInit, Inject } from '@angular/core'; import { MAT_DIALOG_DATA } from "@angular/material/dialog";
constructor(@Inject(MAT_DIALOG_DATA) public data:any) { }
Session timeout
//---------------------------------------------
home HTML <button mat-raised-button (click)="openDialog()"> Open Dialog
constructor(public dialog: MatDialog){}
openDialog() { let dialogRef = this.dialog.open(DialogExampleComponent, {data: {name: 'Vishwas'}}); dialogRef.afterClosed().subscribe(result => { console.log(
Dialog result: ${result}
); }); }