This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Directive } from '@angular/core'; | |
| import { AbstractControl, FormGroup } from '@angular/forms'; | |
| /** Helper для работы с формами */ | |
| @Directive() | |
| export abstract class FormHelper { | |
| /** | |
| * Возвращает значение поля формы | |
| * @param form - форма | |
| * @param fieldName - название поля |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Injectable} from '@angular/core'; | |
| const TUI = 'someId_'; | |
| /** | |
| * Generates unique ids | |
| */ | |
| @Injectable({ | |
| providedIn: 'root', | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Usage: | |
| <Input label='Email' errorMessage={'ERROR'}/> | |
| Code: | |
| import React from 'react'; | |
| import classes from './Input.module.scss'; | |
| function isInvalid({ valid, touched, shouldValidate }) { | |
| return !valid && shouldValidate && touched; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: 'breaklines' | |
| }) | |
| export class BreakLinesPipe implements PipeTransform { | |
| transform(text: string) { | |
| if (text) { | |
| return text.replace(new RegExp('\n', 'g'), '<br>'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @mixin mouse() { | |
| @media (hover: hover) { | |
| @content; | |
| } | |
| } | |
| Пример использования: | |
| @include mouse { | |
| &:hover { | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: 'paragraphs' | |
| }) | |
| export class ParagraphsPipe implements PipeTransform { | |
| transform(text: string) { | |
| if (text) { | |
| return '<p>' + text | |
| .replace(new RegExp('(\n){2,}', 'g'), '</p><p>') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class IdService { | |
| constructor() { } | |
| generate() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: 'phoneFormat' | |
| }) | |
| export class PhoneFormatPipe implements PipeTransform { | |
| transform(value: string, args?: any): string { | |
| return value.replace(/[^+0-9]/gim, ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Для несколько элементов: | |
| ngOnInit() { | |
| const stickyElm = document.querySelectorAll('mat-expansion-panel-header'); | |
| const observer = new IntersectionObserver( | |
| ([e]) => e.target.classList.toggle('isSticky', e.intersectionRatio < 1), | |
| {threshold: [1]} | |
| ); | |
| for (let i = 0; i < stickyElm.length; i++) { |
NewerOlder