-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
18,439 additions
and
3,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
{ | ||
"previews": { | ||
"3000": { | ||
"name": "Playground", | ||
"script": "yarn workspace @codesandbox/sandpack-playground dev" | ||
}, | ||
"6006": { | ||
"name": "Storybook", | ||
"script": "yarn workspace @codesandbox/sandpack-react storybook" | ||
} | ||
"previews": { | ||
"1234": { | ||
"name": "Playground", | ||
"command": "yarn workspace @codesandbox/sandpack-playground dev" | ||
}, | ||
"6006": { | ||
"name": "Storybook", | ||
"command": "yarn workspace @codesandbox/sandpack-react storybook" | ||
}, | ||
"3000": { | ||
"name": "Docs", | ||
"command": "yarn dev:docs" | ||
} | ||
}, | ||
"tasks": { | ||
"setup": { | ||
"name": "Install Dependencies", | ||
"command": "yarn" | ||
}, | ||
"build": { | ||
"name": "Build Workspace", | ||
"command": "yarn build" | ||
}, | ||
"format": { | ||
"name": "Format Workspace", | ||
"command": "yarn format" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"setupTasks": [ | ||
{ | ||
"name": "Installing Dependencies", | ||
"command": "yarn install" | ||
}, | ||
{ | ||
"name": "Building Workspace", | ||
"command": "yarn build" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"default": { | ||
"name": "Default", | ||
"type": "SIDEKICK", | ||
"items": [ | ||
{ "type": "PREVIEW", "port": "3000" }, | ||
{ "type": "PREVIEW", "port": "6006" } | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
name: 🐛 Bug Report | ||
about: What went wrong? | ||
title: 'Bug: ' | ||
labels: 'bug' | ||
--- | ||
|
||
# Bug report | ||
|
||
## Packages affected | ||
|
||
- [ ] sandpack-client | ||
- [ ] sandpack-react | ||
|
||
## Description of the problem | ||
|
||
## What were you doing when the problem occurred? | ||
|
||
### What steps can we take to reproduce the problem? | ||
|
||
<!-- | ||
Your best chance of getting this bug looked at quickly is to provide an example. | ||
--> | ||
|
||
### Link to sandbox: [link]() (optional) | ||
|
||
### Your Environment | ||
|
||
| Software | Name/Version | | ||
| ----------------------- | ------------ | | ||
| Sandpack-client version | | | ||
| Sandpack-react version | | | ||
| Browser | | | ||
| Operating System | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
name: 📃 Documentation | ||
about: Report an issue related to documentation | ||
title: 'Documentation: ' | ||
labels: 'documentation' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: 🌈 Feature | ||
about: What cool thing would you like to add? | ||
title: 'Feature request: ' | ||
labels: 'feature request' | ||
--- | ||
|
||
# Tell us how you think we can improve Sandpack | ||
|
||
## Packages affected | ||
|
||
- [ ] sandpack-client | ||
- [ ] sandpack-react | ||
|
||
## What is this feature? | ||
|
||
## How would your idea work? | ||
|
||
## Do you have any examples of how you would like to see us implement it? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
contact_links: | ||
- name: Question | ||
url: https://github.com/codesandbox/sandpack/discussions | ||
about: Have any questions? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## What kind of change does this pull request introduce? | ||
|
||
<!-- Is it a Bug fix, feature, documentation update... --> | ||
|
||
## What is the current behavior? | ||
|
||
<!-- You can also link to an open issue here --> | ||
|
||
## What is the new behavior? | ||
|
||
<!-- if this is a feature change --> | ||
|
||
## What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated. | ||
|
||
1. Step A | ||
2. Step B | ||
3. Step C | ||
|
||
## Checklist | ||
|
||
<!-- Have you done all of these things? --> | ||
<!-- add "N/A" to the end of each line that's irrelevant to your changes --> | ||
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" --> | ||
|
||
- [ ] Documentation | ||
- [ ] Ready to be merged | ||
<!-- In your opinion, is this ready to be merged as soon as it's reviewed? --> | ||
|
||
<!-- feel free to add additional comments --> | ||
<!-- Thank you for contributing! --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
{} | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@codesandbox/sandpack-docusaurus", | ||
"private": true, | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "src/index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"build": "echo 1" | ||
}, | ||
"dependencies": { | ||
"@codesandbox/sandpack-react": "0.1.13", | ||
"@docusaurus/core": "2.0.0-beta.6", | ||
"@docusaurus/utils-validation": "2.0.0-beta.6" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.4 || ^17.0.0", | ||
"react-dom": "^16.8.4 || ^17.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=12.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const path = require("path"); | ||
const { validateThemeConfig } = require("./validateThemeConfig"); | ||
|
||
function theme() { | ||
return { | ||
name: "docusaurus-sandpack", | ||
|
||
getThemePath() { | ||
return path.resolve(__dirname, "./theme"); | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = theme; | ||
|
||
theme.validateThemeConfig = validateThemeConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Sandpack } from "@codesandbox/sandpack-react"; | ||
import CodeBlock from "@theme-init/CodeBlock"; | ||
import React from "react"; | ||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; | ||
|
||
import "./style.css"; | ||
|
||
const RenderSandpack = (props) => { | ||
const { siteConfig } = useDocusaurusContext(); | ||
const sandpackPluginOptions = siteConfig.themeConfig.sandpack; | ||
|
||
if (props.sandpack) { | ||
const { | ||
children, | ||
template = "react", | ||
file = "/App.js", | ||
theme = sandpackPluginOptions.theme, | ||
} = props; | ||
|
||
const occurrences = children | ||
.split(/(```(.*?[^\\])```)/gms) | ||
.filter((line) => line.startsWith("```")); | ||
|
||
const files = occurrences.reduce((acc, curr) => { | ||
const [firstLine, ...content] = curr.replace(/```/g, "").split("\n"); | ||
const fileName = firstLine.match(/file=(.+)/)?.[1] ?? ""; | ||
|
||
return { | ||
...acc, | ||
[fileName]: { | ||
code: content.join("\n"), | ||
}, | ||
}; | ||
}, {}); | ||
|
||
return ( | ||
<Sandpack | ||
files={occurrences.length ? files : { [file]: children }} | ||
template={template} | ||
theme={theme} | ||
/> | ||
); | ||
} | ||
|
||
return <CodeBlock {...props} />; | ||
}; | ||
|
||
export default RenderSandpack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import "@codesandbox/sandpack-react/dist/index.css"; | ||
|
||
.sp-wrapper { | ||
margin-bottom: 2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { Joi } = require("@docusaurus/utils-validation"); | ||
|
||
const DEFAULT_CONFIG = { | ||
theme: "codesandbox-light", | ||
}; | ||
exports.DEFAULT_CONFIG = DEFAULT_CONFIG; | ||
|
||
const Schema = Joi.object({ | ||
sandpack: Joi.object({ | ||
theme: Joi.string() | ||
.equal( | ||
"codesandbox-light", | ||
"codesandbox-dark", | ||
"night-owl", | ||
"aqua-blue", | ||
"github-light", | ||
"monokai-pro" | ||
) | ||
.default(DEFAULT_CONFIG.theme), | ||
}) | ||
.label("themeConfig.sandpack") | ||
.default(DEFAULT_CONFIG), | ||
}); | ||
exports.Schema = Schema; | ||
|
||
exports.validateThemeConfig = function ({ validate, themeConfig }) { | ||
return validate(Schema, themeConfig); | ||
}; |
Oops, something went wrong.