Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 13, 2020
1 parent 82e95b9 commit b7b0e90
Show file tree
Hide file tree
Showing 20 changed files with 1,267 additions and 113 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist
.cache
.rpt2_cache
*.log
public
public
.next
42 changes: 42 additions & 0 deletions examples/nextjs/.config/buildtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = {
stories: [
'../../stories/src/blogs/*.mdx',
'../../stories/src/authors/*.mdx',
'../../stories/src/pages/*.mdx',
'../../stories/src/tutorial/getting-started/*.mdx',
'../../stories/src/tutorial/write-documentation/*.mdx',
'../../stories/src/tutorial/configuration/*.mdx',
'../../stories/src/tutorial/parts/*.mdx',
'../../stories/src/stories/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../core/core/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/editors/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/axe-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
// '../../stories/src/blogs/introduction-to-controls.mdx',
],
pages: {
story: {
basePath: 'api/',
},
blog: {
basePath: 'blogs/',
},
tutorial: {
basePath: 'tutorial/',
},
},
webpack: (config = {}, options = {}) => {
return {
...config,
plugins: [
...config.plugins,
//new BundleAnalyzerPlugin({ generateStatsFile: true, statsFilename: 'stats.json' })
]
};
},

};
74 changes: 74 additions & 0 deletions examples/nextjs/.config/runtime.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/** @jsx jsx */
import { jsx, Box, Text } from 'theme-ui';
import { RunOnlyConfiguration } from "@component-controls/core";
import { Link } from "@component-controls/components";
import { OctofaceIcon } from '@primer/octicons-react';

const categories = ['Introduction', 'Application','Controls','Blocks', 'Editors', 'Components', 'Plugins']

const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
siteTitle: `Component controls`,
siteTitleAlt: `Component controls - https://github.com/ccontrols/component-controls`,
siteHeadline: `Component controls gatsby`,
siteUrl: `https://component-controls-gatsby.netlify.app`,
siteDescription: `Component controls stories. Write your components documentation with MDX and JSX. Design, develop, test and review in a single site.`,
siteLanguage: `en`,
author: `@component-controls`,
theme: {
colors: {
//primary: 'pink',
}
},
pages: {
story: {
label: 'API',
},
tutorial: {
label: 'Tutorial',
topMenu: true,
navSidebar: true,
contextSidebar: true,
},
},
storySort: (a, b) => {
const aDoc = a.split('/')[0];
const aIndex = categories.findIndex(c => c === aDoc);
const bDoc = b.split('/')[0];
const bIndex = categories.findIndex(c => c === bDoc);
return aIndex - bIndex;
},
toolbar: {
right: [
{
node: (
<Link href="https://twitter.com/atanasster">
<Box sx={{ mr: 1, display: 'flex', flexDirection: 'row', alignItems: 'center'}} >
<svg viewBox="0 0 24 20" xmlns="http://www.w3.org/2000/svg" width={16} height={16} fill="currentColor" sx={{ pt: '1px'}}>
<path d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z">
</path>
</svg>
<Text sx={{ ml: '2px'}}>
twitter
</Text>
</Box>
</Link>
),
},
{
node: (
<Link href="https://github.com/ccontrols/component-controls">
<Box sx={{ mr: 1, display: 'flex', flexDirection: 'row', alignItems: 'center'}} >
<OctofaceIcon />
<Text sx={{ ml: '2px'}}>
github
</Text>
</Box>
</Link>
),
},
]
}
}

export default config;
48 changes: 48 additions & 0 deletions examples/nextjs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:mdx/recommended',
'prettier/@typescript-eslint',
],
rules: {
'comma-dangle': ['error', 'always-multiline'],
'no-mixed-operators': 'error',
'no-console': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
"no-restricted-globals":'error',
'react-hooks/rules-of-hooks': 'off',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
}
2 changes: 2 additions & 0 deletions examples/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
3 changes: 3 additions & 0 deletions examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const withStories = require('@component-controls/nextjs-plugin');

module.exports = withStories({ configPath: '.config', distDir: 'dist' });
27 changes: 27 additions & 0 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "component-controls-nextjs",
"private": true,
"version": "1.8.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build-sample": "next build",
"start": "next -p 9021"
},
"repository": {
"type": "git",
"url": "https://github.com/ccontrols/component-controls.git",
"directory": "examples/nextjs"
},
"dependencies": {
"@component-controls/nextjs-plugin": "^1.8.0",
"@component-controls/pages": "^1.8.0",
"next": "^9.4.4",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"typescript": "^3.9.3",
"webpack-bundle-analyzer": "^3.7.0"
}
}
31 changes: 31 additions & 0 deletions examples/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"jsx": "preserve",
"lib": [
"dom",
"esnext"
],
"strict": true,
"noEmit": true,
"isolatedModules": true,
"esModuleInterop": true,
"noUnusedLocals": false,
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"exclude": [
"node_modules",
"public",
".cache"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}
1 change: 1 addition & 0 deletions integrations/nextjs-plugin/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
21 changes: 21 additions & 0 deletions integrations/nextjs-plugin/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Atanas Stoyanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions integrations/nextjs-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Table of contents

# In action

[Example site](https://components-storybook-6-no-docs.netlify.app/?path=/test/components-actioncontainer--overview)

# Overview

Next.js plugin for documenting your projects with component controls

- Gatsby theme quick start.
- Full UI configurability with components shadowing.


# Getting Started

## Install

```sh
yarn add gatsby-theme-stories
```

## Configure

the default options will configure `component-controls` to work with react apps, with `react-docgen` for prop-types and `react-docgen-typescript` for typescript props information

in `gatsby-config.js`:

```js
plugins: [
...
{
resolve: '@component-controls/gatsby-theme-stories',
options: {
//path to the configuration files
configPath: '.config',
},
},
...
],

```

# API

<react-docgen-typescript path="./src" />

52 changes: 52 additions & 0 deletions integrations/nextjs-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@component-controls/nextjs-plugin",
"version": "1.8.0",
"description": "Nextjs plugin to create stories documentation sites",
"keywords": [
"story",
"nextjs"
],
"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist/",
"package.json",
"README.md"
],
"scripts": {
"build": "yarn cross-env NODE_ENV=production rollup -c",
"dev": "yarn cross-env NODE_ENV=development rollup -cw",
"docs": "ts-md",
"fix": "yarn lint --fix",
"lint": "yarn eslint . --ext mdx,ts,tsx",
"prepare": "yarn build",
"test": "yarn jest --passWithNoTests"
},
"homepage": "https://github.com/ccontrols/component-controls",
"bugs": {
"url": "https://github.com/ccontrols/component-controls/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/ccontrols/component-controls.git",
"directory": "integrations/nextjs-plugin"
},
"license": "MIT",
"dependencies": {
"@component-controls/webpack-compile": "^1.8.0",
"next": "^9.4.4"
},
"devDependencies": {
"@component-controls/ts-markdown-docs": "^1.5.0",
"@types/next": "^9.0.0",
"typescript": "^3.8.3"
},
"publishConfig": {
"access": "public"
},
"authors": [
"Atanas Stoyanov"
],
"gitHead": "c5145d66c6b8a355839e53c3bca97fd361ce9377"
}
5 changes: 5 additions & 0 deletions integrations/nextjs-plugin/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { config } from '../../rollup-config';

export default config({
input: ['./src/index.ts'],
});
Loading

0 comments on commit b7b0e90

Please sign in to comment.