Skip to content

Commit

Permalink
Re-implements documentation
Browse files Browse the repository at this point in the history
- Adds upgraded Storybook and some initial ported documentation
  • Loading branch information
chrissrogers committed Jun 28, 2023
1 parent f3a406f commit f97ed01
Show file tree
Hide file tree
Showing 19 changed files with 8,246 additions and 833 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ test-types: $(pkg)
@npx dtslint types --expectOnly

docs: $(pkg)
@npx start-storybook -p 6006 -c docs/.storybook/
@npx storybook dev -p 6006 -c docs/.storybook/
docs-build: $(pkg)
@npx build-storybook -c docs/.storybook/ -o build/docs
@npx storybook build -c docs/.storybook/ -o build/docs
docs-publish-remote:
@curl \
--header "Authorization: token $(GITHUB_TOKEN)" \
Expand All @@ -33,5 +33,8 @@ endif

clean:
@rm -rf build lib-dist node_modules
@rm README.md

.PHONY: clean publish test test-ci test-debug docs docs-build docs-deploy test-types test-ci test-cov-ci
.PHONY: test test-debug test-watch test-types
.PHONY: docs docs-build docs-publish-remote
.PHONY: publish clean
21 changes: 21 additions & 0 deletions docs/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @type { import('@storybook/react-vite').StorybookConfig } */
const config = {
stories: ['../**/*.mdx', '../**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions'
],
framework: {
name: '@storybook/react-vite',
options: {}
},
docs: {
autodocs: 'tag'
},
core: {
disableTelemetry: true
}
};

export default config;
11 changes: 11 additions & 0 deletions docs/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script src="https://js.recurly.com/v4/recurly.js"></script>
<link rel="stylesheet" href="https://js.recurly.com/v4/recurly.css">
<style>
.recurly-element {
height: 2.5em;
}

.sbdocs-title, .sbdocs-h1 {
font-weight: 700 !important;
}
</style>
16 changes: 16 additions & 0 deletions docs/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
actions: {
argTypesRegex: '^on[A-Z].*'
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
}
}
};

export default preview;
6 changes: 6 additions & 0 deletions docs/0-introduction/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Meta } from '@storybook/blocks';
import Readme from '../../README.mdx';

<Meta title="Introduction/Getting Started" parameters={{ sortOrder: 0 }} />

<Readme />
19 changes: 19 additions & 0 deletions docs/0-introduction/interactive-demo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Meta } from '@storybook/blocks';

<Meta title="Introduction/Interactive Demo" parameters={{ sortOrder: 1 }} />

<iframe
src="https://codesandbox.io/embed/github/recurly/react-recurly/tree/main/demo?autoresize=1&fontsize=12&hidenavigation=1&theme=light"
style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', border: '0', overflow: 'hidden' }}
title="@recurly/react-recurly-demo"
allow="payment;"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
></iframe>

<div style={{ postion: 'absolute', width: '100%', height: '100%', textAlign: 'center' }}>
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" height="75px" width="75px" style={{ margin: '48% auto' }}>
<circle cx="50%" cy="50%" r="24" strokeWidth="9" stroke="#5191b7" strokeDasharray="37.69911184307752 37.69911184307752" fill="none" strokeLinecap="round" transform="rotate(131.575 50 50)">
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1.1904761904761905s" keyTimes="0;1" values="0 50 50;360 50 50"></animateTransform>
</circle>
</svg>
</div>
16 changes: 16 additions & 0 deletions docs/components/CardElement.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CardElement } from '../../lib';

export default {
component: CardElement,
tags: ['autodocs']
};

export const Primary = {
// render: () => <CardElement />,
args: {
// publicKey: 'MY_PUBLIC_KEY'
},
parameters: {
componentSubtitle: 'Accept all card parameters in one place'
}
};
29 changes: 29 additions & 0 deletions docs/components/Elements.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Meta } from '@storybook/blocks';
import { Elements, CardElement } from '../../lib';

<Meta title="Components/Elements" />

# Elements

`import { Elements } from '@recurly/react-recurly';`

This component groups `*Element` components together. When generating tokens, it is used to determine which values will be tokenized. This should wrap your checkout form.

The functionality of `<Elements />` is largely behind the scenes. It takes one `onSubmit` prop, and is used solely to designate which `*Element` components belong together in your component heirarchy.

```js
import {
RecurlyProvider,
Elements
} from '@recurly/react-recurly';

() => {
return (
<RecurlyProvider publicKey="MY_PUBLIC_KEY">
<Elements>
{/* Any *Element component from react-recurly */}
</Elements>
</RecurlyProvider>
);
};
```
27 changes: 27 additions & 0 deletions docs/components/RecurlyProvider.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Meta, Controls } from '@storybook/blocks';
import RecurlyProvider from './RecurlyProvider.stories';

<Meta of={RecurlyProvider} />

# RecurlyProvider

`import { RecurlyProvider } from '@recurly/react-recurly';`

This component accepts your `publicKey` and other configuration options for Recurly.js as props. It is responsible for creating a `recurly` instance on which we will generate tokens. This should wrap any other `react-recurly` component you will use.

```js
import { RecurlyProvider } from '@recurly/react-recurly';

() => {
return (
<RecurlyProvider publicKey="MY_PUBLIC_KEY">
{/* Any other react-recurly component */}
</RecurlyProvider>
);
};
```
**Note:** Replace `MY_PUBLIC_KEY` with yours, found [here][app-api-access].

<Controls />

[app-api-access]: https://app.recurly.com/go/developer/api_access
18 changes: 18 additions & 0 deletions docs/components/RecurlyProvider.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RecurlyProvider } from '../../lib';

export default {
component: RecurlyProvider,
includeStories: ['Primary']
};

export const Empty = null;

export const Primary = {
render: () => <RecurlyProvider />,
// args: {
// publicKey: 'MY_PUBLIC_KEY'
// },
parameters: {
componentSubtitle: 'Top-level component'
}
};
Loading

0 comments on commit f97ed01

Please sign in to comment.