Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 25, 2021
1 parent f2eb346 commit 5436b37
Show file tree
Hide file tree
Showing 13 changed files with 3,177 additions and 146 deletions.
109 changes: 109 additions & 0 deletions examples/react-webpack/.config/buildtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const path = require('path');
require('dotenv').config();
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;

module.exports = {
stories: [
'../../stories/src/blogs/*.mdx',
'../../stories/src/showcase/*.mdx',
'../../stories/src/authors/*.mdx',
'../../stories/src/pages/*.mdx',
'../../stories/src/tutorial/getting-started/ssg/*.mdx',
'../../stories/src/tutorial/getting-started/*.mdx',
'../../stories/src/tutorial/write-documentation/*.mdx',
'../../stories/src/tutorial/design/*.mdx',
'../../stories/src/tutorial/design/tokens/*.mdx',
'../../stories/src/tutorial/testing/*.mdx',
'../../stories/src/tutorial/configuration/*.mdx',
'../../stories/src/tutorial/reference/*.mdx',
'../../stories/src/stories/*.stories.@(js|jsx|tsx|mdx)',
'../../stories/src/stories_native/*.stories.@(js|jsx|tsx|mdx)',
'../../stories/src/mdx-stories/*.mdx',
'../../stories/src/catalogs/*.mdx',
'../../../ui/components/src/**/*.mdx',
'../../../ui/components/src/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/blocks/src/**/*.mdx',
'../../../ui/blocks/src/**/*.@(stories.@(js|jsx|tsx)|mdx)',
'../../../ui/design-tokens/src/Colors/**/*.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)',
'../../../plugins/viewport-plugin/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/addon-stats/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/addon-catalog/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/figma-embed/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/addon-notes/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../plugins/addon-images/src/stories/**/*.stories.@(js|jsx|tsx|mdx)',
'../../../ui/app/src/**/*.stories.@(js|jsx|tsx|mdx)',
],
siteUrl:
process.env.NODE_ENV === 'development'
? 'http://localhost:9020'
: 'https://component-controls.com',
pages: {
story: {
basePath: 'api/',
tabs: {
page: '@component-controls/pages/ClassicPage',
test: '@component-controls/pages/TestingPage',
design: '@component-controls/pages/DesignPage',
},
},
tutorial: {
basePath: 'tutorial/',
},
showcase: {
basePath: 'showcase/',
},
},
search: {
indexingModule: require.resolve(
'@component-controls/search-algolia/indexing',
),
searchingModule: require.resolve('@component-controls/search-algolia'),
fields: ['title', 'description', 'source', 'tags', 'components'],
emptySearchDocuments: [
'Getting started/Site generators/Gatsby',
'Getting started/Site generators/Nextjs',
'Getting started/Documentation site',
'Writing Documentation/ESM Stories',
'Getting started/UI customization',
'Writing Documentation/MDX Documentation',
'Writing Documentation/MDX Stories',
],
options: {
saveIndex: true, // turn to false when no more needed to re-index algolia search
indexName: process.env.ALGOLIA_SEARCH_INDEX_NAME,
appID: process.env.ALGOLIA_SEARCH_APP_ID,
searchAPIKey: process.env.ALGOLIA_SEARCH_SEARCH_KEY,
adminAPIKey: process.env.ALGOLIA_SEARCH_ADMIN_KEY,
},
},
tokens: {
githubAccessToken: process.env.GITHUB_AUTH_TOKEN,
},
webpack: (config = {}, options = {}) => {
return {
...config,
plugins: [
...config.plugins,
//new BundleAnalyzerPlugin({ generateStatsFile: true, statsFilename: 'stats.json' })
],
};
},
instrument: {
components: {
resolveFile: (componentName, filePath) => {
if (filePath.includes('theme-ui/dist')) {
const resolved = path.resolve(
path.dirname(filePath),
`../../@theme-ui/components/index.d.ts`,
);
return resolved;
}
return filePath;
},
},
},
};
101 changes: 101 additions & 0 deletions examples/react-webpack/.config/runtime.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/** @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 = [
'ESM',
'MDX',
'Components',
'Blocks',
'Design Tokens',
'Plugins',
'Controls',
'Editors',
'Application',
];

const config: RunOnlyConfiguration = {
analytics: 'UA-172446254-1',
title: `Component controls`,
description: `A next-generation tool to create blazing-fast documentation sites`,
language: `en`,
author: `@component-controls`,
theme: {
colors: {
// primary: 'pink',
},
},
pages: {
story: {
label: 'API',
},
tutorial: {
label: 'Tutorial',
topMenu: true,
navSidebar: true,
contextSidebar: true,
},
showcase: {
label: 'Showcase',
topMenu: 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;
86 changes: 86 additions & 0 deletions examples/react-webpack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# create-react-app component-controls

## Using `create-docz-app`

```sh
npx create-react-app my-docs-site --template cra-template-component-controls
# or
npm init react-app my-docs-site --template cra-template-component-controls
# or
yarn create react-app my-docs-site --template cra-template-component-controls
```

## Install packages

```sh
yarn
```

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

### `npm run build` fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
51 changes: 51 additions & 0 deletions examples/react-webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "component-controls-cra-starter",
"private": true,
"version": "2.9.1",
"dependencies": {
"@component-controls/app": "^2.9.1",
"@component-controls/core": "^2.9.0",
"@component-controls/pages": "^2.9.1",
"@component-controls/routes": "^2.9.0",
"@component-controls/search-algolia": "^2.9.0",
"@component-controls/search-fusejs": "^2.9.0",
"@component-controls/store": "^2.9.1",
"@component-controls/webpack-compile": "^2.9.1",
"@component-controls/webpack-configs": "^2.9.1",
"react": "^17.0.1",
"react-app-rewired": "^2.1.8",
"react-dom": "^17.0.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"typescript": "^3.9.3",
"webpack-bundle-analyzer": "^3.7.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
7 changes: 7 additions & 0 deletions examples/react-webpack/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { FC } from 'react';

const App: FC = () => {
return <div>Hello</div>;
};

export default App;
11 changes: 11 additions & 0 deletions examples/react-webpack/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
1 change: 1 addition & 0 deletions examples/react-webpack/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
Loading

0 comments on commit 5436b37

Please sign in to comment.