-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from DemocracyEarth/dapp
Dynamic Sidebar Menu
- Loading branch information
Showing
20 changed files
with
609 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ | |
"email-username": "E-mail", | ||
"email-sample": "[email protected]", | ||
"password-sample": "make it long.", | ||
"sign-in": "Sign In", | ||
"sign-in": "Connect Wallet", | ||
"password": "Password", | ||
"please-wait": "Please wait...", | ||
"use-social-media": "or use:", | ||
|
@@ -889,5 +889,23 @@ | |
"voted-no": "{{shares}} {{label}} for <strong>No</strong> to {{proposal}}", | ||
"shares": "shares", | ||
"share": "share", | ||
"arrow-verb": " → " | ||
"arrow-verb": " → ", | ||
"overview": "Overview", | ||
"recent": "Recent", | ||
"in-queue": "In Queue", | ||
"voting-now": "Voting Now", | ||
"grace-period": "Grace Period", | ||
"ready-to-process": "Ready to process", | ||
"rejected": "Rejected", | ||
"approved": "Approved", | ||
"quits": "Quits", | ||
"jailed": "Jailed", | ||
"kicked": "Kicked", | ||
"sponsored": "Sponsored", | ||
"guild-kicks": "Guild Kicks", | ||
"proposals-account": "Proposals by {{account}}", | ||
"memberships-account": "Memberships of {{account}}", | ||
"proposals-sidebar": "Recent Proposals", | ||
"memberships-sidebar": "Your Memberships", | ||
"no-memberships-found": "No DAO memberships found." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Router } from 'meteor/iron:router'; | ||
|
||
import { getTemplateImage } from '/imports/ui/templates/layout/templater.js'; | ||
|
||
/** | ||
* @summary checks if href matches to current url | ||
* @param {string} url with href to match | ||
* @return {boolean} | ||
*/ | ||
const _matchingContext = (url) => { | ||
if (url) { | ||
const current = Router.current().url.replace(window.location.origin, ''); | ||
if ((Router.current().params.username === url.substring(6)) | ||
|| (current === url) | ||
) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
|
||
/** | ||
* @summary displays the contents of a poll | ||
*/ | ||
export default class Item extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
inContext: _matchingContext(this.props.href), | ||
icon: { | ||
paper: '', | ||
paperActive: '', | ||
}, | ||
}; | ||
} | ||
|
||
async componentDidMount() { | ||
await this.setIcons(); | ||
} | ||
|
||
async setIcons() { | ||
this.setState({ | ||
icon: { | ||
paper: await getTemplateImage('paper'), | ||
paperActive: await getTemplateImage('paper-active'), | ||
}, | ||
}); | ||
} | ||
|
||
getLabel() { | ||
if (this.props.children) { | ||
return this.props.children; | ||
} | ||
return (this.props.label); | ||
} | ||
|
||
getStyle() { | ||
return `menu-item ${this.state.inContext ? 'menu-item-selected' : null}`; | ||
} | ||
|
||
getTagStyle() { | ||
return `sidebar-tag ${this.state.inContext ? 'sidebar-tag-selected' : null}`; | ||
} | ||
|
||
getIcon() { | ||
return (this.state.inContext) ? this.state.icon.paperActive : this.state.icon.paper; | ||
} | ||
|
||
getLabelStyle() { | ||
if (this.props.children) { | ||
return `sidebar-label sidebar-label-${this.props.children.type.name.toLowerCase()}`; | ||
} | ||
return 'sidebar-label'; | ||
} | ||
|
||
render() { | ||
if (this.props.hideEmpty && this.props.score === 0) return null; | ||
return ( | ||
<a className={this.getStyle()} href={this.props.href}> | ||
{(this.props.sharp) ? | ||
<div className="sidebar-sharp"> | ||
<img src={this.getIcon()} role="presentation" className="menu-item-icon" /> | ||
</div> | ||
: | ||
null | ||
} | ||
<div className={this.getLabelStyle()}> | ||
{this.getLabel()} | ||
</div> | ||
<div className={this.getTagStyle()}> | ||
{this.props.score} | ||
</div> | ||
</a> | ||
); | ||
} | ||
} | ||
|
||
Item.propTypes = { | ||
sharp: PropTypes.bool, | ||
label: PropTypes.string, | ||
score: PropTypes.number, | ||
hideEmpty: PropTypes.bool, | ||
href: PropTypes.string, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]), | ||
}; | ||
|
Oops, something went wrong.