Skip to content

Commit

Permalink
docs(style): make more responsive for mobile (apache#10853)
Browse files Browse the repository at this point in the history
* docs(style): make more responsive for mobile

* Make a responsive navbar

* more fixes and tweaks

* Add README instructions
  • Loading branch information
mistercrunch authored Sep 14, 2020
1 parent d93b2b9 commit 08ec509
Show file tree
Hide file tree
Showing 15 changed files with 676 additions and 523 deletions.
1 change: 1 addition & 0 deletions docs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
'jsx-a11y/iframe-has-title': 'off',
'jsx-a11y/interactive-supports-focus': 'off',
'react-hooks/rules-of-hooks': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
},
extends: ['airbnb', 'airbnb/hooks'],
env: {
Expand Down
33 changes: 33 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,36 @@ npm install
npm run start
# navigate to localhost:8000`
```

## To Publish

To publish, the static site that Gatsby generates needs to be pushed
to the `asf-site` branch on the
[apache/incubator-superset-site](https://github.com/apache/incubator-superset-site/)
repository. No need to PR here, just `git push`!

```bash
# Get in the docs/ folder in the main repo
cd ~/repos/incubator-superset/docs
# have Gatsby build the static website, this puts in under `docs/public`
npm run build

# go to the docs repo
cd ~/repos/incubator-superset-site
# checkout the proper branch
git checkout asf-site

# BE CAREFUL WITH THIS COMMAND
# wipe the content of the repo
rm -rf *

# copy the static site here
cp -r ~/repos/incubator-superset/docs/public ./

# git push
git add .
git commit "{{ relevant commit msg }}"
git push origin asf-site

# SUCCESS - it should take minutes to take effect on superset.apache.org
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,44 @@
import React from 'react';
import { Anchor } from 'antd';
import { useMenus } from 'docz';
import { getActiveMenuItem } from '../utils';
import { css } from '@emotion/core';
import { getActiveMenuItem, mq } from '../utils';

const { Link } = Anchor;
const anchorNavStyle = css`
${[mq[3]]} {
display: none;
}
position: fixed;
top: 64px;
right: 0;
width: 250px;
padding: 16px;
height: 605px;
overflow: auto;
ul {
font-size: 12px;
li {
height: 25px;
line-height: 25px;
word-wrap: break-word;
}
}
`;

const HeaderNav = () => {
const menus = useMenus();
const { headings } = getActiveMenuItem(menus);
const headsList = headings.map((e) => (
<Link href={`#${e.slug}`} title={e.value} />
));
return <Anchor>{headsList}</Anchor>;
return (
<div css={anchorNavStyle}>
<Anchor>
{headings.map((e) => (
<Link href={`#${e.slug}`} title={e.value} />
))}
</Anchor>
</div>
);
};

export default HeaderNav;
File renamed without changes.
149 changes: 149 additions & 0 deletions docs/src/components/MainMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { Drawer, Layout, Menu } from 'antd';
import { Link } from 'gatsby';
import { MenuOutlined, GithubOutlined } from '@ant-design/icons';
import { css } from '@emotion/core';
import { getCurrentPath, mq } from '../utils';
import logoSvg from '../images/superset-logo-horiz.svg';

const menuResponsiveIndex = 1;

const headerStyle = css`
background-color: rgb(255,255,255, 0.9);
padding-left: 0px;
padding-right: 0px;
position: fixed;
top: 0;
width: 100%;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.12);
z-index: 1;
.ant-menu {
background: transparent;
}
.menu-icon {
vertical-align: middle;
font-size: 24px;
padding-left: 0px;
padding-right: 0px;
}
.ant-menu-horizontal {
border-bottom: none;
}
.menu-sm {
display: none;
}
${[mq[menuResponsiveIndex]]} {
.menu-sm {
display: block;
}
.menu-lg {
display: none;
}
}
`;
const logoStyle = css`
float: left;
margin-top: 6px;
height: 50px;
`;

interface menuProps {
mode: string;
}

const MenuItems = ({ mode, toggleDrawer }: menuProps) => {
let leftStyle = { float: 'left' };
let rightStyle = { float: 'right' };
if (mode === 'vertical') {
leftStyle = null;
rightStyle = null;
}
return (
<Menu mode={mode} selectedKeys={getCurrentPath()}>
<Menu.Item key="docsintro" style={leftStyle} className="menu-lg">
<Link to="/docs/intro">Documentation</Link>
</Menu.Item>
<Menu.Item key="community" style={leftStyle} className="menu-lg">
<Link to="/community">Community</Link>
</Menu.Item>
<Menu.Item key="resources" style={leftStyle} className="menu-lg">
<Link to="/resources"> Resources</Link>
</Menu.Item>
{toggleDrawer && (
<Menu.Item style={rightStyle} className="menu-sm">
<MenuOutlined onClick={toggleDrawer} className="menu-icon" />
</Menu.Item>
)}
{mode === 'horizontal'
&& (
<Menu.Item key="github" style={rightStyle}>
<a href="https://github.com/apache/incubator-superset" target="_blank" rel="noreferrer">
<GithubOutlined className="menu-icon" />
</a>
</Menu.Item>
)}
</Menu>
);
};

export default class MainMenu extends React.Component {
constructor(props) {
super(props);
this.state = {
visible: false,
};
this.toggleDrawer = this.toggleDrawer.bind(this);
this.onClose = this.onClose.bind(this);
}

onClose() {
this.setState({
visible: false,
});
}

toggleDrawer() {
this.setState((prevState) => ({
visible: !prevState.visible,
}));
}

render() {
const { visible } = this.state;
return (
<Layout.Header css={headerStyle}>
<Link to="/">
<img height="50" css={logoStyle} src={logoSvg} alt="logo" />
</Link>
<MenuItems toggleDrawer={this.toggleDrawer} mode="horizontal" />
<Drawer
title="Menu"
placement="right"
closable={false}
onClose={this.onClose}
visible={visible}
>
<MenuItems mode="vertical" />
</Drawer>
</Layout.Header>
);
}
}
Loading

0 comments on commit 08ec509

Please sign in to comment.