A short time ago, in a galaxy very,
very near....
It is a period of designer unrest. Our patternfly.org designers demand more features with less bugs. Little do they know, patternfly.org is currently three sites merged into one behemoth.
With technical debt mounting, Rebel spies managed to steal secret plans to Gatsby's ultimate weapon, the GATSBY THEME, a modular system with enough power to refactor all three sites at once.
Pursued by the looming deadlines, PatternFly.org contributors race to finish implementing the GATSBY THEME that can save the designers and restore freedom to the galaxy . . . .
Currently, we have three documentation sites:
export default (props) => {
const alertTypes = AlertTypes();
const alertVariations = AlertVariations();
const headingText = 'Alert';
const variablesRoot = 'pf-c-alert';
return <Documentation
data={props}
docs={Docs}
heading={headingText}
variablesRoot={variablesRoot}>
<Example heading="Alert types"
handlebars={AlertTypesRaw}>
{alertTypes}
</Example>
<Example heading="Alert Variations"
handlebars={AlertVariationsRaw}>
<Example heading="Alert variations"
handlebars={AlertVariationsRaw}>
{alertVariations}
</Example>
</Documentation>
Upstream prop injection for patternfly.org in patternfly-next's repo. PR here.
New docs without the injected prop won't be able to show snippets. We have to go back upstream, which costs a lot of time...
Patternfly.org adds many custom styles to markdown, even sometimes changing the DOM
const changeHeadingLevel = (html, level) => {
const modifiedHtml = html
.replace(/<h2/g, `<${level} class="pf-u-mt-xl pf-u-mb-sm"`)
.replace(/h2>/g, `${level}>`);
return modifiedHtml;
};
const changeTableResponsiveness = html =>
html.replace(/<table>/g, '<table class="pf-m-grid">')
const HTML_DOCS = { __html:
changeTableResponsiveness(changeHeadingLevel(docs, 'h3')) };
Custom rendering markdown for Core examples
Unify the configuration using a Gatsby theme. Luckily, all our sites use Gatsby.
Start with patternfly-next (pf4.patternfly.org) and patternfly-react (patternfly-react.surge.sh).
Work up to making a new patternfly-org (https://patternfly.org).
index.js
barrel files with custom Gatsby config
import React from 'react';
import Documentation from '@siteComponents/Documentation';
import Example from '@siteComponents/Example';
import brandSimpleExampleRaw from '!raw!./brand-simple-example.hbs';
import BrandSimpleExample from './brand-simple-example.hbs';
import docs from '../docs/code.md';
export const Docs = docs;
export default props => {
const brandSimpleExample = BrandSimpleExample();
const headingText = 'Brand';
const variablesRoot = 'pf-c-brand';
return <Documentation data={props} docs={Docs} heading={headingText} variablesRoot={variablesRoot}>
<Example heading="Brand simple" handlebars={brandSimpleExampleRaw}>
{brandSimpleExample}
</Example>
</Documentation>;
};
Old Core docs code
index.js
files -- why should HTML devs know React?mdx.js
templateExample.js
component using react-live
---
title: Brand
section: components
---
## Examples
```hbs title=Basic
{{#> brand brand--attribute='src="/assets/images/pf_logo.svg" alt="PatternFly logo"'}}
{{/brand}}
```
## Documentation
### Overiew
Simple brand component.
### Accessibility
| Attribute | Applied to | Outcome |
| -- | -- | -- |
| `alt` | `.pf-c-brand` | The alt attribute specifies an alternate text for an image,
if the image cannot be displayed. **Required** |
### Usage
| Class | Applied to | Outcome |
| -- | -- | -- |
| `.pf-c-brand` | `<img>` | Initiates a brand image. **Required** |
New docs code
Here's the PR (+19,108/-22,516)
## Simple area chart with right aligned legend
```js
(jsx)
```
to
```js title=Basic-with-right-aligned-legend
ExampleName = (jsx) OR
class ExampleName extends React.Component {
```
Here's the PR (+5,402/-6,381)
I didn't realize Gatsby was also building all the project SASS. I stopped Core development for 2 days.