Skip to content

Commit

Permalink
#100 - Added floating link bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Parrello committed Apr 3, 2019
1 parent a29cafa commit 9dbc1d8
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 9 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
REACT_APP_GOOGLE_TAG_MANAGER_CONTAINER_ID=GTM-XXXXXX

NODE_PATH=src/

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"swagger-ui": "^3.18.2"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.17",
"@fortawesome/free-brands-svg-icons": "^5.8.1",
"@fortawesome/react-fontawesome": "^0.1.4",
"cookieconsent": "^3.1.0",
"node-sass-chokidar": "^1.3.4",
"react-scripts": "^2.1.8"
Expand All @@ -28,4 +31,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
12 changes: 12 additions & 0 deletions src/assets/images/icon-together.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/helpers/bunqIcons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/plugins/BunqLayoutPlugin/BunqLayoutPlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @flow
import BunqLayout from "plugins/BunqLayoutPlugin/components/BunqLayout/BunqLayout";
import Floater from "plugins/BunqLayoutPlugin/components/Floater/Floater";
import FloaterItem from "plugins/BunqLayoutPlugin/components/FloaterItem/FloaterItem";
import Sidebar from "plugins/BunqLayoutPlugin/components/Sidebar/Sidebar";
import SidebarItem from "plugins/BunqLayoutPlugin/components/SidebarItem/SidebarItem";

Expand Down Expand Up @@ -139,6 +141,8 @@ const BunqLayoutPlugin = (): Object => {
return {
components: {
BunqLayout: BunqLayout,
Floater: Floater,
FloaterItem: FloaterItem,
Sidebar: Sidebar,
SidebarItem: SidebarItem
},
Expand Down
15 changes: 11 additions & 4 deletions src/plugins/BunqLayoutPlugin/components/BunqLayout/BunqLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BunqLayout extends React.Component {
return (
<div className="doc-wrapper">
{
this.renderSidebar()
this.renderAllElementAfterInitialization()
}
<BaseLayout />
</div>
Expand All @@ -25,13 +25,20 @@ class BunqLayout extends React.Component {
/**
* @returns {Node}
*/
renderSidebar (): Node {
renderAllElementAfterInitialization (): Node {
const { getComponent } = this.props;
const Sidebar = getComponent("Sidebar", true);
const loadingStatus = this.props.specSelectors.loadingStatus();

const Sidebar = getComponent("Sidebar", true);
const Floater = getComponent("Floater", true);

if ("success" === loadingStatus) {
return <Sidebar {...this.props} />;
return (
<div>
<Sidebar {...this.props} />
<Floater {...this.props} />
</div>
);
} else {
return null;
}
Expand Down
74 changes: 74 additions & 0 deletions src/plugins/BunqLayoutPlugin/components/Floater/Floater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from "react";
import { library, dom } from "@fortawesome/fontawesome-svg-core";
import {
faGithub,
faStackOverflow
} from "@fortawesome/free-brands-svg-icons";

import { iconTogether } from "helpers/bunqIcons";

/**
* @author Nicola Parrello <[email protected]>
* @since 20190402 Initial creation.
*/
class Floater extends React.Component {
/**
* @type {Object[]}
*/
static allResource = [
{
destination: "https://github.com/bunq",
name: "GitHub",
icon: "github"
},
{
destination: "https://stackoverflow.com/search?q=bunq",
name: "Stack Overflow",
icon: "stack-overflow"
},
{
destination: "https://together.bunq.com/t/api",
name: "bunq Together",
icon: "together"
}
];

/**
* @param {Object} props
*/
constructor (props: Object) {
super(props);

library.add([
faGithub,
faStackOverflow,
iconTogether
]);

dom.watch();
}

/**
* @returns {Node}
*/
render (): Node {
const { getComponent } = this.props;
const FloaterItem = getComponent("FloaterItem", true);

return (
<div className="floater">
<div className="floater-list">
{
Floater.allResource.map((resource: Object, index: number): Element => {
return (
<FloaterItem key={ index } resource={ resource } />
);
})
}
</div>
</div>
);
}
}

export default Floater;
44 changes: 44 additions & 0 deletions src/plugins/BunqLayoutPlugin/components/FloaterItem/FloaterItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

/**
* @author Nicola Parrello <[email protected]>
* @since 20190403 Initial creation.
*/
class FloaterItem extends React.Component {
/**
* @param {Object} props
*/
constructor (props: Object) {
super(props);

const { resource } = props;

this.state = {
destination: resource.destination,
name: resource.name,
icon: resource.icon
};
}

/**
* @returns {Node}
*/
render (): Node {
return (
<div className={ "floater-item" }>
<a href={ this.state.destination } target={ "_blank" }>
<FontAwesomeIcon
icon={
["fab", this.state.icon]
}
title={ this.state.name }
size={ "3x" }
/>
</a>
</div>
);
}
}

export default FloaterItem;
47 changes: 47 additions & 0 deletions src/scss/_floater.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@import "variables";

$border-radius-floater: 8px;

.floater {
position: fixed;
top: 25%;
right: 0;
display: none;
border-top-left-radius: $border-radius-floater;
border-bottom-left-radius: $border-radius-floater;
background-color: $color-grey-dark;

@media (min-width: $width-viewport-small) {
display: flex;
}

.floater-list {
display: flex;
flex-direction: column;
justify-content: center;
padding-left: 0;
margin: $spacer-small;
list-style: none;

.floater-item {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: $spacer-medium;

&:last-of-type {
margin-bottom: 0;
}

a {
color: $color-white;
font-size: $font-size-sidebar-item;
text-decoration: none;

&:hover {
text-decoration: underline;
}
}
}
}
}
16 changes: 13 additions & 3 deletions src/scss/_type.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "variables";

.floater,
.sidebar,
.swagger-ui {
font-family: "Open Sans", sans-serif !important;
Expand Down Expand Up @@ -64,13 +65,22 @@
}
}

h1,
h2.title {
padding-top: $margin-top-h1;
h1 {
padding-top: $margin-top-h1 / 2;

@media (min-width: $width-viewport-small) {
padding-top: $margin-top-h1;
}
}

h2 {
margin-top: $margin-top-h2;

&.title {
@media (min-width: $width-viewport-small) {
padding-top: $margin-top-h1;
}
}
}

h3 {
Expand Down
1 change: 1 addition & 0 deletions src/scss/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "cookie-consent";
@import "custom";
@import "floater";
@import "sidebar";
@import "type";
@import "variables";
Expand Down
32 changes: 32 additions & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9dbc1d8

Please sign in to comment.