Skip to content

Instantly share code, notes, and snippets.

View vadimkorr's full-sized avatar
🦉

Vadim vadimkorr

🦉
View GitHub Profile
import { makeNotification } from "./makeNotification";
// 'SuccessNotification' component is used for rendering success notifications
export const SuccessNotification = makeNotification(
"check-circle", // icon name
"#dff0d8", // primary color
"#3c763d" // accent color
);
@vadimkorr
vadimkorr / makeNotification.js
Last active July 30, 2019 10:17
Basic implementation
import React from "react";
import PropTypes from "prop-types";
import { StyleSheet, TouchableOpacity, Text } from "react-native";
import { FontAwesome } from "@expo/vector-icons";
const ICON_SQUARE_SIZE = 100;
// 'makeNotification' is a HOC
export const makeNotification = (
// these values depend on notification type
<div class="form-group">
<label for="field1-od" class="required">Field #1</label>
<input formControlName="field1" type="text"
id="field1-od" placeholder="Enter Field #1">
</div>
<custom-labeled-input formControlName="field1" [isRequired]="true" [type]="'text'"
[id]="'field1'" [placeholder]="'Enter Field #1'" [label]="'Field #1'"></custom-labeled-input>
import { Component, ElementRef, ViewChild } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ComponentFixture, TestBed, tick, async, fakeAsync } from '@angular/core/testing';
import { CustomControlsModule } from '../../custom-controls.module';
@Component({
template: `
<custom-input [placeholder]="placeholder" [type]="type" [id]="id" [(ngModel)]="name"></custom-input>
`
})
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { InputComponent } from './components/input/input.component';
import { LabeledComponent } from './components/labeled/labeled.component';
import { LabeledInputComponent } from './components/labeled-input/labeled-input.component';
@NgModule({
imports: [ CommonModule, FormsModule ],
import { Component, OnInit, forwardRef, Input, ViewChild } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
import { InputComponent } from '../input/input.component';
@Component({
selector: 'custom-labeled-input',
templateUrl: './labeled-input.component.html',
styleUrls: ['./labeled-input.component.css'],
providers: [{
provide: NG_VALUE_ACCESSOR,
<custom-labeled
class="catch-validation-events"
[label]="label"
[id]="id"
[isRequired]="isRequired">
<custom-input
#input
[(ngModel)]="value"
[type]="type"
import { Component, Input } from '@angular/core';
@Component({
selector: 'custom-labeled',
templateUrl: './labeled.component.html',
styleUrls: ['./labeled.component.css']
})
export class LabeledComponent {
@Input() label: string = '';
@Input() id: string = '';
<div class="form-group group">
<label
[for]="id"
[ngClass]="{ 'required': isRequired }">{{label}}</label>
<ng-content></ng-content>
</div>