Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into update-new-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkholic authored Oct 30, 2018
2 parents 9fc52d4 + 7411a9b commit a85987f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 26 deletions.
44 changes: 25 additions & 19 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import React from "react";
import React, { Fragment } from "react";

import Loading from "./common/Loading";
import ErrorView from "./common/ErrorView";
import InfoView from "./common/InfoView";
import Welcome from "./Welcome";
import Gallery from "./Gallery";

const Loading = () => (
<div className="bp3-progress-bar bp3-intent-primary">
<div className="bp3-progress-meter" />
</div>
);
const ErrorView = error => <div>{error}</div>;

const App = ({
fonts,
flags,
installedFonts,
error,
announcement,
isUserRegistered,
registerUser,
installFont,
Expand All @@ -22,22 +20,30 @@ const App = ({
registering,
loading
}) => {
if (error) return <ErrorView error={error} />;
if (loading) return <Loading />;

if (isUserRegistered)
return (
<Gallery
loading={loading}
fonts={fonts}
flags={flags}
installedFonts={installedFonts}
installFont={installFont}
updateFont={updateFont}
uninstallFont={uninstallFont}
/>
<Fragment>
<ErrorView error={error} />
<InfoView announcement={announcement} />
<Gallery
fonts={fonts}
flags={flags}
installedFonts={installedFonts}
installFont={installFont}
updateFont={updateFont}
uninstallFont={uninstallFont}
/>
</Fragment>
);
return <Welcome registering={registering} registerUser={registerUser} />;
return (
<Fragment>
<ErrorView error={error} />
<InfoView announcement={announcement} />
<Welcome registering={registering} registerUser={registerUser} />
</Fragment>
);
};

export default App;
8 changes: 3 additions & 5 deletions src/components/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import styled from "styled-components";
import { Button, Switch, Card, Elevation } from "@blueprintjs/core";
import find from "lodash/find";

import Loading from "./common/Loading";

// Styles
const Wrapper = styled.div`
height: 100vh;
Expand Down Expand Up @@ -134,11 +136,7 @@ class Gallery extends Component {
return (
<CardContent className="card-style" key={id}>
<Content elevation={Elevation.TWO}>
{flags[id] && (
<div className="bp3-progress-bar bp3-intent-primary">
<div className="bp3-progress-meter" />
</div>
)}
{flags[id] && <Loading />}

<FontImage src={coverImageUrl} />
<SettingsContent>
Expand Down
18 changes: 18 additions & 0 deletions src/components/common/ErrorView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import styled from "styled-components";

// Styles
const Error = styled.div`
color: white;
text-align: center;
background-color: red;
padding: 5px 0;
font-size: 11px;
`;

const ErrorView = ({ error }) => {
if (!error) return null;
return <Error>{error}</Error>;
};

export default ErrorView;
30 changes: 30 additions & 0 deletions src/components/common/InfoView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import styled from "styled-components";

const electron = window.require("electron");

// Styles
const Announcement = styled.div`
color: white;
text-align: center;
background-color: green;
padding: 5px 0;
font-size: 11px;
cursor: pointer;
`;

const openExternalLink = url => {
if (!url) return;
electron.shell.openExternal(url);
};

const InfoView = ({ announcement }) => {
if (!announcement) return null;
const { text, href } = announcement || {};
if (!text) return null;
return (
<Announcement onClick={() => openExternalLink(href)}>{text}</Announcement>
);
};

export default InfoView;
9 changes: 9 additions & 0 deletions src/components/common/Loading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

const Loading = () => (
<div className="bp3-progress-bar bp3-intent-primary">
<div className="bp3-progress-meter" />
</div>
);

export default Loading;
4 changes: 2 additions & 2 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AppContainer extends React.Component {
(
error,
{
announcement,
announcements,
fonts,
installedFonts,
flags,
Expand All @@ -44,7 +44,7 @@ class AppContainer extends React.Component {
}
) => {
this.setState(() => ({
announcement,
announcement: announcements && announcements[0],
fonts,
installedFonts,
flags,
Expand Down

0 comments on commit a85987f

Please sign in to comment.