All files / icon status-icon.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 10/10
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133                                                        1x         53x                         53x               53x                 53x                 53x                 53x                 53x                 53x                 53x                 53x                 53x            
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { InjectionToken } from '@angular/core';
import { EntityStatusType, StatusIcon } from '@siemens/element-ng/common';
import { t } from '@siemens/element-translate-ng/translate';
 
import {
  elementCircleFilled,
  elementOctagonFilled,
  elementSquare45Filled,
  elementSquareFilled,
  elementStateExclamationMark,
  elementStateInfo,
  elementStatePause,
  elementStateProgress,
  elementStateQuestionMark,
  elementStateTick,
  elementTriangleFilled
} from './element-icons';
import { addIcons } from './si-icons';
 
/**
 * The status icon configuration.
 *
 * @experimental
 */
export const STATUS_ICON_CONFIG = new InjectionToken<{ [key in EntityStatusType]: StatusIcon }>(
  'STATUS_ICON_CONFIG',
  {
    providedIn: 'root',
    factory: () => {
      addIcons({
        elementCircleFilled,
        elementOctagonFilled,
        elementSquare45Filled,
        elementSquareFilled,
        elementStateExclamationMark,
        elementStateInfo,
        elementStatePause,
        elementStateProgress,
        elementStateQuestionMark,
        elementStateTick,
        elementTriangleFilled
      });
      return {
        success: {
          icon: 'elementCircleFilled',
          color: 'status-success',
          stacked: 'elementStateTick',
          stackedColor: 'status-success-contrast',
          background: 'bg-base-success',
          severity: 5,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.SUCCESS:Success`)
        },
        info: {
          icon: 'elementSquareFilled',
          color: 'status-info',
          stacked: 'elementStateInfo',
          stackedColor: 'status-info-contrast',
          background: 'bg-base-info',
          severity: 4,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.INFO:Info`)
        },
        caution: {
          icon: 'elementSquare45Filled',
          color: 'status-caution',
          stacked: 'elementStateExclamationMark',
          stackedColor: 'status-caution-contrast',
          background: 'bg-base-caution',
          severity: 3,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.CAUTION:Caution`)
        },
        warning: {
          icon: 'elementTriangleFilled',
          color: 'status-warning',
          stacked: 'elementStateExclamationMark',
          stackedColor: 'status-warning-contrast',
          background: 'bg-base-warning',
          severity: 2,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.WARNING:Warning`)
        },
        danger: {
          icon: 'elementCircleFilled',
          color: 'status-danger',
          stacked: 'elementStateExclamationMark',
          stackedColor: 'status-danger-contrast',
          background: 'bg-base-danger',
          severity: 1,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.DANGER:Danger`)
        },
        critical: {
          icon: 'elementOctagonFilled',
          color: 'status-critical',
          stacked: 'elementStateExclamationMark',
          stackedColor: 'status-critical-contrast',
          background: 'bg-base-critical',
          severity: 0,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.CRITICAL:Critical`)
        },
        progress: {
          icon: 'elementCircleFilled',
          color: 'status-info',
          stacked: 'elementStateProgress',
          stackedColor: 'status-info-contrast',
          background: 'bg-base-info',
          severity: 7,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.PROGRESS:Progress`)
        },
        pending: {
          icon: 'elementCircleFilled',
          color: 'status-caution',
          stacked: 'elementStatePause',
          stackedColor: 'status-caution-contrast',
          background: 'bg-base-caution',
          severity: 6,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.PENDING:Pending`)
        },
        unknown: {
          icon: 'elementCircleFilled',
          color: 'status-neutral',
          stacked: 'elementStateQuestionMark',
          stackedColor: 'text-body',
          background: 'bg-base-0',
          severity: 8,
          ariaLabel: t(() => $localize`:@@SI_ICON_STATUS.UNKNOWN:Unknown`)
        }
      };
    }
  }
);