Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feature: fix header (in progress) #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/components/PageLayout/Header/header.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
margin: 0;
display: flex;
}
//height: 70px;
}
.nav{
.flex-center();
Expand Down Expand Up @@ -112,7 +113,7 @@
color: #fff;
}
}

}
/** mobile header code */
.openMenu{
Expand Down Expand Up @@ -160,4 +161,20 @@
@media screen and ( max-width:768px ) {
display: none;
}
}
}

.topPadding {
height: 1.87rem;
@media screen and (max-width: 768px){
height: 0;
}
background: @site-background-color;
}

.bottomPadding {
height: 2.5rem;
@media screen and (max-width: 768px){
height: 0;
}
background: white;
}
17 changes: 14 additions & 3 deletions src/components/PageLayout/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useRef, useState } from 'react';
import { Link } from 'gatsby';
import { Layout } from 'antd';
import {
Layout, Affix, Col, Row,
} from 'antd';
import { library } from '@fortawesome/fontawesome-svg-core';
import { fas } from '@fortawesome/free-solid-svg-icons';
import { fab } from '@fortawesome/free-brands-svg-icons';
Expand Down Expand Up @@ -43,14 +45,15 @@ export default () => {
};

return (
<>
<Affix offsetTop={0}>
<div className={style.circleMenu} role="button" tabIndex="0" onKeyDown={toggleMenu} onClick={toggleMenu}>
<div className={`${style.hamburger} ${menu ? style.menuIcon : null}`}>
<div className={style.line} />
<div className={style.line} />
<div className={style.hamburgerText}>MENU</div>
</div>
</div>
<div className={style.topPadding} />
<Layout className={`${style.navWrap} ${menu ? null : style.hidden} ${menu ? style.openMenu : null}`}>
<div className={style.backgroundDiv}>
<ul className={style.nav}>
Expand Down Expand Up @@ -102,6 +105,14 @@ export default () => {
</ul>
</div>
</Layout>
</>
<div className="container" style={{ position: 'fixed' }}>
<Row>
<Col sm={24} md={10} lg={7} />
<Col sm={24} md={14} lg={17}>
<div className={style.bottomPadding} />
</Col>
</Row>
</div>
</Affix>
);
};
2 changes: 1 addition & 1 deletion src/components/PageLayout/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const Sidebar = (props) => {
let domContent = <DomContent />;
if (width > 997) {
domContent = (
<Affix offsetTop={0}>
<Affix offsetTop={120}>
<DomContent />
</Affix>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/PageLayout/Sidebar/sidebar.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.content{
border-radius: @border-radius-content;
margin: 0px;
min-height: 280px
min-height: 280px;
//border-top-left-radius: 0;
}

.sidebarContent{
Expand Down Expand Up @@ -115,6 +116,7 @@
.boxContent{
padding: @padding-margin-val;
padding-left: 0;
padding-top: 0;
@media screen and (max-width: 767px){
padding: @padding-margin-val;
padding-top: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Panel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Panel = (props) => {
}

return (
<>
<div style={{marginTop: "2.5rem"}}>
<section className={style.codeBox}>
<section className={style.codeBoxTitle}>
Filters
Expand Down Expand Up @@ -104,7 +104,7 @@ const Panel = (props) => {
})
}
</Row>
</>
</div>
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/pages/posts/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { graphql } from 'gatsby';
import { Layout } from 'antd';
import { Affix, Layout } from 'antd';

import Header from '../../components/PageLayout/Header';
import SidebarWrapper from '../../components/PageLayout/Sidebar';
Expand All @@ -20,9 +20,9 @@ const Posts = ({ data }) => (
path="posts"
/>
<SidebarWrapper>
<div className="marginTopTitle">
<Affix offsetTop={130} prefixCls="fix-title">
<h1 className="titleSeparate">Posts</h1>
</div>
</Affix>
<Panel type="posts" data={data} />
</SidebarWrapper>
</Layout>
Expand Down
10 changes: 8 additions & 2 deletions src/styles/global.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@import (reference) './mixins.less';
@import (reference) './theme.less';
body{
font-size: 16px;
background: #f0f2f5;
background: @site-background-color;
overflow-y: scroll;
}
h1, h2, h3, h4, h5, h6 {
Expand Down Expand Up @@ -103,6 +104,7 @@ ul{

.outerPadding {
padding: 1.87rem;
padding-top: 0;
@media screen and (max-width: 768px){
padding: 0.6rem;
}
Expand Down Expand Up @@ -146,4 +148,8 @@ ul{
font-size: 12px;
}


.fix-title {
background-color: white;
//padding-top: 2.5em;
//margin-bottom: 2.5rem;
}
1 change: 1 addition & 0 deletions src/styles/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@site-border-color-split: @border-color-split;
@site-header-box-shadow: 0 2px 8px rgba(240, 241, 242, 65);
@site-markdown-code-bg: #f2f4f5;
@site-background-color: #f0f2f5;
6 changes: 4 additions & 2 deletions src/templates/post/post.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import {
Layout, Empty, Row, Col, Input, Alert,
Layout, Empty, Row, Col, Input, Alert, Affix,
} from 'antd';
import { graphql } from 'gatsby';
import Img from 'gatsby-image';
Expand Down Expand Up @@ -87,7 +87,7 @@ const Post = ({ data }) => {
/>
<Header />
<SidebarWrapper>
<div className="marginTopTitle">
<Affix offsetTop={130} prefixCls="fix-title">
<h1 className="titleSeparate">{title}</h1>
<div>
<div style={{ color: 'rgba(0, 0, 0, 0.45)', marginBottom: '1rem' }}>
Expand All @@ -99,6 +99,8 @@ const Post = ({ data }) => {
<Img className={style.bannerImg} fluid={fluid} title={excerpt} alt={title} />
</div>
) : null }
</Affix>
<div>
{ state.locked
? (
<Empty
Expand Down