/** * @prettier */ import React, { Component } from 'react'; import List from '@material-ui/core/List/index'; import { DetailContextConsumer } from '../../pages/version/index'; import { Heading, DistListItem, DistChips } from './styles'; import fileSizeSI from '../../utils/file-size'; class Dist extends Component { render() { return ( {context => { return this.renderDist(context); }} ); } renderChips(dist, license) { const distDict = { 'file-count': dist.fileCount, size: dist.unpackedSize && fileSizeSI(dist.unpackedSize), license, }; const chipsList = Object.keys(distDict).reduce((componentList, title, key) => { const value = distDict[title]; if (value) { const label = ( {/* eslint-disable-next-line */} {title.split('-').join(' ')}:{value} ); componentList.push(); } return componentList; }, []); return chipsList; } renderDist = ({ packageMeta }) => { const { dist = {}, license } = packageMeta.latest; return ( {'Latest Distribution'}}> {this.renderChips(dist, license)} ); }; } export default Dist;