From eb8ef781b8b52a8b6ba95b238d2437a3bc925584 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sun, 20 Jan 2019 11:04:37 +0100 Subject: [PATCH 1/2] chore: clean up component --- src/webui/components/DetailSidebar/index.js | 70 ++++++++------------- src/webui/components/Install/index.js | 48 ++++++++++++++ 2 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 src/webui/components/Install/index.js diff --git a/src/webui/components/DetailSidebar/index.js b/src/webui/components/DetailSidebar/index.js index ad63dbfa9..70997edcf 100644 --- a/src/webui/components/DetailSidebar/index.js +++ b/src/webui/components/DetailSidebar/index.js @@ -1,19 +1,11 @@ -/* eslint react/jsx-max-depth: 0 */ - import React, {Component} from 'react'; import { DetailContextConsumer } from '../../pages/version/index'; -// import Paper from '@material-ui/core/Paper/index'; import Typography from '@material-ui/core/Typography/index'; import Grid from '@material-ui/core/Grid/index'; -// import CardHeader from '@material-ui/core/CardHeader'; -import Card from '@material-ui/core/Card/index'; -import CardContent from '@material-ui/core/CardContent/index'; + +import Install from '../Install'; import { Content } from './styles'; -import CopyToClipBoard from '../CopyToClipBoard'; -import Button from '@material-ui/core/Button'; -import CardActions from '@material-ui/core/CardActions'; -// import Paper from '@material-ui/core/Paper/index'; class DetailSidebar extends Component { render() { @@ -28,46 +20,34 @@ class DetailSidebar extends Component { renderSideBar = ({packageMeta, packageName}) => { return ( - - {this.renderDescription(packageMeta, packageName)} - - - - - {packageName} - - - {packageMeta.latest.description} - - - - - - - - - - - - - - + + + + {this.renderTitle(packageName, packageMeta)} - - + + {this.renderCopyCLI()} + + + ); } - renderDescription = (packageMeta) => { - console.log('packageMeta', packageMeta); + renderTitle = (packageName, packageMeta) => { + return ( + + + {packageName} + + + {packageMeta.latest.description} + + + ); + } - return ( - - - - ); + renderCopyCLI = () => { + return ; } } diff --git a/src/webui/components/Install/index.js b/src/webui/components/Install/index.js new file mode 100644 index 000000000..631932e34 --- /dev/null +++ b/src/webui/components/Install/index.js @@ -0,0 +1,48 @@ +import React, {Component} from 'react'; + +import { DetailContextConsumer } from '../../pages/version/index'; +import Card from '@material-ui/core/Card/index'; +import CardContent from '@material-ui/core/CardContent/index'; +import CopyToClipBoard from '../CopyToClipBoard'; +import Button from '@material-ui/core/Button'; +import CardActions from '@material-ui/core/CardActions'; + +class Install extends Component { + render() { + return ( + + {(context) => { + return this.renderCopyCLI(context); + }} + + ); + }; + + renderCopyCLI = ({packageName}) => { + return ( + + + + + + + {this.renderDownloadButton()} + + + + ); + } + + renderDownloadButton = () => { + return ( + + + + ); + } +} + + +export default Install; From 2929e371b95fd5ef3349c6d5bc829019a0aca644 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sun, 20 Jan 2019 15:17:54 +0100 Subject: [PATCH 2/2] chore: add repository, license and author --- src/webui/components/Author/index.js | 54 +++++++++++++++++ src/webui/components/DetailSidebar/index.js | 36 +++++++++++- src/webui/components/License/index.js | 51 ++++++++++++++++ src/webui/components/Repository/index.js | 64 +++++++++++++++++++++ src/webui/components/Repository/styles.js | 13 +++++ src/webui/components/Versions/index.js | 21 ++++--- src/webui/icons/GitHub.js | 16 ++++++ src/webui/pages/version/index.js | 1 - 8 files changed, 247 insertions(+), 9 deletions(-) create mode 100644 src/webui/components/Author/index.js create mode 100644 src/webui/components/License/index.js create mode 100644 src/webui/components/Repository/index.js create mode 100644 src/webui/components/Repository/styles.js create mode 100644 src/webui/icons/GitHub.js diff --git a/src/webui/components/Author/index.js b/src/webui/components/Author/index.js new file mode 100644 index 000000000..7f1c30b89 --- /dev/null +++ b/src/webui/components/Author/index.js @@ -0,0 +1,54 @@ +/* eslint no-unused-vars: 0 */ + +import React, {Component, Fragment} from 'react'; + +import { DetailContextConsumer } from '../../pages/version/index'; +import Card from '@material-ui/core/Card/index'; +import CardContent from '@material-ui/core/CardContent/index'; +import CopyToClipBoard from '../CopyToClipBoard'; +import CardHeader from '@material-ui/core/CardHeader/index'; +import Avatar from '@material-ui/core/Avatar'; +import CardActions from '@material-ui/core/CardActions'; +import Typography from "@material-ui/core/Typography/index"; + +class Authors extends Component { + render() { + return ( + + {(context) => { + return this.renderAuthor(context); + }} + + ); + }; + + renderAuthor = ({packageMeta}) => { + const { author } = packageMeta.latest; + + if (!author) { + return null; + } + + return ( + + + {this.renderAvatar(author)} + + + ); + } + + renderAvatar = ({name, email, url, avatar}) => { + return ( + + + + {name} + + + ); + } +} + + +export default Authors; diff --git a/src/webui/components/DetailSidebar/index.js b/src/webui/components/DetailSidebar/index.js index 70997edcf..86a78e357 100644 --- a/src/webui/components/DetailSidebar/index.js +++ b/src/webui/components/DetailSidebar/index.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, {Component, Fragment} from 'react'; import { DetailContextConsumer } from '../../pages/version/index'; import Typography from '@material-ui/core/Typography/index'; @@ -6,6 +6,9 @@ import Grid from '@material-ui/core/Grid/index'; import Install from '../Install'; import { Content } from './styles'; +import Authors from '../Author'; +import License from '../License'; +import Repository from '../Repository'; class DetailSidebar extends Component { render() { @@ -28,6 +31,12 @@ class DetailSidebar extends Component { {this.renderCopyCLI()} + + {this.renderSecondLevel(8)} + + + {this.renderRepository()} + ); @@ -49,6 +58,31 @@ class DetailSidebar extends Component { renderCopyCLI = () => { return ; } + + renderSecondLevel = (spacing = 24) => { + return ( + + {this.renderAuthor()} + + ); + } + + renderRepository = () => { + return ; + } + + renderAuthor = () => { + return ( + + + + + + + + + ); + } } diff --git a/src/webui/components/License/index.js b/src/webui/components/License/index.js new file mode 100644 index 000000000..f7c3c4c5f --- /dev/null +++ b/src/webui/components/License/index.js @@ -0,0 +1,51 @@ +/* eslint no-unused-vars: 0 */ + +import React, {Component, Fragment} from 'react'; + +import { DetailContextConsumer } from '../../pages/version/index'; +import Card from '@material-ui/core/Card/index'; +import CardContent from '@material-ui/core/CardContent/index'; +import Avatar from '@material-ui/core/Avatar'; +import Notes from '@material-ui/icons/Notes'; +import Typography from "@material-ui/core/Typography/index"; + +class License extends Component { + render() { + return ( + + {(context) => { + return this.renderAuthor(context); + }} + + ); + }; + + renderAuthor = ({packageMeta}) => { + const { license } = packageMeta.latest; + if (!license) { + return null; + } + + return ( + + + {this.renderLicense(license)} + + + ); + } + + renderLicense = (license) => { + return ( + + + + {license} + + + ); + } +} + + +export default License; diff --git a/src/webui/components/Repository/index.js b/src/webui/components/Repository/index.js new file mode 100644 index 000000000..ded02165f --- /dev/null +++ b/src/webui/components/Repository/index.js @@ -0,0 +1,64 @@ +/* eslint no-unused-vars: 0 */ +/* eslint react/jsx-max-depth: 0 */ + +import React, {Component, Fragment} from 'react'; + +import { DetailContextConsumer } from '../../pages/version/index'; +import Card from '@material-ui/core/Card/index'; +import CardContent from '@material-ui/core/CardContent/index'; +import Grid from '@material-ui/core/Grid/index'; +import GitHub from '../../icons/GitHub'; +import CopyToClipBoard from '../CopyToClipBoard'; +import BugReport from '@material-ui/icons/BugReport'; +import CardActions from '@material-ui/core/CardActions/index'; +import Button from '@material-ui/core/Button'; +import {GridRepo} from './styles'; + +class Repository extends Component { + render() { + return ( + + {(context) => { + return this.renderAuthor(context); + }} + + ); + }; + + renderAuthor = ({packageMeta}) => { + const { repository, bugs } = packageMeta.latest; + if (!repository) { + return null; + } + + return ( + + + + {this.renderRepository(repository, bugs)} + + + + + + + + ); + } + + renderRepository = ({url, type}, bugs) => { + return ( + + + + + + + + + ); + } +} + + +export default Repository; diff --git a/src/webui/components/Repository/styles.js b/src/webui/components/Repository/styles.js new file mode 100644 index 000000000..8533347d5 --- /dev/null +++ b/src/webui/components/Repository/styles.js @@ -0,0 +1,13 @@ +/** + * @prettier + * @flow + */ + +import styled from 'react-emotion'; +import Grid from '@material-ui/core/Grid/index'; + +export const GridRepo = styled(Grid)` + && { + align-items: center; + } +`; diff --git a/src/webui/components/Versions/index.js b/src/webui/components/Versions/index.js index bea3ae6c4..ca8e004cc 100644 --- a/src/webui/components/Versions/index.js +++ b/src/webui/components/Versions/index.js @@ -6,16 +6,24 @@ import { DetailContextConsumer } from '../../pages/version/index'; import { formatDateDistance } from '../../utils/package'; import { Heading, Spacer, ListItemText } from './styles'; -import List from '@material-ui/core/List'; -import ListItem from '@material-ui/core/ListItem'; +import List from '@material-ui/core/List/index'; +import ListItem from '@material-ui/core/ListItem/index'; import React from 'react'; +import { DIST_TAGS } from '../../../lib/constants'; -class Versions extends React.PureComponent { +class Versions extends React.PureComponent { render() { - return {({ packageMeta }) => this.renderContent(packageMeta['dist-tags'], packageMeta.versions)}; + return ( + // $FlowFixMe + + {({ packageMeta }) => { + return this.renderContent(packageMeta[DIST_TAGS], packageMeta.versions); + }} + + ); } - renderPackageList = (packages: object, isVersion: boolean = false) => ( + renderPackageList = (packages: any, isVersion: boolean = false) => ( {Object.keys(packages) .reverse() @@ -29,8 +37,7 @@ class Versions extends React.PureComponent { ); - // $FlowFixMe - renderContent = (distTags, versions) => ( + renderContent = (distTags: any, versions: any) => ( <> {distTags && ( <> diff --git a/src/webui/icons/GitHub.js b/src/webui/icons/GitHub.js new file mode 100644 index 000000000..264784f1c --- /dev/null +++ b/src/webui/icons/GitHub.js @@ -0,0 +1,16 @@ +// @flow +/* eslint-disable max-len */ +/* eslint-disable react/jsx-curly-brace-presence */ + +import React from 'react'; +import SvgIcon from '@material-ui/core/SvgIcon/index'; + +function GitHub(props: Object) { + return ( + + + + ); +} + +export default GitHub; diff --git a/src/webui/pages/version/index.js b/src/webui/pages/version/index.js index c918c60e5..655e17021 100644 --- a/src/webui/pages/version/index.js +++ b/src/webui/pages/version/index.js @@ -110,7 +110,6 @@ class VersionPage extends Component { render() { const { isLoading, packageMeta, readMe, packageName } = this.state; - console.log('render', packageName, isLoading); if (isLoading === false) { return (