Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/spectacle mdx loader addition #1228

Merged
merged 24 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
762b177
spectacle-mdx-loader addition setup
paulmarsicloud Aug 26, 2022
251d16b
mdx example updates
paulmarsicloud Aug 26, 2022
484f51e
Merge branch 'main' into chore/spectacle-mdx-loader-addition
paulmarsicloud Sep 16, 2022
9221a69
trying to add spectacle-mdx-loader
paulmarsicloud Sep 16, 2022
daffbc5
trying to add spectacle-mdx-loader
paulmarsicloud Sep 16, 2022
5ba53a8
testing out spectacle-mdx-loader
paulmarsicloud Sep 20, 2022
3c07137
testing out spectacle-mdx-loader
paulmarsicloud Sep 20, 2022
e96eb8e
Merge branch 'main' into chore/spectacle-mdx-loader-addition
paulmarsicloud Sep 20, 2022
8eaac34
testing out spectacle-mdx-loader
paulmarsicloud Sep 20, 2022
4de10ee
testing out spectacle-mdx-loader
paulmarsicloud Sep 20, 2022
0e8feb5
testing out spectacle-mdx-loader
paulmarsicloud Sep 20, 2022
78e1771
contributing update
paulmarsicloud Sep 20, 2022
298ee03
contributing update
paulmarsicloud Sep 20, 2022
daa02e8
webpack.config.js update
paulmarsicloud Sep 20, 2022
5586b52
PR feedback suggestions
paulmarsicloud Sep 20, 2022
6bdaec9
Clean up package and webpack config for mdx example.
ryan-roemer Sep 21, 2022
77009dc
Remove loop
ryan-roemer Sep 21, 2022
d9c59dd
Minor other cleanup
ryan-roemer Sep 21, 2022
a825036
Minor code cleanup
ryan-roemer Sep 21, 2022
6ce2d1e
Add ./examples/mdx:build
ryan-roemer Sep 22, 2022
910ce2e
Add changelog, fix deps
ryan-roemer Sep 23, 2022
b640452
lol ERR_PNPM_OUTDATED_LOCKFILE
ryan-roemer Sep 26, 2022
8d6e3d6
merge main into branch
paulmarsicloud Oct 7, 2022
b39de2f
Merge branch 'chore/spectacle-mdx-loader-addition' of github.com:Form…
paulmarsicloud Oct 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ We follow the convention of `start:NAME` to run an in-memory dev server for a sp
- [`examples/typescript`](https://github.com/FormidableLabs/spectacle/tree/main/examples/typescript)
- [`examples/one-page`](https://github.com/FormidableLabs/spectacle/tree/main/examples/one-page)
- `spectacle-mdx-loader`
- [`examples/mdx`](https://github.com/FormidableLabs/spectacle-mdx-loader/tree/main/examples/mdx)
- [`examples/mdx`](https://github.com/FormidableLabs/spectacle/tree/main/examples/mdx)

Here's how you can run the various examples:

Expand All @@ -49,6 +49,10 @@ $ open http://localhost:3100/
$ pnpm start:md
$ open http://localhost:3200/

# MDX demo app (in two different terminals)
$ pnpm start:mdx
$ open http://localhost:3300/

# One-page (no build, HTML page only) demo app (in two different terminals)
$ pnpm start:one-page
$ open examples/one-page/index.html
Expand Down
3 changes: 3 additions & 0 deletions examples/mdx/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.babelrc.js"
}
14 changes: 14 additions & 0 deletions examples/mdx/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title><%= htmlWebpackPlugin.options.title %></title>
<link
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
</body>
</html>
60 changes: 60 additions & 0 deletions examples/mdx/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { render } from 'react-dom';

import { MDXProvider } from '@mdx-js/react';

import {
Deck,
FlexBox,
Slide,
Box,
Progress,
FullScreen,
Notes,
mdxComponentMap
} from 'spectacle';

// SPECTACLE_CLI_MDX_START
import slides, { notes } from './slides.mdx';
// SPECTACLE_CLI_MDX_END

// SPECTACLE_CLI_THEME_START
const theme = {};
// SPECTACLE_CLI_THEME_END

// SPECTACLE_CLI_TEMPLATE_START
const template = () => (
<FlexBox
justifyContent="space-between"
position="absolute"
bottom={0}
width={1}
>
<Box padding="0 1em">
<FullScreen />
</Box>
<Box padding="1em">
<Progress />
</Box>
</FlexBox>
);
// SPECTACLE_CLI_TEMPLATE_END

const Presentation = () => (
<MDXProvider components={mdxComponentMap}>
<Deck theme={theme} template={template}>
{slides
.map((MDXSlide, i) => [MDXSlide, notes[i]])
.map(([MDXSlide, MDXNote], i) => (
<Slide key={`slide-${i}`} slideNum={i}>
<MDXSlide />
<Notes>
<MDXNote />
</Notes>
</Slide>
))}
</Deck>
</MDXProvider>
);

render(<Presentation />, document.getElementById('root'));
87 changes: 87 additions & 0 deletions examples/mdx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "spectacle-example-mdx",
"private": true,
"dependencies": {
"@mdx-js/react": "^1.5.3",
"prop-types": "^15.7.2",
"spectacle": "*",
"react": "^18.1.0",
"react-dom": "^18.1.0"
},
"devDependencies": {
"spectacle-mdx-loader": "*"
},
"scripts": {
"start": "webpack-dev-server --port=3300 --hot --config ./webpack.config.js",
"build": "wireit",
"lint": "wireit",
"lint:fix": "wireit",
"prettier": "wireit",
"prettier:fix": "wireit"
},
"wireit": {
"build": {
"command": "nps webpack",
"files": [
"*.{js,jsx,ts,tsx,html}"
],
"output": [
"dist/*"
],
"dependencies": [
"../../packages/spectacle:build:lib:esm"
],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"lint": {
"command": "nps \"lint:base *.js\"",
"files": [
"../../.eslintignore",
"../../.eslintrc",
"*.{js,jsx,ts,tsx}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"lint:fix": {
"command": "pnpm run lint || nps \"lint:base --fix *.js\"",
"files": [
"../../.eslintignore",
"../../.eslintrc",
"*.{js,jsx,ts,tsx}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"prettier": {
"command": "nps prettier:pkg -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,html}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"prettier:fix": {
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,html}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
}
}
}
68 changes: 68 additions & 0 deletions examples/mdx/slides.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Test from './test-component';
export const testProp = 50;

# Spectacle Presentation (MDX) 👋

This example uses:

- `mdx`
- `@babel/preset-react` for the React components we import

Notes: These are presenter notes. This text will be automatically exported as `notes` from your MDX file (e.g. `import {notes} from './my-file.mdx'`).

---

## Yellow div from a JSX component

<Test height={testProp} />

Notes: here are some more notes.

---

# Write your Spectacle Presentations in Markdown

## And seamlessly use React Components

**How sweet is that**
**(super sweet)**

---

![datboi](https://pbs.twimg.com/media/CkjFUyTXEAEysBY.jpg)

---

###### Typography

# Heading 1

## Heading 2

### Heading 3

#### Heading 4

##### Heading 5

###### Heading 6

Standard Text

---

> Example Quote

---

```jsx
import { createClient, Provider } from 'urql';

const client = createClient({ url: 'https://0ufyz.sse.codesandbox.io' });

const App = () => (
<Provider value={client}>
<Todos />
</Provider>
);
```
12 changes: 12 additions & 0 deletions examples/mdx/test-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
fritz-c marked this conversation as resolved.
Show resolved Hide resolved

const Test = ({ height }) => {
return <div style={{ height, width: '100%', backgroundColor: 'yellow' }} />;
};

Test.propTypes = {
height: PropTypes.number.isRequired
};

export default Test;
39 changes: 39 additions & 0 deletions examples/mdx/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const base = require('../../webpack.config.base');

/**
* Base configuration for the CLI, core, and examples.
*/
module.exports = {
...base,
mode: 'development',
context: __dirname,
entry: './index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'example.js'
},
externals: {},
devtool: 'source-map',
module: {
...base.module,
rules: [
...base.module.rules,
{
test: /\.mdx$/,
use: [
require.resolve('babel-loader'),
require.resolve('spectacle-mdx-loader')
]
}
]
},
plugins: [
...base.plugins,
new HtmlWebpackPlugin({
title: 'Spectacle MDX Development Example',
template: `./index.html`
})
]
};
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"changeset": "changeset",
"start:js": "concurrently --raw pnpm:build:spectacle:esm:watch pnpm:build:spectacle:types:watch \"pnpm run --filter ./examples/js start\"",
"start:md": "concurrently --raw pnpm:build:spectacle:esm:watch pnpm:build:spectacle:types:watch \"pnpm run --filter ./examples/md start\"",
"start:mdx": "concurrently --raw pnpm:build:spectacle:esm:watch pnpm:build:spectacle:types:watch \"pnpm run --filter ./examples/mdx start\"",
"start:ts": "concurrently --raw pnpm:build:spectacle:esm:watch pnpm:build:spectacle:types:watch \"pnpm run --filter ./examples/typescript start\"",
"start:one-page": "concurrently --raw pnpm:build:spectacle:dev:watch pnpm:build:spectacle:types:watch",
"start:examples": "concurrently --raw pnpm:build:spectacle:esm:watch pnpm:build:spectacle:dev:watch pnpm:build:spectacle:types:watch \"pnpm run --parallel --filter \\\"./examples/*\\\" start\"",
Expand Down Expand Up @@ -113,6 +114,7 @@
"./packages/spectacle:build",
"./examples/js:build",
"./examples/md:build",
"./examples/mdx:build",
"./examples/one-page:build",
"./examples/typescript:build"
]
Expand Down Expand Up @@ -167,9 +169,11 @@
"dependencies": [
"./packages/spectacle:lint",
"./packages/create-spectacle:lint",
"./packages/spectacle-mdx-loader:lint",
"./website:lint",
ryan-roemer marked this conversation as resolved.
Show resolved Hide resolved
"./examples/js:lint",
"./examples/md:lint",
"./examples/mdx:lint",
"./examples/one-page:lint",
"./examples/typescript:lint"
]
Expand All @@ -178,9 +182,11 @@
"dependencies": [
"./packages/spectacle:lint:fix",
"./packages/create-spectacle:lint:fix",
"./packages/spectacle-mdx-loader:lint:fix",
"./website:lint:fix",
"./examples/js:lint:fix",
"./examples/md:lint:fix",
"./examples/mdx:lint:fix",
"./examples/one-page:lint:fix",
"./examples/typescript:lint:fix"
]
Expand Down Expand Up @@ -227,9 +233,11 @@
"dependencies": [
"./packages/spectacle:prettier",
"./packages/create-spectacle:prettier",
"./packages/spectacle-mdx-loader:prettier",
"./website:prettier",
"./examples/js:prettier",
"./examples/md:prettier",
"./examples/mdx:prettier",
"./examples/one-page:prettier",
"./examples/typescript:prettier"
]
Expand All @@ -238,9 +246,11 @@
"dependencies": [
"./packages/spectacle:prettier:fix",
"./packages/create-spectacle:prettier:fix",
"./packages/spectacle-mdx-loader:prettier:fix",
"./website:prettier:fix",
"./examples/js:prettier:fix",
"./examples/md:prettier:fix",
"./examples/mdx:prettier:fix",
"./examples/one-page:prettier:fix",
"./examples/typescript:prettier:fix"
]
Expand Down
13 changes: 13 additions & 0 deletions packages/spectacle-mdx-loader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# spectacle-mdx-loader

## 0.1.1

- Update to `spectacle@6`.

## 0.1.0

- Move `examples/loader-mdx` to `examples/mdx` and publish for consumption by `spectacle-cli`.

## 0.0.1

- Initial release.