aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/core/preloadImages.js
blob: e0796e1fefcc70ca29feb6ae4c0049b160ab3a05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import palette from '../../common/theme/palette';
import deviceCategories from '../../common/util/deviceCategories';
import { loadImage, prepareIcon } from './mapUtil';

export const mapImages = {};

export default async () => {
  const background = await loadImage('images/background.svg');
  mapImages.background = await prepareIcon(background);
  await Promise.all(deviceCategories.map(async (category) => {
    const results = [];
    ['positive', 'negative', 'neutral'].forEach((color) => {
      results.push(loadImage(`images/icon/${category}.svg`).then((icon) => {
        mapImages[`${category}-${color}`] = prepareIcon(background, icon, palette.colors[color]);
      }));
    });
    await Promise.all(results);
  }));
};