diff --git a/src/components/Container.js b/src/components/Container.js index cac8d96a2..5d53d4519 100644 --- a/src/components/Container.js +++ b/src/components/Container.js @@ -1,14 +1,16 @@ import React from 'react'; import PropTypes from 'prop-types'; +import cx from 'classnames'; import './Container.scss'; -const Container = ({ children }) => ( -
{children}
+const Container = ({ children, className }) => ( +
{children}
); Container.propTypes = { children: PropTypes.node.isRequired, + className: PropTypes.string, }; export default Container; diff --git a/src/components/HamburgerMenu.js b/src/components/HamburgerMenu.js index ed278f7f1..1a1ac73f0 100644 --- a/src/components/HamburgerMenu.js +++ b/src/components/HamburgerMenu.js @@ -4,12 +4,12 @@ import cx from 'classnames'; import './HamburgerMenu.scss'; -const HamburgerMenu = ({ toggle, open }) => ( +const HamburgerMenu = ({ toggle, isOpen }) => ( + + + +); + +Sidebar.propTypes = { + toggle: PropTypes.func.isRequired, + pages: PropTypes.arrayOf(link).isRequired, + isOpen: PropTypes.bool, +}; + +Sidebar.defaultProps = { + isOpen: false, +}; + +export default Sidebar; diff --git a/src/components/Sidebar.scss b/src/components/Sidebar.scss new file mode 100644 index 000000000..52e398ce7 --- /dev/null +++ b/src/components/Sidebar.scss @@ -0,0 +1,61 @@ +.Sidebar { + padding: 1rem; + + ul { + margin: 0; + padding-left: 1rem; + list-style: none; + } + + a { + text-decoration: none; + color: var(--color-black); + display: inline-block; + padding: 0.2rem 0; + + &:hover { + text-decoration: underline; + } + + &.is-active { + font-weight: bold; + } + } + + h3 { + margin: 0; + } + + button { + background: none; + border: 0; + cursor: pointer; + width: 3rem; + display: none; + + @media (max-width: 760px) { + display: block; + } + } + + .Sidebar-top { + display: flex; + justify-content: space-between; + } + + nav { + margin-top: 1rem; + + @media (max-width: 760px) { + display: none; + } + } + + &.is-open { + nav { + @media (max-width: 760px) { + display: block; + } + } + } +} diff --git a/src/pages/reference.js b/src/pages/reference.js new file mode 100644 index 000000000..a4bcc4bd9 --- /dev/null +++ b/src/pages/reference.js @@ -0,0 +1,78 @@ +import React, { useState } from 'react'; + +import Container from '../components/Container'; +import Layout from '../components/Layout'; +import Sidebar from '../components/Sidebar'; + +// TODO: move this js file to same directory and update import +import '../templates/Reference.scss'; + +// TODO: pull this in from Gatsby +const pages = [ + { displayName: 'Overview', url: '' }, + { + displayName: 'CLI', + url: '', + children: [ + { displayName: 'newrelic', url: '' }, + { displayName: 'nr1', url: '' }, + ], + }, + { displayName: 'GraphQL', url: '' }, + { + displayName: 'Applications', + url: '', + children: [ + { displayName: 'Component Library', url: '', active: true }, + { displayName: 'File structure', url: '' }, + ], + }, + { + displayName: 'Data Collectors', + url: '', + children: [ + { displayName: 'Custom Attributes', url: '' }, + { displayName: 'Custom Events', url: '' }, + { displayName: 'Open Telemetry', url: '' }, + { displayName: 'Telemetry SDK', url: '' }, + ], + }, + { + displayName: 'Automation', + url: '', + children: [ + { displayName: 'Cloud Formation Provider', url: '' }, + { displayName: 'Terraform Provider', url: '' }, + { + displayName: 'Agent Deploy', + url: '', + children: [ + { displayName: 'Ansible', url: '' }, + { displayName: 'Chef', url: '' }, + { displayName: 'Puppet', url: '' }, + ], + }, + ], + }, +]; + +const Reference = () => { + const [isOpen, setIsOpen] = useState(false); + + return ( + + + setIsOpen(!isOpen)} + /> +
+ The main page content goes here +
+
+
+ ); +}; + +export default Reference; diff --git a/src/templates/Reference.scss b/src/templates/Reference.scss new file mode 100644 index 000000000..6814d6750 --- /dev/null +++ b/src/templates/Reference.scss @@ -0,0 +1,18 @@ +.ReferenceTemplate { + display: grid; + grid-template-columns: 1fr 3fr; + grid-template-areas: 'sidebar main'; + + @media (max-width: 760px) { + grid-template-columns: none; + grid-template-areas: 'sidebar' 'main'; + } + + .Sidebar { + grid-area: sidebar; + } + + .ReferenceTemplate-content { + grid-area: main; + } +} diff --git a/src/types.js b/src/types.js new file mode 100644 index 000000000..602eea517 --- /dev/null +++ b/src/types.js @@ -0,0 +1,10 @@ +import PropTypes from 'prop-types'; + +// NOTE: while creating a recursive data structure is feasible, +// it is not very performant. +export const link = PropTypes.shape({ + displayName: PropTypes.string.isRequired, + url: PropTypes.string.isRequired, + active: PropTypes.bool, + children: PropTypes.array, +});