Skip to content

Commit

Permalink
Toolbar and header
Browse files Browse the repository at this point in the history
  • Loading branch information
TowhidKashem committed Apr 28, 2020
1 parent d38fbdc commit 5b88980
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 80,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
Expand Down
1 change: 1 addition & 0 deletions src/common/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Button: React.FC<Props> = ({
{icons ? (
icons.map((icon, index) => (
<FontAwesomeIcon
key={index}
icon={icon}
className={classNames({
[iconClasses[index] as string]: iconClasses[index]
Expand Down
2 changes: 2 additions & 0 deletions src/common/Input/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.input {
}
27 changes: 27 additions & 0 deletions src/common/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import styles from './index.module.scss';

interface Props {
placeholder: string;
leftIcon: any;
rightIcon: any;
rightIconClick: () => void;
}

const Input: React.FC<Props> = ({ placeholder, leftIcon, rightIcon, rightIconClick }) => {
const iconClick = rightIconClick
? {
onClick: rightIconClick
}
: {};
return (
<div className={styles.input}>
{leftIcon && <FontAwesomeIcon icon={leftIcon} />}
<input type="text" placeholder={placeholder} />
{rightIcon && <FontAwesomeIcon icon={rightIcon} {...iconClick} />}
</div>
);
};

export default Input;
6 changes: 3 additions & 3 deletions src/pages/Layout/Header/index.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import '../../../static/styles/vars';

.header {
position: fixed;
top: 0;
left: 0;
// position: fixed;
// top: 0;
// left: 0;

svg {
color: $color-white;
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Layout/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUserCircle } from '@fortawesome/free-solid-svg-icons';
import { faUserCircle, faSearch, faUserPlus } from '@fortawesome/free-solid-svg-icons';
import Input from '../../../common/Input';
import styles from './index.module.scss';

interface Props {
Expand All @@ -10,6 +11,12 @@ interface Props {
const Header: React.FC<Props> = ({ setToggleMenu }) => (
<header className={styles.header}>
<FontAwesomeIcon icon={faUserCircle} size="5x" onClick={setToggleMenu} />
<Input
placeholder="Search"
leftIcon={faSearch}
rightIcon={faUserPlus}
rightIconClick={() => {}}
/>
</header>
);

Expand Down
21 changes: 21 additions & 0 deletions src/pages/Layout/Toolbar/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.toolbar {
color: white;
padding: 5px 10px 10px;

display: grid;
grid-template-columns: 50% 50%;

article {
}

svg {
color: white;
margin-left: 8px;
}

.left {
}
.right {
text-align: right;
}
}
38 changes: 38 additions & 0 deletions src/pages/Layout/Toolbar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faLocationArrow,
faSignal,
faBatteryHalf
} from '@fortawesome/free-solid-svg-icons';
import styles from './index.module.scss';

const Toolbar: React.SFC<{}> = () => {
const { useState } = React;
const [time, setTime] = useState<string>();

const updateTime = () => {
const time = new Date().toLocaleTimeString('en-us', {
hour: 'numeric',
minute: '2-digit'
});
setTime(time);
};

setInterval(updateTime, 1000);

return (
<div className={styles.toolbar}>
<article className={styles.left}>
<time>{time}</time>
<FontAwesomeIcon icon={faLocationArrow} />
</article>
<article className={styles.right}>
<FontAwesomeIcon icon={faSignal} />
<FontAwesomeIcon icon={faBatteryHalf} />
</article>
</div>
);
};

export default Toolbar;
2 changes: 2 additions & 0 deletions src/pages/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import Toolbar from './Toolbar';
import Header from './Header';
import Footer from './Footer';
import Menu from './Menu';
Expand All @@ -14,6 +15,7 @@ const Layout: React.FC<Props> = ({ children }) => {

return (
<div className={styles.menu}>
<Toolbar />
<Header setToggleMenu={() => setToggleMenu(!toggleMenu)} />
<section className={styles.wrapper}>{children}</section>
<Menu
Expand Down
2 changes: 1 addition & 1 deletion src/static/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

background-color: #222;
background-color: #333;
}

a {
Expand Down

0 comments on commit 5b88980

Please sign in to comment.