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

Commit

Permalink
Kwun/banners (#504)
Browse files Browse the repository at this point in the history
* update version and change log

* add banner support with remote settings

* update changelog

* remove console log
  • Loading branch information
kwunyeung committed Apr 22, 2021
1 parent c0a0cbe commit 348cddd
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [Unreleased]
## v0.41.x-9
* Added banner support. Banner settings are loading remotely from the url defined in settings.
## v0.41.x-8

* [#487] Fixed typo in the query which make validator power change tx lookup failed.
* Fixed an issue on displaying individual transaction.
Expand Down
11 changes: 11 additions & 0 deletions client/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ body {
&#main, &#transaction, &#block {
padding-top: 6rem;
padding-bottom: 3.85rem;

.banner {
a {
display: block;
width: 100%;

img {
max-width: 100%
}
}
}
}

&#transaction .card.card-body {
Expand Down
4 changes: 3 additions & 1 deletion default_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
"gov": true,
"distribution": false
},
"coingeckoId": "cosmos"
"coingeckoId": "cosmos",
"networks": "https://gist.githubusercontent.com/kwunyeung/8be4598c77c61e497dfc7220a678b3ee/raw/bd-networks.json",
"banners": false
},
"remote":{
"rpc":"https://rpc.stargate.forbole.com:443",
Expand Down
2 changes: 2 additions & 0 deletions imports/ui/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import SearchBar from '/imports/ui/components/SearchBar.jsx';
import moment from 'moment';
import SentryBoundary from '/imports/ui/components/SentryBoundary.jsx';
import NotFound from '/imports/ui/pages/NotFound.jsx';
import Banners from '/imports/ui/components/Banners.jsx';

import { ToastContainer, toast } from 'react-toastify';

Expand Down Expand Up @@ -78,6 +79,7 @@ class App extends Component {
{(Meteor.settings.public.gtm)?<GoogleTagManager gtmId={Meteor.settings.public.gtm} />:''}
<RouteHeader refreshApp={this.propagateStateChange}/>
<Container fluid id="main">
{(Meteor.settings.public.banners)?<Banners url={Meteor.settings.public.banners}/>:''}
<ToastContainer />
<SentryBoundary>
<MobileSearchBar />
Expand Down
46 changes: 46 additions & 0 deletions imports/ui/components/Banners.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { HTTP } from 'meteor/http'
import { Container, Row, Col } from 'reactstrap';

export default class Banners extends React.Component {
constructor(props) {
super(props);
this.state = {
banners: []
}
}
componentDidMount(){
const url = this.props.url;
HTTP.get(url, (error, result) => {
if (result.statusCode == 200){
let banners = JSON.parse(result.content);
if (banners.banners && (banners.banners.length > 0)){
this.setState({
banners: banners.banners
})
}
}
})

}

render() {
if (this.state.banners.length>0){
const bannerIndex = Math.floor(Math.random()*this.state.banners.length);
const banner = this.state.banners[bannerIndex];
return (
<Container fluid className="banner mb-3 text-center">
<Row>
<Col className="d-none d-xl-block"><a href={banner.url} target="_blank"><img src={banner.images.lg} /></a></Col>
<Col className="d-none d-md-block d-xl-none"><a href={banner.url} target="_blank"><img src={banner.images.md} /></a></Col>
<Col className="d-block d-md-none"><a href={banner.url} target="_blank"><img src={banner.images.xs} /></a></Col>
</Row>
</Container>
);

}
else{
return <div></div>
}
}
}
2 changes: 1 addition & 1 deletion private/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.41.x-7
v0.41.x-8

0 comments on commit 348cddd

Please sign in to comment.