Skip to content

Commit

Permalink
Lint & prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
huayunh committed Feb 22, 2020
1 parent 962867d commit 10c9871
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
15 changes: 8 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import * as Colors from '@pxblue/colors';
import { Feedback } from '@material-ui/icons';
import useMediaQuery from '@material-ui/core/useMediaQuery';

const ellipseBackgroundImage = require('./assets/bg.png');
const angularImage = require('./assets/angular-ionic-logo.svg');
const reactImage = require('./assets/react-logo.svg');
const reactNativeImage = require('./assets/react-native-logo.png');
const titleImage = require('./assets/title.svg');
const titleImageSM = require('./assets/titleSM.svg');
import ellipseBackgroundImage from './assets/bg.png';
import angularImage from './assets/angular-ionic-logo.svg';
import reactImage from './assets/react-logo.svg';
import reactNativeImage from './assets/react-native-logo.png';
import titleImage from './assets/title.svg';
import titleImageSM from './assets/titleSM.svg';

const cardShift = -100;

Expand Down Expand Up @@ -82,6 +82,7 @@ const useStyles = makeStyles((theme: Theme) =>
padding: theme.spacing(2),
color: Colors.white[50],
flexShrink: 0,
textAlign: 'center',
},
FAB: {
position: 'fixed',
Expand All @@ -92,7 +93,7 @@ const useStyles = makeStyles((theme: Theme) =>
})
);

function App() {
function App(): JSX.Element {
const theme = useTheme();
const classes = useStyles(theme);
const matchesSM = useMediaQuery(theme.breakpoints.down('sm'));
Expand Down
21 changes: 10 additions & 11 deletions src/SimpleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,29 @@ type SimpleCardProps = {
version?: string;
};

// return the #.#.# version number as a promise
// return empty string if unsuccessful
function fetchNpmVersion(packageName: string): Promise<string> {
return fetch(`https://api.npms.io/v2/package/${encodeURIComponent(packageName)}`)
.then((res) => res.json())
.then((json) => {
let version = '-.-.-';
try {
version = json.collected.metadata.version;
} catch (e) {
} finally {
return version;
} catch (err) {
version = '';
}
return version;
});
}

export function SimpleCard(props: SimpleCardProps) : JSX.Element {
export function SimpleCard(props: SimpleCardProps): JSX.Element {
const { title, body, packageName, image, url } = props;
const theme = useTheme();
const classes = useStyles(theme);
const matchesSM = useMediaQuery(theme.breakpoints.down('sm'));
const [version, setVersion] = useState('-.-.-');
fetchNpmVersion(packageName)
.then(
(_version) => setVersion(_version)
);
fetchNpmVersion(packageName).then((_version) => setVersion(_version));
return (
<a className={classes.wrapper} href={url} style={matchesSM ? { width: 'auto', maxWidth: 600 } : undefined}>
<div className={classes.image} style={{ backgroundImage: `url("${image}")` }} />
Expand All @@ -92,12 +91,12 @@ export function SimpleCard(props: SimpleCardProps) : JSX.Element {
{body}
</Typography>
<div style={{ flex: '1 1 0' }} />
<Typography className={classes.footer} variant={'subtitle2'} noWrap={true}>
<Typography className={classes.footer} variant={'subtitle2'} noWrap={true}>
{packageName}
</Typography>
<Typography className={classes.footer} variant={'subtitle2'}>
{version && <Typography className={classes.footer} variant={'subtitle2'}>
v{version}
</Typography>
</Typography>}
<Button style={{ fontWeight: 600, marginTop: 8 }} color="primary">
Check API
</Button>
Expand Down

0 comments on commit 10c9871

Please sign in to comment.