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

Commit

Permalink
Merge branch 'main' into peer-deps
Browse files Browse the repository at this point in the history
* main:
  Remove unused highlight.js and util function (#305)
  Add aria-label to BackToTopButton (#290)
  Add the catalog site  (#137)
  Delete dependabot.yml
  Only direct dependencies
  Create dependabot.yml (#296)
  Update Travis bad
  • Loading branch information
Katy DeCorah committed Jul 8, 2020
2 parents 322f28a + 6271142 commit 1b8bb1a
Show file tree
Hide file tree
Showing 191 changed files with 4,323 additions and 2,644 deletions.
10 changes: 4 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
node_modules
*.log
dist
coverage
.DS_Store
**/_batfish*
src/docs/data
src/components/*/index.js
packages/**/package-lock.json
_batfish*
pkg
src/test-cases-app/component-index.js
dist
docs/src/data/components.js
_site*
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ node_modules
dist
pkg
src/test-cases-app/component-index.js
src/components/syntax-highlighting/index.js
docs/src/pages/files/
docs/src/data/components.js
docs/src/prism.css
_site*
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ node_js:
sudo: false
notifications:
email: false
cache:
directories:
- node_modules
git:
depth: 3

scripts:
- npm run build-docs
- npm test
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## Master
## Main

- 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
Expand Down
73 changes: 73 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributing

This repo has two sites:

- **The [catalog site](https://mapbox.github.io/dr-ui/) built with Batfish.**
- The catalog contains examples of most common uses for each component and lists all available properties.
- To make sure all our components are production ready with Batfish, CI runs the `npm run build-docs`.
- Every catalog example must have a test case.
- **The test cases app available locally.**
- The test cases app builds a local development site and snapshot tests for each component. The test cases app also includes less common use cases.

## Commands

To run the catalog site at https://mapbox.github.io/dr-ui/:

```
npm run start-docs
```

To build the test cases app:

```bash
npm start
```

To run the tests:

```
npm test
```

## Tests

Every component should have a `__tests__` directory with the following files:

- `/[component-name]-test-cases.js`. The `*test-cases.js` file includes variations of the component to demonstrate different capabilities and properties for the component. Every catalog example must have a test case.
- `/[component-name].test.js`. The `*.test.js` file should create a unit test for each test case found in `*test-cases.js`.

## Add a new component

Run the `new` command to generate all the files and starter code to create a new component. The command accepts an argument with the name of the component:

```
node scripts/new.js Button
node scripts/new.js responsive button
```

The command will create the following folder structure:

```
src/components/[component-name]/
index.js
[component-name].js
examples/
basic.js
__tests__/
[component-name]-test-cases.js
[component-name].test.js
```

## Publish a new dr-ui version

The `build` command creates a `pkg/` directory that contains the code we want to publish, organized the way we want it. So `pkg/` is the directory that we publish. `pkg/package.json` is a clone of `package.json` but with `private: true` removed.

1. Document changes in the CHANGELOG.
1. Increment the version key in package.json and package-lock.json.
1. Make sure all this is committed, typically with a commit message like `Prepare 0.0.11`.
1. Create a tag. No message is necessary, since the changelog includes explanations of changes. For example: `git tag -a 0.0.11 -m ""`.
1. Push the tag: `git push --tags`.
1. Push your commit.
1. Build the `pkg/` directory: `npm run build`.
1. `cd` into the `pkg/` directory and publish the new version on npm.
1. `cd` back to the root directory and run `npm run deploy-docs` to deploy the catalog site.
42 changes: 2 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @mapbox/dr-ui

[![Build Status](https://travis-ci.com/mapbox/dr-ui.svg?branch=master)](https://travis-ci.com/mapbox/dr-ui)
[![Build Status](https://travis-ci.com/mapbox/dr-ui.svg?branch=main)](https://travis-ci.com/mapbox/dr-ui)

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

Expand Down Expand Up @@ -31,42 +31,4 @@ Only the component itself and whatever _it_ depends on will be drawn into your b

## Development

Here are some commands you'll probably want to use:

```bash
# Start the test-cases app.
npm start
```

Docs build process and automated testing coming soon.

When making changes to the build script, test that the module builds correctly by running `npm run build` and then linking the local package with another local repo. Make sure you are able to run the local repo without errors from dr-ui.

## Tests

Each component should have a `__tests__` folder with a `component-name-test-cases.js` and `component-name.test.js`. The `*test-cases.js` file should include variations of the component in use to demonstrate the different capabilities and properites for the component. The `*.test.js` file should create a unit test for each test case found in `*test-cases.js`.

Run the tests:

```
npm test
```

Update snapshots (run when making changes to `*.test.js`):

```
npm test -- -u
```

### Publishing

The `build` command creates a `pkg/` directory that contains the code we want to publish, organized the way we want it. So `pkg/` is the directory that we publish. `pkg/package.json` is a clone of `package.json` but with `private: true` removed.

1. Document changes in the CHANGELOG.
1. Increment the version key in package.json and package-lock.json.
1. Make sure all this is committed, typically with a commit message like `Prepare 0.0.11`.
1. Create a tag. No message is necessary, since the changelog includes explanations of changes. For example: `git tag -a 0.0.11 -m ""`.
1. Push the tag: `git push --tags`.
1. Push your commit.
1. Build the `pkg/` directory: `npm run build`.
1. `cd` into the `pkg/` directory and publish the new version on npm.
See [CONTRIBUTING.md](CONTRIBUTING.md).
7 changes: 7 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["../conf/eslint-config-base.json", "@mapbox/eslint-config-docs"],
"rules": {
"es/no-object-assign": "off",
"react/prop-types": "off"
}
}
15 changes: 15 additions & 0 deletions docs/batfish.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path');

module.exports = () => {
return {
siteBasePath: '/dr-ui',
outputDirectory: path.join(__dirname, '_site/'),
temporaryDirectory: path.join(__dirname, '_site_tmp/'),
stylesheets: [
require.resolve('@mapbox/mbx-assembly/dist/assembly.css'),
require.resolve('../src/css/docs-prose.css'),
require.resolve('../src/css/prism.css'),
require.resolve('./src/css/site.css')
]
};
};
99 changes: 99 additions & 0 deletions docs/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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 (
<div key={category}>
<h2 className="txt-fancy txt-h3" id={category.toLowerCase()}>
{category}
</h2>
{categories[category].sort().map((comp) => {
const component = components.filter((f) => f.name === comp)[0];
return (
<div
key={component.name}
className="pt30 mb30 border-t border--darken10"
>
<ComponentSection data={component} />
</div>
);
})}
</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>
);
}
}
53 changes: 53 additions & 0 deletions docs/src/categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"Features": [
"Feedback",
"LevelIndicator",
"Note",
"RelatedPage",
"Search",
"Tag",
"Browser",
"DemoIframe",
"GLWrapper",
"Phone",
"Video"
],
"Code": [
"AndroidLayoutCodeBlock",
"CodeSnippet",
"CodeSnippetTitle",
"CodeToggle",
"ContextlessAndroidActivityToggle",
"ContextlessIosViewControllerToggle",
"Edit",
"Highlight",
"NumberedCodeSnippet",
"ToggleableCodeBlock"
],
"Layout": [
"BackToTopButton",
"GlossaryCard",
"GlossaryImage",
"GlossaryPage",
"GlossarySection",
"OverviewHeader",
"NavigationAccordion",
"NavigationDropdown",
"PageLayout",
"ProductMenu",
"SectionedNavigation",
"Topbar",
"TopbarSticker",
"Card",
"CardContainer",
"ExamplesPage"
],
"Images": [
"BookImage",
"BookletImage",
"ContactImage",
"ExampleImage",
"PlaygroundImage",
"TroubleshootImage"
]
}
Loading

0 comments on commit 1b8bb1a

Please sign in to comment.