import {MatButtonToggleGroup} from '@angular/material'; import {War} from '../models/model-interfaces'; import {Fraction} from './fraction.enum'; export const CSSHelpers = { getBackgroundCSS: (imageUrl) => { return 'background-image: url(' + imageUrl + ');' + 'background-size: cover;' + 'background-attachment: fixed;' + 'background-position: center;' + 'background-repeat: no-repeat;'; } }; export const FractionHelpers = { getFractionColor: (fraction, war?: War, style?) => { let switchInput; if (war) { switchInput = (fraction === 'BLUFOR' ? war.fractionMappingBlufor : war.fractionMappingOpfor); } else { switchInput = fraction; } switch (switchInput) { case Fraction.ARF: switch (style) { case 'LIGHT': return Fraction.COLOR_ARF_LIGHT; case 'DARK': return Fraction.COLOR_ARF_DARK; case 'GREY': return Fraction.COLOR_ARF_GREY; default: return Fraction.COLOR_ARF; } case 'BLUFOR': switch (style) { case 'LIGHT': return Fraction.COLOR_BLUFOR_LIGHT; case 'DARK': return Fraction.COLOR_BLUFOR_DARK; case 'GREY': return Fraction.COLOR_BLUFOR_GREY; default: return Fraction.COLOR_BLUFOR; } case 'OPFOR': switch (style) { case 'LIGHT': return Fraction.COLOR_OPFOR_LIGHT; case 'DARK': return Fraction.COLOR_OPFOR_DARK; case 'GREY': return Fraction.COLOR_OPFOR_GREY; default: return Fraction.COLOR_OPFOR; } case Fraction.SWORD: switch (style) { case 'LIGHT': return Fraction.COLOR_SWORD_LIGHT; case 'DARK': return Fraction.COLOR_SWORD_DARK; case 'GREY': return Fraction.COLOR_SWORD_GREY; default: return Fraction.COLOR_SWORD; } } }, getFractionColors: (war: War, fraction) => { switch (fraction === 'BLUFOR' ? war.fractionMappingBlufor : war.fractionMappingOpfor) { case Fraction.ARF: return Fraction.COLOR_ARF; case 'BLUFOR': return Fraction.COLOR_BLUFOR; case 'OPFOR': return Fraction.COLOR_OPFOR; case Fraction.SWORD: return Fraction.COLOR_SWORD; } }, getFractionName: (war: War, fraction) => { switch (fraction === 'BLUFOR' ? war.fractionMappingBlufor : war.fractionMappingOpfor) { case Fraction.ARF: return Fraction.ARF; case 'BLUFOR': return Fraction.BLUFOR; case 'OPFOR': return Fraction.OPFOR; case Fraction.SWORD: return Fraction.SWORD; } } }; export const UIHelpers = { toggleReleaseButton: (currentVal, group?: MatButtonToggleGroup) => { if (group) { if (currentVal === group.value) { group.value = ''; return ''; } return group.value; } return currentVal; }, };