Skip to content

Commit

Permalink
Use mdx.macro for create-react-app example
Browse files Browse the repository at this point in the history
Closes #358
  • Loading branch information
johno committed Dec 14, 2018
1 parent 3bd75e1 commit 1682149
Show file tree
Hide file tree
Showing 16 changed files with 4,301 additions and 2,541 deletions.
4 changes: 3 additions & 1 deletion examples/create-react-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
Expand Down
23 changes: 0 additions & 23 deletions examples/create-react-app/config-overrides.js

This file was deleted.

27 changes: 18 additions & 9 deletions examples/create-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
{
"name": "create-react-app",
"version": "0.1.0",
"private": true,
"name": "mdx-create-react-app",
"dependencies": {
"@mdx-js/loader": "^0.16.4",
"@mdx-js/mdx": "^0.16.4",
"mdx.macro": "^0.2.7",
"react": "^16.6.3",
"react-app-rewired": "^1.6.2",
"react-dom": "^16.6.3",
"react-scripts": "1.1.5"
"react-scripts": "2.1.1"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom"
}
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
4 changes: 2 additions & 2 deletions examples/create-react-app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
2 changes: 1 addition & 1 deletion examples/create-react-app/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "image/x-icon"
}
],
"start_url": "./index.html",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
Expand Down
48 changes: 42 additions & 6 deletions examples/create-react-app/readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
# MDX + Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

```shell
npm install
npm start
```
## Available Scripts

[See documentation](https://mdxjs.com/getting-started/create-react-app)
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/).
32 changes: 32 additions & 0 deletions examples/create-react-app/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.App {
text-align: center;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
22 changes: 10 additions & 12 deletions examples/create-react-app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React, {Component} from 'react'
import {MDXProvider} from '@mdx-js/tag'
import React, { lazy, Component, Suspense } from 'react';
import { importMDX } from 'mdx.macro';

import Hello from './hello.md'

const components = {
h1: props => <h1 style={{color: 'tomato'}} {...props} />
}
const Content = lazy(() => importMDX('./Content.mdx'));

class App extends Component {
render() {
return (
<MDXProvider components={components}>
<Hello />
</MDXProvider>
)
<div>
<Suspense fallback={<div>Loading...</div>}>
<Content />
</Suspense>
</div>
);
}
}

export default App
export default App;
14 changes: 7 additions & 7 deletions examples/create-react-app/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
})
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
8 changes: 8 additions & 0 deletions examples/create-react-app/src/Content.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const Demo = () => (
<div style={{ padding: 20, backgroundColor: "tomato" }} />
);

# Hello, world!

<Demo />

3 changes: 0 additions & 3 deletions examples/create-react-app/src/hello.md

This file was deleted.

14 changes: 14 additions & 0 deletions examples/create-react-app/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
15 changes: 11 additions & 4 deletions examples/create-react-app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'))
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: http://bit.ly/CRA-PWA
serviceWorker.unregister();
7 changes: 7 additions & 0 deletions examples/create-react-app/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1682149

Please sign in to comment.