Skip to content

WIP chore: Better demo #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,077 changes: 9,816 additions & 2,261 deletions demo/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"private": true,
"dependencies": {
"idm-wallet": "file:..",
"lodash": "^4.17.11",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-scripts": "2.1.5"
"react-scripts": "2.1.5",
"react-syntax-highlighter": "^11.0.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion demo/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>IDM Example Wallet</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
35 changes: 35 additions & 0 deletions demo/src/shared/components/console/Console.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.console {
position: relative;
flex: 0 0 300px;
margin-top: auto;
border-radius: 5px 0 0 25px;
box-shadow: 0 0 10px 1px grey;
overflow: scroll;
background-color: #141922 !important;
}

.console > pre {
margin: 0 !important;
padding: 20px !important;
min-height: 100% !important;
border: 0 !important;
border-radius: 0 !important;
background-color: #141922 !important;
}

.console > .controls {
position: absolute;
top: 0;
right: 0;
width: 60px;
background-color: white;
opacity: 0.7;
display:flex;
justify-content: space-between;
border-radius: 0 0 0 3px;

}

.console > .controls > button {
border-radius: 0;
}
29 changes: 29 additions & 0 deletions demo/src/shared/components/console/Console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { twilight } from 'react-syntax-highlighter/dist/esm/styles/prism';
import styles from './Console.css';

const Console = ({ logData, forward, backward }) => {
return (
<div className="console">
{ logData &&
<SyntaxHighlighter language="javascript" style={twilight}>
{JSON.stringify(logData, null, 2)}
</SyntaxHighlighter>
}
<div className="controls">
<button onClick={ backward }>&lt;</button>
<button onClick={ forward }>&gt;</button>
</div>
</div>
);
}

Console.propTypes = {
logData: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
forward: PropTypes.func,
backward: PropTypes.func,
};

export default Console;
19 changes: 19 additions & 0 deletions demo/src/shared/components/generic-card/GenericCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.card {
position: relative;
display: inline-flex;
background: white;
padding: 15px;
border-radius: 5px;
box-shadow: 0px 10px 23px 7px rgba(0,0,0,0.14);
}

.card::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background-color: #4076C5;
border-radius: 5px 5px 0 0;
}
16 changes: 16 additions & 0 deletions demo/src/shared/components/generic-card/GenericCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import './GenericCard.css';

const GenericCard = ({ className, children }) => {
const classNames = !className ? 'card' : `card ${className}`;
return (
<div className={ classNames }>{ children }</div>
)
}

GenericCard.propTypes = {
className: PropTypes.string,
}

export default GenericCard;
90 changes: 57 additions & 33 deletions demo/src/shared/components/wallet/wallet-content/WalletContent.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,82 @@
display: flex;
flex-direction: row;

background-color: #131923;

text-align: start;
font-family: 'Times New Roman', Times, serif;
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
}

.WalletContent .leftBar {
flex-basis: 60px;
.WalletContent .menu {
width: 224px;
color: whitesmoke;
flex-shrink: 0;
}

.WalletContent .container {
flex-grow: 1;
.WalletContent .menu h1,
.WalletContent .menu .timer {
margin-bottom: 50px;
}

.WalletContent .container .top {
height: 40vh;
background-color: #F3ECE5;
overflow: hidden;
.WalletContent .menu .timer {
font-size: 26px;
}

.WalletContent .container .top .timer {
font-size: 100px;
margin: 20px;
.WalletContent .menu > *:not(.links) {
padding: 0 30px;
}

.WalletContent .container .top .timer::before {
content: 'Current Session:';
display: block;
font-size: 30px;
.WalletContent .menu .links {
display: flex;
flex-direction: column;
}

.WalletContent .container .bottom {
height: 60vh;
display: flex;
overflow: hidden;
background-color: #334A43;
color: rgb(201,213,210);
.WalletContent .menu .links .button {
will-change: color;
position: relative;
font-size: 16px;
padding: 15px 30px;
background-color: #131923;
color: grey;
border: none;
cursor: pointer;
margin-bottom: 15px;
outline: 0;
transition: color 0.3s ease;
}

.WalletContent .container .bottom .section {
flex-grow: 1;
max-width: 500px;
padding: 30px;
box-sizing: border-box;
.WalletContent .menu .links .button:hover {
color: whitesmoke;
}

.WalletContent .container .bottom .section .content {
border: 1px solid rgb(201,213,210);
.WalletContent .menu .links .button.active {
color: whitesmoke;
background-image: linear-gradient(to right, #172232, transparent);
}

.WalletContent .container .bottom .section .content .option {
margin: 20px;
.WalletContent .menu .links .button.active::before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background-color: #4076C5;
border-radius: 0 3px 3px 0;
}

.WalletContent .container .bottom .section .content .option > * {
margin: 0 10px;
.WalletContent .menu .links .button div {
display: flex;
justify-content: flex-start;
}

.WalletContent .content {
padding: 30px 0 30px 30px;
width: calc(100vw - 224px);
background-color: #EBEBED;
display: flex;
flex-direction: column;
position: relative;
overflow-y: scroll;
}
91 changes: 81 additions & 10 deletions demo/src/shared/components/wallet/wallet-content/WalletContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,105 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Timer from '../../timer/Timer';
import { Sessions, Locker, Identities } from './sections';
import Section from './section';
import './WalletContent.css';

const links = {
IDENTITIES: 'Identities',
LOCKER: 'Locker',
SESSIONS: 'Sessions',
};

class WalletContent extends Component {
state = {
currentLink: undefined,
identitiesList: undefined,
};

componentDidMount() {
const { wallet } = this.props;

wallet.identities.load().then(() => console.log('Identities Loaded'));
wallet.identities.onChange(this.handleIdentitiesChange);
wallet.identities.load().then(this.handleIdentitiesChange);
}

render() {
const { wallet } = this.props;

return (
<div className="WalletContent">
<div className="leftBar" />
<div className="container">
<div className="top">
<Timer className="timer" locker={ wallet.locker } />
</div>
<div className="bottom">
<Locker wallet={ wallet } />
<Identities wallet={ wallet } />
<Sessions wallet={ wallet } />
<div className="menu">
<h1>IDM</h1>
<Timer className="timer" locker={ wallet.locker } />
<div className="links">
{ this.renderLinks() }
</div>
</div>
<div className="content">
{ this.renderContent() }
</div>
</div>
);
}

renderLinks() {
const { currentLink } = this.state;

return Object.values(links).map((name, index) => {
const isCurrentLink = currentLink === name;
const buttonClasses = `button ${isCurrentLink ? 'active' : '' }`;

return (
<button
key={ index }
name={ name }
className={ buttonClasses }
onClick={ this.handleLinkClick }>
<div>{ name }</div>
</button>
);
});
}

renderContent() {
const { currentLink, identitiesList } = this.state;
const { wallet } = this.props;

switch (currentLink) {
case links.LOCKER:
return (
<Section title="Locker">
<Locker wallet={ wallet } />
</Section>
);
case links.IDENTITIES:
return (
<Section title="Identities">
<Identities
identities={ identitiesList }
wallet={ wallet } />
</Section>
);
case links.SESSIONS:
return (
<Section title="Sessions">
<Sessions wallet={ wallet } />
</Section>
);
default:
return (
<p>WELCOME TO IDM UI!</p>
);
}
}

handleLinkClick = (event) => {
event.currentTarget.name && this.setState({ currentLink: event.currentTarget.name });
}

handleIdentitiesChange = (idList) => {
this.setState({ identitiesList: idList });
};
}

WalletContent.propTypes = {
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import './Section.css';

const Section = ({ title, children }) => (
<>
<h2>{ title }</h2>
{ children }
</>
);

Section.propTypes = {
title: PropTypes.string.isRequired,
children: PropTypes.node,
}

export default Section;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Section';
Loading