Skip to content

Commit

Permalink
Feat: Move existing examples into Storybook and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zplata committed Jun 8, 2022
1 parent 90c6d1e commit ec230fa
Show file tree
Hide file tree
Showing 66 changed files with 528 additions and 953 deletions.
22 changes: 12 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
module.exports = {
env: {
browser: true,
es2021: true,
es2021: true
},
extends: ['plugin:react/recommended', 'prettier'],
extends: ['plugin:react/recommended', 'prettier', 'plugin:storybook/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
jsx: true
},
ecmaVersion: 12,
sourceType: 'module',
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'prefer-const': ['warn', { destructuring: 'all' }],
'prefer-const': ['warn', {
destructuring: 'all'
}],
'no-var': 'error',
eqeqeq: ['error', 'smart'],
eqeqeq: ['error', 'smart']
},
settings: {
react: {
version: 'detect',
},
},
};
version: 'detect'
}
}
};
13 changes: 13 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
"stories": [
"../examples/stories/*.stories.mdx",
"../examples/stories/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions"
],
"framework": "@storybook/react",
staticDirs: ['../examples/stories/assets'],
}
17 changes: 17 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
data-href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&amp;display=swap"
/>
<link
rel="stylesheet"
data-href="https://fonts.googleapis.com/css2?family=Roboto+Mono&amp;display=swap"
/>

<style>
body {
font-family: 'Roboto', sans-serif;
font-size: 16px;
}
</style>
39 changes: 39 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: {
method: 'alphabetical',
order: ['Overview', 'Playback Controls', 'State Machines'],
},
},
viewMode: 'docs',
};

// The below function helps to default to the docs page, which contains all the documentation and examples
function clickDocsButtonOnFirstLoad() {
window.removeEventListener("load", clickDocsButtonOnFirstLoad);

try {
const docsButtonSelector = window.parent.document.evaluate(
"//button[contains(., 'Docs')]",
window.parent.document,
null,
XPathResult.ANY_TYPE,
null
);

const button = docsButtonSelector.iterateNext();

button.click();
} catch (error) {
// Do nothing if it wasn't able to click on Docs button.
}
}

window.addEventListener("load", clickDocsButtonOnFirstLoad);
23 changes: 0 additions & 23 deletions examples/basic-typescript/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions examples/basic-typescript/README.md

This file was deleted.

44 changes: 0 additions & 44 deletions examples/basic-typescript/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions examples/basic-typescript/public/index.html

This file was deleted.

19 changes: 0 additions & 19 deletions examples/basic-typescript/src/App.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions examples/basic-typescript/src/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion examples/basic-typescript/src/react-app-env.d.ts

This file was deleted.

26 changes: 0 additions & 26 deletions examples/basic-typescript/tsconfig.json

This file was deleted.

14 changes: 0 additions & 14 deletions examples/basic-with-hook/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions examples/basic-with-hook/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions examples/basic-with-hook/public/index.html

This file was deleted.

Binary file removed examples/basic-with-hook/public/magic-ball.riv
Binary file not shown.
Binary file removed examples/basic-with-hook/public/poison-loader.riv
Binary file not shown.
29 changes: 0 additions & 29 deletions examples/basic-with-hook/src/App.js

This file was deleted.

10 changes: 0 additions & 10 deletions examples/basic-with-hook/src/index.js

This file was deleted.

0 comments on commit ec230fa

Please sign in to comment.