Skip to content

Commit b92e545

Browse files
author
k.golikov
committed
Add "hide the footer" option
1 parent 9594170 commit b92e545

File tree

9 files changed

+102
-22
lines changed

9 files changed

+102
-22
lines changed

src/hooks/useAppSettings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { useEffect, useMemo } from 'react';
77
const initialState: AppSettings = {
88
theme: SpecialAppTheme.AUTO,
99
isErudaEnabled: false,
10-
doShowHiddenMenuItems: false
10+
doShowHiddenMenuItems: false,
11+
isFooterHidden: false
1112
};
1213

1314
export const useAppSettingsState = () => {

src/layouts/appLayout/AppLayout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ import styles from './AppLayout.module.scss';
55
import AppHeader from './components/appHeader/AppHeader';
66
import AppSider from './components/appSider/AppSider';
77
import AppFooter from './components/appFooter/AppFooter';
8+
import useAppSettings from '../../hooks/useAppSettings';
9+
import useAppLocation from '../../hooks/useAppLocation';
10+
import { routes } from '../../constants/router/routes';
811

912
const AppLayout: FunctionComponent = ({ children }) => {
13+
const { isFooterHidden } = useAppSettings();
14+
const appRoute = useAppLocation();
15+
16+
const isFooterShown = !isFooterHidden || appRoute === routes.root;
17+
1018
return (
1119
<Layout className={styles.container}>
1220
<AppHeader />
1321
<Layout className={styles.mainLayout}>
1422
<AppSider />
1523
<Content className={styles.contentContainer}>{children}</Content>
1624
</Layout>
17-
<AppFooter />
25+
{isFooterShown && <AppFooter />}
1826
</Layout>
1927
);
2028
};

src/layouts/appLayout/components/appFooter/AppFooter.module.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../../../../styles/main';
2+
13
.container {
24
background: #212121 !important;
35
color: white !important;
@@ -8,10 +10,31 @@
810
align-items: center;
911
gap: 16px;
1012

13+
padding-left: 26px;
14+
padding-right: 26px;
15+
16+
justify-content: space-between;
17+
18+
@include mediaSM {
19+
justify-content: flex-start;
20+
}
21+
22+
@include mediaLG {
23+
padding-left: 50px;
24+
padding-right: 50px;
25+
}
26+
1127
.copyright {
1228
margin-right: 10px;
1329
}
1430

31+
.socials {
32+
display: flex;
33+
flex-direction: row;
34+
justify-content: flex-start;
35+
gap: 16px;
36+
}
37+
1538
.link {
1639
&,
1740
& > * {

src/layouts/appLayout/components/appFooter/AppFooter.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
import React from 'react';
2-
import { Footer } from 'antd/lib/layout/layout';
1+
import React, { FunctionComponent } from 'react';
2+
import { BasicProps, Footer } from 'antd/lib/layout/layout';
33
import styles from './AppFooter.module.scss';
44
import moment from 'moment';
55
import ExternalLink from '../../../../components/ExternalLink';
66
import { GithubFilled } from '@ant-design/icons';
77
import { ReactComponent as TelegramLogoDark } from '../../../../assets/img/telegram-logo-dark-2.svg';
8+
import classNames from 'classnames';
89

910
const currentYear = moment().year();
1011

11-
const AppFooter = () => {
12+
type Props = BasicProps;
13+
14+
const AppFooter: FunctionComponent<Props> = ({ className, ...props }) => {
1215
return (
13-
<Footer className={styles.container}>
16+
<Footer className={classNames(styles.container, className)} {...props}>
1417
<div className={styles.copyright}>Kirill Golikov © {currentYear}</div>
15-
<ExternalLink href="https://github.com/MRGRD56">
16-
<GithubFilled className={styles.link} />
17-
</ExternalLink>
18-
<ExternalLink href="https://t.me/MRGRD56">
19-
<TelegramLogoDark className={styles.link} />
20-
</ExternalLink>
18+
<div className={styles.socials}>
19+
<ExternalLink href="https://github.com/MRGRD56">
20+
<GithubFilled className={styles.link} />
21+
</ExternalLink>
22+
<ExternalLink href="https://t.me/MRGRD56">
23+
<TelegramLogoDark className={styles.link} />
24+
</ExternalLink>
25+
</div>
2126
</Footer>
2227
);
2328
};

src/layouts/pages/pageContainer/PageContainer.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum PageTag {
1111
}
1212

1313
export interface PageContainerProps extends Omit<SpaceProps, 'title'> {
14+
contentClassName?: string;
1415
title?: ReactNode;
1516
description?: ReactNode;
1617
titleExtra?: ReactNode;
@@ -35,8 +36,18 @@ const getTagNodes = (key: number | string): Readonly<Record<PageTag, ReactNode>>
3536
const renderTag = (tag: PageTag, index: number) => getTagNodes(index)[tag];
3637

3738
const PageContainer: FunctionComponent<PageContainerProps> = (props) => {
38-
const { title, description, titleExtra, tags, noPadding, noContentPadding, children, className, ...restProps } =
39-
props;
39+
const {
40+
title,
41+
description,
42+
titleExtra,
43+
tags,
44+
noPadding,
45+
noContentPadding,
46+
children,
47+
className,
48+
contentClassName,
49+
...restProps
50+
} = props;
4051

4152
const renderedTags = useMemo(() => tags?.map(renderTag), [tags]);
4253

@@ -61,7 +72,7 @@ const PageContainer: FunctionComponent<PageContainerProps> = (props) => {
6172
)}
6273
{description && <Paragraph>{description}</Paragraph>}
6374

64-
<div className={styles.contentContainer}>{children}</div>
75+
<div className={classNames(styles.contentContainer, contentClassName)}>{children}</div>
6576
</div>
6677
);
6778
};

src/pages/rootPage/RootPage.module.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,21 @@
99
opacity: 1;
1010
}
1111
}
12+
13+
.container {
14+
display: flex;
15+
flex-direction: column;
16+
height: 100%;
17+
}
18+
19+
.contentContainer {
20+
flex: 1;
21+
display: flex;
22+
flex-direction: column;
23+
}
24+
25+
.footer {
26+
margin-left: -15px;
27+
margin-right: -15px;
28+
margin-bottom: -8px;
29+
}

src/pages/rootPage/RootPage.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@ import PageContainer, { PageTag } from '../../layouts/pages/pageContainer/PageCo
44
import { ReactComponent as ForkMeOnGitHub } from './assets/forkMeOnGitHub.svg';
55
import styles from './RootPage.module.scss';
66
import ExternalLink from '../../components/ExternalLink';
7+
import { Col } from 'antd';
78

89
const RootPage: FunctionComponent = () => {
10+
// const {isFooterHidden} = useAppSettings();
11+
912
return (
1013
<>
1114
<ExternalLink className={styles.forkMeOnGitHub} href="https://github.com/MRGRD56/mrgrd56.github.io">
1215
<ForkMeOnGitHub />
1316
</ExternalLink>
1417

15-
<PageContainer tags={[PageTag.WIP]}>
16-
<Paragraph>
17-
Hello! Maybe one day I will write something here 🙂 <br />
18-
But you can check out other sections, look at the menu on the{' '}
19-
<span className="d-none d-lg-inline">left</span>
20-
<span className="d-lg-none">right</span>!
21-
</Paragraph>
18+
<PageContainer tags={[PageTag.WIP]} contentClassName={styles.container}>
19+
<Col className={styles.contentContainer}>
20+
<Paragraph>
21+
Hello! Maybe one day I will write something here 🙂 <br />
22+
But you can check out other sections, look at the menu on the{' '}
23+
<span className="d-none d-lg-inline">left</span>
24+
<span className="d-lg-none">right</span>!
25+
</Paragraph>
26+
</Col>
27+
28+
{/*{isFooterHidden && (*/}
29+
{/* <AppFooter className={styles.footer}/>*/}
30+
{/*)}*/}
2231
</PageContainer>
2332
</>
2433
);

src/pages/settingsPage/SettingsPage.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const SettingsPage: FunctionComponent = () => {
5353
/>
5454
<span className="ms-3">Show hidden menu items</span>
5555
</label>
56+
<label>
57+
<Switch checked={appSettings.isFooterHidden} onChange={handleAppSettingChange('isFooterHidden')} />
58+
<span className="ms-3">Hide the footer</span>
59+
</label>
5660
</Col>
5761
</PageContainer>
5862
);

src/types/AppSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface AppSettings {
44
theme: SelectableAppTheme;
55
isErudaEnabled: boolean;
66
doShowHiddenMenuItems: boolean;
7+
isFooterHidden: boolean;
78
}
89

910
export default AppSettings;

0 commit comments

Comments
 (0)