All files / packages/sds-recipes/src/modules/c/illustration illustrationMapping.js

0% Statements 0/6
0% Branches 0/4
0% Functions 0/1
0% Lines 0/6

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                                                                                                       
// Mapping slds2 illustration to slds1 illustration
const v2ToV1Mapping = {
  cart: {
    noitems: {
      set: 'misc',
      symbol: 'gonefishing',
    },
  },
  error: {
    appconnection: {
      set: 'error',
      symbol: 'noconnection',
    },
    connectionissue: {
      set: 'error',
      symbol: 'noconnection',
    },
    recoverable: {
      set: 'custom',
      symbol: 'noevents',
    },
    unrecoverable: {
      set: 'error',
      symbol: 'walkthroughnotavailable',
    },
  },
};
 
/**
 * Returns slds2 illustration set and symbol to slds1
 * illustration set and symbol in object
 * @param {string} setVal - The SLDS2 set value
 * @param {string} symbolVal - The SLDS2 symbol value
 * @returns {object} Object containing slds1Set and slds1Symbol. If slds1 set or symbol does not exist, it will display console error.
 */
export function mapV2ToV1(setVal, symbolVal) {
  // Early return if no mapping exists
  if (!v2ToV1Mapping[setVal]) {
    console.error(`Set "${setVal}" not found in mapping`);
  }
 
  const symbolMapping = v2ToV1Mapping[setVal][symbolVal];
  if (!symbolMapping) {
    console.error(`Symbol "${symbolVal}" not found in set "${setVal}"`);
  }
 
  return {
    slds1Set: symbolMapping.set,
    slds1Symbol: symbolMapping.symbol,
  };
}