Skip to content

Commit

Permalink
docs: update starter example with api
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 20, 2021
1 parent 05348ee commit e6e9df2
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 55 deletions.
231 changes: 194 additions & 37 deletions core/webpack-compile/tests/draft.test.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/starter/.config/buildtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')

module.exports = {
siteRoot: '/root/',
stories: ['../src/docs/*.@(mdx|tsx)'],
stories: ['../src/docs/*.mdx', '../src/**/*.docs.@(tsx|jsx|ts|js)'],

webpack: (config = {}, options = {}) => {
return {
...config,
Expand Down
1 change: 1 addition & 0 deletions examples/starter/src/api/sum/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sum';
17 changes: 17 additions & 0 deletions examples/starter/src/api/sum/sum.docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { sum } from './sum';

const doc = {
title: 'Library/api/sum',
order: 1,
component: sum,
};

export const overview = ({ a, b }: { a: number; b: number }) => {
return sum(a, b);
};
overview.controls = {
a: 1,
b: 2,
};

export default doc;
7 changes: 7 additions & 0 deletions examples/starter/src/api/sum/sum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* sum api function
* @param a first parameter to add
* @param b second parameter to add
* @returns the sum of the two parameters
*/
export const sum = (a: number, b: number): number => a + b;
17 changes: 17 additions & 0 deletions examples/starter/src/components/Button/Button.docs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Document, Example } from '@component-controls/core';
import { useStore } from '@component-controls/store';
import { Button, ButtonProps } from './Button';

const doc: Document = {
title: 'Library/Components/Button',
order: 1,
component: Button
};

export const overview: Example<ButtonProps> = (props) => {
const store = useStore();
return <Button {...props}>{store.config.title}</Button>;
};

export default doc;
File renamed without changes.
1 change: 1 addition & 0 deletions examples/starter/src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Button';
16 changes: 16 additions & 0 deletions examples/starter/src/components/Spinner/Spinner.docs.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { useStore } from '@component-controls/store';
import { Spinner } from './Spinner';

const doc = {
title: 'Library/Components/Spinner',
order: 1,
component: Spinner,
};

export const overview = props => {
const store = useStore();
return <Spinner {...props}>{store.config.title}</Spinner>;
};

export default doc;
File renamed without changes.
1 change: 1 addition & 0 deletions examples/starter/src/components/Spinner/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Spinner';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Button } from 'theme-ui';

export default {
title: 'Library/Components/Button',
title: 'Library/Components/External',
order: 2,
component: Button,
};
Expand Down
File renamed without changes.
15 changes: 0 additions & 15 deletions examples/starter/src/docs/first-story.stories.tsx

This file was deleted.

7 changes: 6 additions & 1 deletion examples/starter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
"resolveJsonModule": true
},
"exclude": ["node_modules", "public", ".cache"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"src/components/Spinner/Spinner.docs.jsx"
]
}

0 comments on commit e6e9df2

Please sign in to comment.