forked from sombochea/verdaccio-ui
refactor: corrects eslint and variable name spacing (#31)
* refactor: corrects eslint and variable namespacing * chore: fixes git conflict * chore: fixes eslint
This commit is contained in:
committed by
Juan Picado @jotadeveloper
parent
f000438b86
commit
96b65d969a
@@ -1,5 +1,8 @@
|
||||
/* eslint-disable */
|
||||
import React, {Component} from 'react';
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import Avatar from '@material-ui/core/Avatar/index';
|
||||
import Grid from '@material-ui/core/Grid/index';
|
||||
@@ -7,29 +10,27 @@ import List from '@material-ui/core/List/index';
|
||||
import ListItemText from '@material-ui/core/ListItemText/index';
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/version/index';
|
||||
|
||||
import { Heading, EngineListItem } from './styles';
|
||||
import node from './img/node.png';
|
||||
import npm from '../Install/img/npm.svg'
|
||||
|
||||
import npm from '../Install/img/npm.svg';
|
||||
|
||||
const ICONS = {
|
||||
'node-JS': <Avatar src={node} />,
|
||||
'NPM-version': <Avatar src={npm} />,
|
||||
}
|
||||
};
|
||||
|
||||
class Engine extends Component {
|
||||
render() {
|
||||
return (
|
||||
<DetailContextConsumer>
|
||||
{(context) => {
|
||||
{context => {
|
||||
return this.renderEngine(context);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
renderEngine = ({packageMeta}) => {
|
||||
renderEngine = ({ packageMeta }) => {
|
||||
const { engines } = packageMeta.latest;
|
||||
if (!engines) {
|
||||
return null;
|
||||
@@ -37,14 +38,14 @@ class Engine extends Component {
|
||||
|
||||
const engineDict = {
|
||||
'node-JS': engines.node,
|
||||
'NPM-version': engines.npm
|
||||
}
|
||||
'NPM-version': engines.npm,
|
||||
};
|
||||
|
||||
const items = Object.keys(engineDict).reduce((markup, text, key) => {
|
||||
const heading = engineDict[text]
|
||||
if (heading){
|
||||
const heading = engineDict[text];
|
||||
if (heading) {
|
||||
markup.push(
|
||||
<Grid item={true} xs={6} key={key}>
|
||||
<Grid item={true} key={key} xs={6}>
|
||||
{this.renderListItems(heading, text)}
|
||||
</Grid>
|
||||
);
|
||||
@@ -56,23 +57,19 @@ class Engine extends Component {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Grid container={true}>
|
||||
{items}
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
return <Grid container={true}>{items}</Grid>;
|
||||
};
|
||||
|
||||
renderListItems = (heading, text) => {
|
||||
return (
|
||||
<List subheader={<Heading variant={"subheading"}>{text.split('-').join(' ')}</Heading>}>
|
||||
<List subheader={<Heading variant={'subheading'}>{text.split('-').join(' ')}</Heading>}>
|
||||
<EngineListItem>
|
||||
{ ICONS[text] }
|
||||
{ICONS[text]}
|
||||
<ListItemText primary={heading} />
|
||||
</EngineListItem>
|
||||
</List>
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Engine;
|
||||
|
||||
Reference in New Issue
Block a user