mirror of
https://github.com/apache/superset.git
synced 2026-04-17 15:15:20 +00:00
docs(style): make more responsive for mobile (#10853)
* docs(style): make more responsive for mobile * Make a responsive navbar * more fixes and tweaks * Add README instructions
This commit is contained in:
committed by
GitHub
parent
d93b2b99b2
commit
08ec509dc9
@@ -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;
|
||||
149
docs/src/components/MainMenu.tsx
Normal file
149
docs/src/components/MainMenu.tsx
Normal file
@@ -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>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,23 +27,23 @@ const footerStyle = css`
|
||||
background-color: #323232;
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
.apacheLinks {
|
||||
a {
|
||||
color: white;
|
||||
margin: 5px;
|
||||
}
|
||||
}
|
||||
padding: 10px;
|
||||
`;
|
||||
|
||||
const copyrightStyle = css`
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
`;
|
||||
const apacheLinksStyle = css`
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
a {
|
||||
color: rgba(255, 255, 255, 0.75);
|
||||
margin: 5px;
|
||||
}
|
||||
`;
|
||||
const iconContainerStyle = css`
|
||||
padding: 30px;
|
||||
padding: 10px;
|
||||
background-color: #323232;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -67,92 +67,89 @@ const iconContainerStyle = css`
|
||||
`;
|
||||
|
||||
const LayoutFooter = () => (
|
||||
<>
|
||||
<Footer css={footerStyle}>
|
||||
<div css={apacheLinksStyle} className="apacheLinks">
|
||||
<Footer css={footerStyle}>
|
||||
<div css={iconContainerStyle}>
|
||||
<div className="icons">
|
||||
<a
|
||||
href="https://www.apache.org/security/"
|
||||
href="https://apache-superset.slack.com/join/shared_invite/zt-g8lpruog-HeqpgYrwdfrD5OYhlU7hPQ#/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Security |
|
||||
<SlackSquareOutlined className="icon" />
|
||||
</a>
|
||||
<a
|
||||
href="https://www.apache.org/foundation/sponsorship.html"
|
||||
href="https://github.com/apache/incubator-superset"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Donate |
|
||||
<GithubOutlined className="icon" />
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://www.apache.org/foundation/thanks.html"
|
||||
href="https://stackoverflow.com/questions/tagged/apache-superset+superset"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Thanks
|
||||
<img
|
||||
alt="StackOverflow"
|
||||
src="/images/so-icon.svg"
|
||||
className="icon svg"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div css={iconContainerStyle}>
|
||||
<div className="icons">
|
||||
<a
|
||||
href="https://apache-superset.slack.com/join/shared_invite/zt-g8lpruog-HeqpgYrwdfrD5OYhlU7hPQ#/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<SlackSquareOutlined className="icon" />
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/apache/incubator-superset"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<GithubOutlined className="icon" />
|
||||
</a>
|
||||
<a
|
||||
href="https://stackoverflow.com/questions/tagged/apache-superset+superset"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<img
|
||||
alt="StackOverflow"
|
||||
src="/images/so-icon.svg"
|
||||
className="icon svg"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div css={copyrightStyle}>
|
||||
© Copyright
|
||||
{' '}
|
||||
{new Date().getFullYear()}
|
||||
,
|
||||
<a href="http://www.apache.org/" target="_blank" rel="noreferrer">
|
||||
</div>
|
||||
<div css={copyrightStyle}>
|
||||
© Copyright
|
||||
{' '}
|
||||
{new Date().getFullYear()}
|
||||
,
|
||||
<a href="http://www.apache.org/" target="_blank" rel="noreferrer">
|
||||
The Apache Software Fountation
|
||||
</a>
|
||||
, Licensed under the Apache
|
||||
<a
|
||||
href="https://www.apache.org/licenses/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
</a>
|
||||
, Licensed under the Apache
|
||||
<a
|
||||
href="https://www.apache.org/licenses/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
License.
|
||||
</a>
|
||||
{' '}
|
||||
<br />
|
||||
<div>
|
||||
Disclaimer: Apache Superset is an effort undergoing incubation at The
|
||||
Apache Software Foundation (ASF), sponsored by the Apache Incubator.
|
||||
Incubation is required of all newly accepted projects until a further
|
||||
review indicates that the infrastructure, communications, and decision
|
||||
making process have stabilized in a manner consistent with other
|
||||
successful ASF projects. While incubation status is not necessarily a
|
||||
reflection of the completeness or stability of the code, it does
|
||||
indicate that the project has yet to be fully endorsed by the ASF.
|
||||
</div>
|
||||
</a>
|
||||
{' '}
|
||||
<div>
|
||||
Disclaimer: Apache Superset is an effort undergoing incubation at The
|
||||
Apache Software Foundation (ASF), sponsored by the Apache Incubator.
|
||||
Incubation is required of all newly accepted projects until a further
|
||||
review indicates that the infrastructure, communications, and decision
|
||||
making process have stabilized in a manner consistent with other
|
||||
successful ASF projects. While incubation status is not necessarily a
|
||||
reflection of the completeness or stability of the code, it does
|
||||
indicate that the project has yet to be fully endorsed by the ASF.
|
||||
</div>
|
||||
</Footer>
|
||||
</>
|
||||
</div>
|
||||
<div css={apacheLinksStyle} className="apacheLinks">
|
||||
<a
|
||||
href="https://www.apache.org/security/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Security |
|
||||
</a>
|
||||
<a
|
||||
href="https://www.apache.org/foundation/sponsorship.html"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Donate |
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://www.apache.org/foundation/thanks.html"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
Thanks
|
||||
</a>
|
||||
</div>
|
||||
</Footer>
|
||||
);
|
||||
|
||||
export default LayoutFooter;
|
||||
|
||||
@@ -86,7 +86,7 @@ const Image = ({
|
||||
getAllImages: allImageSharp {
|
||||
edges {
|
||||
node {
|
||||
fixed(height: 70) {
|
||||
fixed(height: 50) {
|
||||
...GatsbyImageSharpFixed
|
||||
originalName
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ body {
|
||||
|
||||
.contentPage {
|
||||
padding-bottom: $bigPad;
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
section {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
@@ -51,15 +53,6 @@ body {
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
h1 {
|
||||
font-size: 48px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 32px;
|
||||
}
|
||||
h3 {
|
||||
font-size: 24px;
|
||||
}
|
||||
.title{
|
||||
margin-top: $bigPad;
|
||||
}
|
||||
@@ -88,11 +81,11 @@ th, td {
|
||||
}
|
||||
|
||||
.ant-menu:not(.ant-menu-horizontal) .ant-menu-item-selected {
|
||||
background-color: $brandColor;
|
||||
background-color: lighten($brandColor, 42);
|
||||
}
|
||||
|
||||
.ant-menu-item-selected a {
|
||||
color: white;
|
||||
color: black;
|
||||
}
|
||||
.ant-menu-submenu-selected {
|
||||
color: $brandColor;
|
||||
@@ -121,3 +114,21 @@ tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
button {
|
||||
background: $brandColor;
|
||||
}
|
||||
.ant-drawer-body {
|
||||
padding: 0px !important;
|
||||
}
|
||||
h1, h2, h3, h4 {
|
||||
font-weight: bold;
|
||||
}
|
||||
h1 {
|
||||
font-size: 40px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 32px;
|
||||
}
|
||||
h3 {
|
||||
font-size: 24px;
|
||||
}
|
||||
h4 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
@@ -17,28 +17,24 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React, { useState } from 'react';
|
||||
import { Link } from 'gatsby';
|
||||
import {
|
||||
Layout, Menu, Button, Drawer,
|
||||
Layout, Drawer,
|
||||
} from 'antd';
|
||||
import { css } from '@emotion/core';
|
||||
import { MenuOutlined } from '@ant-design/icons';
|
||||
|
||||
import logoSvg from '../images/superset-logo-horiz.svg';
|
||||
import Footer from './footer';
|
||||
import SEO from './seo';
|
||||
import AppMenu from './menu';
|
||||
import DoczMenu from './DoczMenu';
|
||||
|
||||
import { getCurrentPath } from '../utils';
|
||||
import { getCurrentPath, mq } from '../utils';
|
||||
import MainMenu from './MainMenu';
|
||||
import 'antd/dist/antd.css';
|
||||
import './layout.scss';
|
||||
|
||||
const { Header, Sider } = Layout;
|
||||
const { Sider } = Layout;
|
||||
|
||||
const leftPaneWidth = 350;
|
||||
const breakpoints = [576, 768, 992, 1200];
|
||||
|
||||
const mq = breakpoints.map((bp) => `@media (max-width: ${bp}px)`);
|
||||
|
||||
const layoutStyles = css`
|
||||
font-family: Inter;
|
||||
@@ -52,38 +48,20 @@ const layoutStyles = css`
|
||||
}
|
||||
`;
|
||||
|
||||
const headerStyle = css`
|
||||
background-color: #fff;
|
||||
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;
|
||||
}
|
||||
.ant-menu-horizontal {
|
||||
border-bottom: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const getStartedButtonStyle = css`
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 16px;
|
||||
`;
|
||||
|
||||
const centerLayoutStyle = css`
|
||||
padding: 25px;
|
||||
min-height: 60vw;
|
||||
overflow: auto;
|
||||
padding-right: 250px;
|
||||
.menu {
|
||||
${[mq[3]]} {
|
||||
padding-right: 25px;
|
||||
}
|
||||
.doc-hamburger {
|
||||
display: none;
|
||||
${[mq[2]]} {
|
||||
display: block;
|
||||
}
|
||||
padding: 25px;
|
||||
text-align: left;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -99,14 +77,6 @@ const sidebarStyle = css`
|
||||
const contentStyle = css`
|
||||
margin-top: 3px;
|
||||
background-color: white;
|
||||
h2 {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
h3 {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
img {
|
||||
max-width: 800px;
|
||||
margin-bottom: 15px;
|
||||
@@ -121,10 +91,13 @@ const contentStyle = css`
|
||||
}
|
||||
pre {
|
||||
border: solid #00000033 1px;
|
||||
padding: 5px;
|
||||
padding: 5px 10px;
|
||||
background-color: #82ef8217;
|
||||
border-radius: 3px;
|
||||
max-width: 1000px;
|
||||
max-width: 800px;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow: auto;
|
||||
}
|
||||
p {
|
||||
font-size: 16px;
|
||||
@@ -153,12 +126,6 @@ const contentLayoutDocsStyle = css`
|
||||
}
|
||||
`;
|
||||
|
||||
const logoStyle = css`
|
||||
float: left;
|
||||
margin-left: -50px;
|
||||
margin-top: 5px;
|
||||
heigh: 30px;
|
||||
`;
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
@@ -169,32 +136,11 @@ const AppLayout = ({ children }: Props) => {
|
||||
return (
|
||||
<Layout css={layoutStyles}>
|
||||
<SEO title="Welcome" />
|
||||
<Header css={headerStyle}>
|
||||
<Link to="/">
|
||||
<img height="50" css={logoStyle} src={logoSvg} alt="logo" />
|
||||
</Link>
|
||||
<Menu mode="horizontal" selectedKeys={getCurrentPath()}>
|
||||
<Menu.Item key="docsintro">
|
||||
<Link to="/docs/intro">Documentation</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="community">
|
||||
<Link to="/community">Community</Link>
|
||||
</Menu.Item>
|
||||
<Menu.Item key="resources">
|
||||
<Link to="/resources"> Resources</Link>
|
||||
</Menu.Item>
|
||||
</Menu>
|
||||
<div css={getStartedButtonStyle}>
|
||||
<Link to="/docs/intro">
|
||||
<Button type="primary" size="medium">
|
||||
Get Started
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</Header>
|
||||
<MainMenu />
|
||||
{isOnDocsPage ? (
|
||||
<>
|
||||
<Drawer
|
||||
title="Documentation"
|
||||
placement="left"
|
||||
closable={false}
|
||||
onClose={() => setDrawer(false)}
|
||||
@@ -202,23 +148,23 @@ const AppLayout = ({ children }: Props) => {
|
||||
getContainer={false}
|
||||
style={{ position: 'absolute' }}
|
||||
>
|
||||
<AppMenu />
|
||||
<DoczMenu />
|
||||
</Drawer>
|
||||
<Layout css={contentLayoutDocsStyle}>
|
||||
{isOnDocsPage && (
|
||||
<Sider width={leftPaneWidth} css={sidebarStyle}>
|
||||
<AppMenu />
|
||||
</Sider>
|
||||
)}
|
||||
<Sider width={leftPaneWidth} css={sidebarStyle}>
|
||||
<DoczMenu />
|
||||
</Sider>
|
||||
<Layout css={contentStyle}>
|
||||
<div css={centerLayoutStyle}>
|
||||
<MenuOutlined
|
||||
onClick={() => setDrawer(true)}
|
||||
className="menu"
|
||||
/>
|
||||
<h1 className="doc-hamburger" onClick={() => setDrawer(true)}>
|
||||
<MenuOutlined
|
||||
className="menu"
|
||||
/>
|
||||
{' '}
|
||||
Documentation
|
||||
</h1>
|
||||
{children}
|
||||
</div>
|
||||
<Footer />
|
||||
</Layout>
|
||||
</Layout>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user