Skip to content

Commit 8640d77

Browse files
authored
Merge pull request #95 from Lemoncode/#92--Remove-links-from-appbar-and-footer-when-session-is-on
Remove links from appbar and footer during session
2 parents 31f0e52 + cd9e054 commit 8640d77

9 files changed

Lines changed: 101 additions & 54 deletions

File tree

‎front/src/common-app/components/appbar/appbar.component.tsx‎

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,44 @@ import React from 'react';
22
import { ReactComponent as CodePasterLogo } from 'assets/logo.svg';
33
import * as classes from './appbar.styles';
44

5-
export const AppbarComponent: React.FC = () => {
6-
const { appbarContainer, navList, listItem, link, logo } = classes;
5+
interface Props {
6+
showLinks: boolean;
7+
}
8+
9+
export const AppbarComponent: React.FC<Props> = ({ showLinks }) => {
10+
const {
11+
appbarContainer,
12+
navContainer,
13+
navList,
14+
listItem,
15+
link,
16+
logo,
17+
} = classes;
18+
console.log(showLinks);
719
return (
8-
<>
9-
<nav className={appbarContainer}>
10-
<CodePasterLogo className={logo} />
11-
<ul className={navList}>
12-
<li className={listItem}>
13-
<a className={link} href="#">
14-
About
15-
</a>
16-
</li>
17-
<li className={listItem}>
18-
<a className={link} href="#">
19-
Credits
20-
</a>
21-
</li>
22-
<li className={listItem}>
23-
<a className={link} href="#">
24-
License
25-
</a>
26-
</li>
27-
</ul>
28-
</nav>
29-
</>
20+
<div className={appbarContainer}>
21+
<CodePasterLogo className={logo} />
22+
{showLinks && (
23+
<nav className={navContainer}>
24+
<ul className={navList}>
25+
<li className={listItem}>
26+
<a className={link} href="#">
27+
About
28+
</a>
29+
</li>
30+
<li className={listItem}>
31+
<a className={link} href="#">
32+
Credits
33+
</a>
34+
</li>
35+
<li className={listItem}>
36+
<a className={link} href="#">
37+
License
38+
</a>
39+
</li>
40+
</ul>
41+
</nav>
42+
)}
43+
</div>
3044
);
3145
};

‎front/src/common-app/components/appbar/appbar.styles.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ export const logo = css`
2323
margin-left: 2.4rem;
2424
`;
2525

26+
export const navContainer = css`
27+
margin-left: auto;
28+
`;
29+
2630
export const navList = css`
2731
display: flex;
28-
margin-left: auto;
2932
list-style: none;
3033
`;
3134

‎front/src/common-app/components/footer/footer.component.tsx‎

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import TwitterIcon from '@material-ui/icons/Twitter';
66
import EmailRoundedIcon from '@material-ui/icons/EmailRounded';
77
import LanguageIcon from '@material-ui/icons/Language';
88

9-
export const FooterComponent: React.FC = () => {
9+
interface Props {
10+
showLinks: boolean;
11+
}
12+
13+
export const FooterComponent: React.FC<Props> = ({ showLinks }) => {
1014
const {
1115
footerContainer,
1216
topContainer,
17+
topContainerCenter,
1318
linkList,
1419
link,
1520
lemoncodeIcon,
@@ -22,26 +27,28 @@ export const FooterComponent: React.FC = () => {
2227
} = classes;
2328
return (
2429
<footer className={footerContainer}>
25-
<div className={topContainer}>
26-
<nav>
27-
<ul className={linkList}>
28-
<li>
29-
<a className={link} href="#">
30-
About
31-
</a>
32-
</li>
33-
<li>
34-
<a className={link} href="#">
35-
Credits
36-
</a>
37-
</li>
38-
<li>
39-
<a className={link} href="#">
40-
License
41-
</a>
42-
</li>
43-
</ul>
44-
</nav>
30+
<div className={showLinks ? topContainer : topContainerCenter}>
31+
{showLinks && (
32+
<nav>
33+
<ul className={linkList}>
34+
<li>
35+
<a className={link} href="#">
36+
About
37+
</a>
38+
</li>
39+
<li>
40+
<a className={link} href="#">
41+
Credits
42+
</a>
43+
</li>
44+
<li>
45+
<a className={link} href="#">
46+
License
47+
</a>
48+
</li>
49+
</ul>
50+
</nav>
51+
)}
4552
<LemoncodeLogo className={lemoncodeIcon} />
4653
</div>
4754
<div className={bottomContainer}>

‎front/src/common-app/components/footer/footer.styles.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ export const topContainer = css`
1919
align-items: center;
2020
`;
2121

22+
export const topContainerCenter = css`
23+
padding: 0 1rem;
24+
display: flex;
25+
justify-content: center;
26+
align-items: center;
27+
height: ${spacing(195)};
28+
`;
29+
2230
export const linkList = css`
2331
padding: 0;
2432
margin: 0;

‎front/src/layout/app-layout.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from 'react';
22
import { AppbarComponent, FooterComponent } from 'common-app';
33

44
export const AppLayout: React.FC = props => {
5+
const [showLinks, setShowLinks] = React.useState<boolean>(true);
56
return (
67
<>
7-
<AppbarComponent />
8+
<AppbarComponent showLinks={showLinks} />
89
{props.children}
9-
<FooterComponent />
10+
<FooterComponent showLinks={showLinks} />
1011
</>
1112
);
1213
};

‎front/src/layout/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './app-layout';
2+
export * from './session-layout';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { AppbarComponent, FooterComponent } from 'common-app';
3+
4+
export const SessionLayout: React.FC = props => {
5+
const [showLinks, setShowLinks] = React.useState<boolean>(false);
6+
return (
7+
<>
8+
<AppbarComponent showLinks={showLinks} />
9+
{props.children}
10+
<FooterComponent showLinks={showLinks} />
11+
</>
12+
);
13+
};

‎front/src/scenes/student.scene.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { AppLayout } from 'layout';
2+
import { SessionLayout } from 'layout';
33
import { PlayerContainer } from 'pods/student';
44

55
export const StudentScene = () => {
@@ -8,8 +8,8 @@ export const StudentScene = () => {
88
}, []);
99

1010
return (
11-
<AppLayout>
11+
<SessionLayout>
1212
<PlayerContainer />
13-
</AppLayout>
13+
</SessionLayout>
1414
);
1515
};

‎front/src/scenes/trainer.scene.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
2+
import { SessionLayout } from 'layout';
23
import { TrainerContainer } from 'pods/trainer';
3-
import { AppLayout } from 'layout';
44

55
export const TrainerScene: React.FC = () => {
66
React.useEffect(() => {
77
document.title = `Trainer - Code Paster`;
88
}, []);
99

1010
return (
11-
<AppLayout>
11+
<SessionLayout>
1212
<TrainerContainer />
13-
</AppLayout>
13+
</SessionLayout>
1414
);
1515
};

0 commit comments

Comments
 (0)