Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'layouts-main' into layout-batfish-helpers
Browse files Browse the repository at this point in the history
* layouts-main:
  Add Changelog to catalog site
  0.29.2
  Prepare 0.29.2
  Update devDependencies, create jest-setup.js (#311)
  Set peerDependencies to keep frontend libraries in sync (#292)
  Remove unused highlight.js and util function (#305)
  Add aria-label to BackToTopButton (#290)
  • Loading branch information
Katy DeCorah committed Jul 10, 2020
2 parents a484224 + 71ed2d4 commit b163afa
Show file tree
Hide file tree
Showing 19 changed files with 7,058 additions and 7,679 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
pkg
src/test-cases-app/component-index.js
docs/src/pages/files/
docs/src/pages/changelog.md
docs/src/data/components.js
docs/src/prism.css
_site*
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Layouts

## 0.29.2

- Add aria-label to `BackToTopButton`. [#290](https://github.com/mapbox/dr-ui/pull/290)
- Update `@sentry/browser` and add it as a peer dependency along with `react`, `react-dom`, `@mapbox/mr-ui`, and `@mapbox/mbx-assembly`. [#292](https://github.com/mapbox/dr-ui/pull/292)

## 0.29.1

- Remove `limiter` from `Topbar`. [#282](https://github.com/mapbox/dr-ui/pull/282)
Expand Down
10 changes: 10 additions & 0 deletions docs/batfish.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ module.exports = () => {
require.resolve('../src/css/prism.css'),
require.resolve('./src/css/site.css')
],
applicationWrapperPath: path.join(__dirname, 'src/components/wrapper.js'),
jsxtremeMarkdownOptions: {
wrapper: path.join(__dirname, 'src/components/page-shell.js'),
rehypePlugins: [
require('rehype-slug'),
require('../src/plugins/add-links-to-headings'),
require('../src/plugins/create-sections'),
require('../src/plugins/make-table-scroll')
]
},
dataSelectors: {
navigation: (data) => buildNavigation(siteBasePath, data),
topics: (data) => buildTopics(data)
Expand Down
66 changes: 2 additions & 64 deletions docs/src/app.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import React from 'react';
import components from './data/components'; // eslint-disable-line
import ComponentSection from './components/component-section';
import Sidebar from './components/sidebar';
import Topbar from '../../src/components/topbar';
import ProductMenu from '../../src/components/product-menu';
import OverviewHeader from '../../src/components/overview-header';
import Note from '../../src/components/note';
import PageLayout from '../../src/components/page-layout';
import categories from './categories.json';

const version = require('../../package.json').version;

export default class App extends React.Component {
componentDidMount() {
// override SectionedNavigation scroll
const sideBar = document.getElementById('dr-ui--page-layout-sidebar');
if (!sideBar) return;
sideBar.scrollTop = 0;
}

render() {
const componentEls = Object.keys(categories).map((category) => {
return (
Expand All @@ -39,61 +32,6 @@ export default class App extends React.Component {
</div>
);
});
return (
<div>
<Topbar>
<div className="limiter">
<div className="grid">
<div className="col col--4-mm col--12">
<div className="ml18-mm pt12" style={{ height: 52 }}>
<ProductMenu productName="Dr. UI" homePage="/dr-ui/" />
</div>
</div>
</div>
</div>
</Topbar>
<div className="limiter">
<PageLayout
sideBarColSize={3}
sidebarContentStickyTop={0}
sidebarContentStickyTopNarrow={0}
sidebarContent={<Sidebar />}
>
<div className="prose">
<OverviewHeader
features={[
'React components',
'Support for IE11 and all modern browsers'
]}
image={<div />}
title="Dr. UI"
version={version}
changelogLink="https://github.com/mapbox/dr-ui/blob/master/CHANGELOG.md"
installLink="https://github.com/mapbox/dr-ui/blob/master/README.md"
ghLink="https://github.com/mapbox/dr-ui"
/>

<p>
Pronounced "Doctor UI". <strong>D</strong>ocumentation{' '}
<strong>R</strong>eact <strong>UI</strong> components.{' '}
<a href="https://mapbox.github.io/mr-ui/">See @mapbox/mr-ui</a>.
</p>

<p>UI components for Mapbox documentation projects.</p>

<Note>
<p>
This project is for internal Mapbox usage. The code is open
source and we appreciate bug reports; but we will only
consider feature requests and pull requests from Mapbox
developers.
</p>
</Note>
</div>
{componentEls}
</PageLayout>
</div>
</div>
);
return componentEls;
}
}
79 changes: 79 additions & 0 deletions docs/src/components/page-shell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import PropTypes from 'prop-types';
import Topbar from '../../../src/components/topbar';
import ProductMenu from '../../../src/components/product-menu';
import PageLayout from '../../../src/components/page-layout';
import Sidebar from '../components/sidebar';
import Toc from '../components/toc';
import TabList from '@mapbox/mr-ui/tab-list';

class PageShell extends React.Component {
sidebarContent = () => {
const { title, headings } = this.props.frontMatter;

switch (title) {
case 'Overview':
return <Sidebar />;
default:
return <Toc headings={headings} />;
}
};
render() {
const { children, location } = this.props;
const { pathname } = location;

return (
<div>
<Topbar>
<div className="limiter">
<div className="grid">
<div className="col col--3-mm col--12">
<div className="ml18-mm pt12">
<ProductMenu productName="Dr. UI" homePage="/dr-ui/" />
</div>
</div>
<div className="col col--5-mm col--12">
<TabList
items={[
{ label: 'Components', id: '/dr-ui/', href: '/dr-ui/' },
{
label: 'Changelog',
id: '/dr-ui/changelog/',
href: '/dr-ui/changelog/'
}
]}
activeItem={pathname}
truncateBy={1}
/>
</div>
</div>
</div>
</Topbar>
<div className="limiter">
<PageLayout
sideBarColSize={3}
sidebarContentStickyTop={0}
sidebarContentStickyTopNarrow={0}
sidebarContent={this.sidebarContent()}
>
<div className="prose">{children}</div>
</PageLayout>
</div>
</div>
);
}
}

PageShell.propTypes = {
frontMatter: PropTypes.shape({
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
contentType: PropTypes.string,
language: PropTypes.array,
level: PropTypes.number,
headings: PropTypes.array
}).isRequired,
children: PropTypes.node.isRequired
};

export default PageShell;
51 changes: 51 additions & 0 deletions docs/src/components/toc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import classnames from 'classnames';
import Scrollspy from 'react-scrollspy';
import PropTypes from 'prop-types';

class LayoutToc extends React.PureComponent {
render() {
const sections = this.props.headings
.filter((heading) => {
return heading.level === 2 || heading.level === 3;
})
.map((heading) => {
return {
title: heading.text,
url: `#${heading.slug}`,
level: heading.level
};
});

const items = sections.map((heading) => heading.url.replace('#', ''));
const tocContent = sections.map((heading, index) => {
const nextHeading = sections[index + 1] || null;
const headingClasses = classnames('', {
pb6: heading.level === 2,
'mb6 color-gray': heading.level === 3,
mb24: nextHeading && nextHeading.level === 2 && heading.level === 3,
mb6: nextHeading && nextHeading.level === 2 && heading.level === 2
});
return (
<li key={index} className={headingClasses}>
<a href={heading.url} className="color-blue-on-hover">
{heading.title}
</a>
</li>
);
});
return (
<div className="mx24">
<Scrollspy items={items} currentClassName="txt-bold">
{tocContent}
</Scrollspy>
</div>
);
}
}

LayoutToc.propTypes = {
headings: PropTypes.array.isRequired
};

export default LayoutToc;
44 changes: 44 additions & 0 deletions docs/src/components/wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { Helmet } from 'react-helmet';

import PropTypes from 'prop-types';
import pageLoadingIndicator from '@mapbox/mr-ui/page-loading-indicator';
import {
addRouteChangeStartListener,
addRouteChangeEndListener
} from '@mapbox/batfish/modules/route-change-listeners';

if (typeof window !== 'undefined') {
import(
/* webpackChunkName: "assembly-js" */ '@mapbox/mbx-assembly/dist/assembly.js'
);
}

addRouteChangeStartListener(() => {
pageLoadingIndicator.start();
});
addRouteChangeEndListener(() => {
pageLoadingIndicator.end();
});

class ApplicationWrapper extends React.Component {
render() {
return (
<div>
<Helmet>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="robots" content="noindex" />
<title>Dr. UI</title>
</Helmet>
{this.props.children}
</div>
);
}
}

ApplicationWrapper.propTypes = {
children: PropTypes.node
};

export default ApplicationWrapper;
25 changes: 0 additions & 25 deletions docs/src/pages/index.js

This file was deleted.

32 changes: 32 additions & 0 deletions docs/src/pages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Overview
description: UI components for Mapbox documentation projects.
prependJs:
- "import Note from '../../../src/components/note'"
- "import OverviewHeader from '../../../src/components/overview-header'"
- "import App from '../app.js'"
- "const version = require('../../../package.json').version;"
---

{{<OverviewHeader
features={[
'React components',
'Support for IE11 and all modern browsers'
]}
image={<div />}
title="Dr. UI"
version={version}
changelogLink="/dr-ui/changelog/"
installLink="https://github.com/mapbox/dr-ui/blob/master/README.md"
ghLink="https://github.com/mapbox/dr-ui"
/>}}

Pronounced "Doctor UI". **D**ocumentation **R**eact **UI** components. [See @mapbox/mr-ui](https://mapbox.github.io/mr-ui/).

UI components for Mapbox documentation projects.

{{<Note>}}
This project is for internal Mapbox usage. The code is open source and we appreciate bug reports; but we will only consider feature requests and pull requests from Mapbox developers.
{{</Note>}}

{{<App />}}
Loading

0 comments on commit b163afa

Please sign in to comment.