Skip to content

Commit

Permalink
Add basic navigator UI
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurab13 committed Dec 1, 2019
1 parent 40d367d commit 70ae485
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 3 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
margin: 0;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="root"></div>
Expand Down
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import 'bootstrap/scss/bootstrap.scss';

const App: React.FC = () => {
return (
<TopBar />
<div className="topbar" id="topbar">
<TopBar />
</div>
);
}

Expand Down
33 changes: 33 additions & 0 deletions src/components/Navigator/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.browser-navigator {
border-right: 1px solid #dbdce4;
white-space: nowrap;
height: 32px;
button {
background: #f2f3f5;
cursor: pointer;
border: 0;
padding: 4px 4px 0 4px;
&:focus,
&:active {
outline: none;
}
i {
width: 24px;
height: 24px;
font-size: 16px;
color: #646575;
&:hover {
color: #272833;
}
}
}
.disabled-btn {
cursor: default;
i {
color: #9fa1b3;
&:hover {
color: #9fa1b3;
}
}
}
}
65 changes: 65 additions & 0 deletions src/components/Navigator/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useEffect } from 'react';
import './index.scss';

interface IProps {
isLoading: boolean;
canGoBack: boolean;
canGoForward: boolean;
}

export const Navigator: React.FunctionComponent<IProps> = props => {
// useEffect(() => {
// updateNavigationState();
// }, []);

const handlePageviewReload = () => {
// reloadPageView();
console.log("yo")
};

const handleStopPageviewReload = () => {
// stopPageViewReload();
console.log("yo")
};

const handleOnBackClick = () => {
// goBacktoPreviousPageView();
console.log("yo")
};

const handleOnForwardClick = () => {
// goForwardtoNextPageView();
console.log("yo")
};

return (
<div className="browser-navigator px-1">
<button
className={`go-backward ${props.canGoBack ? '' : 'disabled-btn'}`}
onClick={() => handleOnBackClick()}
disabled={!props.canGoBack}
>
<i className="fa fa-arrow-left" />
</button>

<button
className={`go-forward ${props.canGoForward ? '' : 'disabled-btn'}`}
onClick={() => handleOnForwardClick()}
disabled={!props.canGoForward}
>
<i className="fa fa-arrow-right" />
</button>
{props.isLoading ? (
<button className="stop-page-reload" onClick={() => handleStopPageviewReload()}>
<i className="fa fa-times" />
</button>
) : (
<button className="reload-page" onClick={() => handlePageviewReload()}>
<i className="fa fa-repeat" />
</button>
)}
</div>
);
};

export default Navigator;
2 changes: 1 addition & 1 deletion src/components/TopBar/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
padding: 3px;
.form-control {
font-size: 14px;
border-radius: 2px;
border: none;
height: 28px;
background: #f8f8fa;
&:focus {
Expand Down
8 changes: 7 additions & 1 deletion src/components/TopBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import './index.scss';
import Navigator from '../Navigator';

type ActionCreator = (...args: any[]) => void;

Expand Down Expand Up @@ -32,6 +33,11 @@ export const TopBar: React.FunctionComponent<IProps> = props => {
return (
<div>
<div className="d-flex flex-row tab-container">
<Navigator
canGoBack={true}
canGoForward={false}
isLoading={true}
/>
{urls.map((url, index) => {
const activeClass = index === activeTabIndex ? 'active' : '';
return (
Expand All @@ -49,7 +55,7 @@ export const TopBar: React.FunctionComponent<IProps> = props => {
<input
type="text"
className="form-control"
value={'url'}
value={urls[activeTabIndex]}
/>
</div>
</div>
Expand Down

0 comments on commit 70ae485

Please sign in to comment.