local icons

Summary:
Currently icons were always fetched remotely. We used a service worker to prefetch and cache some icons, that were critical to the UI.

In this diff, we are bundling icons at build time, with the app. In utils/icons.js we still specfify the list of icons which should be bundled. These are downloaded as part of the build step and bundled with the app. We are downloading the icons in 1x and 2x (the two most common pixel densities).

Reviewed By: jknoxville

Differential Revision: D16620764

fbshipit-source-id: 965a7793ad1f08aebb292606add00218429cdaf4
This commit is contained in:
Daniel Büchele
2019-08-02 08:56:23 -07:00
committed by Facebook Github Bot
parent 1717fba410
commit 16e913a819
6 changed files with 127 additions and 178 deletions

View File

@@ -7,8 +7,8 @@
import React from 'react';
import styled from '../styled/index.js';
const PropTypes = require('prop-types');
import {getIconUrl} from '../../utils/icons.js';
import PropTypes from 'prop-types';
import {getIconURL} from '../../utils/icons.js';
const ColoredIconBlack = styled('img')(({size}) => ({
height: size,
@@ -91,7 +91,11 @@ export default class Glyph extends React.Component<{
className={className}
color={color}
size={size}
src={getIconUrl(name, size, variant)}
src={getIconURL(
variant === 'outline' ? `${name}-outline` : name,
size,
typeof window !== 'undefined' ? window.devicePixelRatio : 1,
)}
/>
);
}