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

feat(template): add solidjs (beta) #447

Merged
merged 5 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sandpack-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"build:types": "tsc -p tsconfig.json",
"lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"build:publish": "yarn build && gulp",
"build:bundler": "gulp",
"start": "tsc -p tsconfig.esm.json --watch"
"build:bundler": "gulp"
},
"files": [
"dist",
Expand Down
5 changes: 4 additions & 1 deletion sandpack-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export class SandpackClient {
sandboxInfo = this.sandboxInfo,
isInitializationCompile?: boolean
): void {
this.sandboxInfo = sandboxInfo;
this.sandboxInfo = {
...this.sandboxInfo,
...sandboxInfo,
};

const files = this.getFiles();

Expand Down
2 changes: 1 addition & 1 deletion sandpack-react/src/Playground.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sandpack } from "../";
import { Sandpack } from "./";

export default {
title: "Intro/Playground",
Expand Down
3 changes: 3 additions & 0 deletions sandpack-react/src/presets/Sandpack.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ClasserProvider } from "@code-hike/classer";
import type { SandpackLogLevel } from "@codesandbox/sandpack-client";
import * as React from "react";

import { SandpackLayout } from "../common/Layout";
Expand Down Expand Up @@ -69,6 +70,7 @@ export interface SandpackProps {
* appears when `readOnly` is `true`
*/
showReadOnly?: boolean;
logLevel?: SandpackLogLevel;
};
}

Expand Down Expand Up @@ -118,6 +120,7 @@ export const Sandpack: React.FC<SandpackProps> = (props) => {
initMode: props.options?.initMode,
initModeObserverOptions: props.options?.initModeObserverOptions,
externalResources: props.options?.externalResources,
logLevel: props.options?.logLevel,
};

// Parts are set as `flex` values, so they set the flex shrink/grow
Expand Down
2 changes: 2 additions & 0 deletions sandpack-react/src/templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { SandpackPredefinedTemplate, SandboxTemplate } from "../types";
import { ANGULAR_TEMPLATE } from "./angular";
import { REACT_TEMPLATE } from "./react";
import { REACT_TYPESCRIPT_TEMPLATE } from "./react-typescript";
import { SOLID_TEMPLATE } from "./solid";
import { SVELTE_TEMPLATE } from "./svelte";
import { VANILLA_TEMPLATE } from "./vanilla";
import { VANILLA_TYPESCRIPT_TEMPLATE } from "./vanilla-typescript";
Expand All @@ -21,4 +22,5 @@ export const SANDBOX_TEMPLATES: Record<
vue3: VUE_TEMPLATE_3,
angular: ANGULAR_TEMPLATE,
svelte: SVELTE_TEMPLATE,
"solid-beta": SOLID_TEMPLATE,
};
58 changes: 58 additions & 0 deletions sandpack-react/src/templates/solid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { SandboxTemplate } from "../types";

export const SOLID_TEMPLATE: SandboxTemplate = {
files: {
"/App.tsx": {
code: `import { Component } from "solid-js";

const App: Component = () => {
return <h1>Hello Solid!</h1>;
};

export default App;`,
},
"/index.tsx": {
code: `import { render } from "solid-js/web";
import App from "./App";

import "./styles.css";

render(() => <App />, document.getElementById("app"));`,
},
"/styles.css": {
code: `body {
font-family: sans-serif;
-webkit-font-smoothing: auto;
-moz-font-smoothing: auto;
-moz-osx-font-smoothing: grayscale;
font-smoothing: auto;
text-rendering: optimizeLegibility;
font-smooth: always;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
}

h1 {
font-size: 1.5rem;
}`,
},
"/index.html": {
code: `<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"></div>
<script src="src/index.tsx"></script>
</body>
</html>`,
},
},
dependencies: {
"solid-js": "1.3.15",
},
entry: "/index.tsx",
main: "/App.tsx",
environment: "solid",
};
6 changes: 4 additions & 2 deletions sandpack-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export type SandboxEnvironment =
| "svelte"
| "parcel"
| "vue-cli"
| "static";
| "static"
| "solid";

export type SandpackPredefinedTemplate =
| "angular"
Expand All @@ -166,7 +167,8 @@ export type SandpackPredefinedTemplate =
| "vanilla-ts"
| "vue"
| "vue3"
| "svelte";
| "svelte"
| "solid-beta";

export type SandpackPredefinedTheme =
| "light"
Expand Down
40 changes: 7 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5251,6 +5251,11 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==

"@types/lz-string@^1.3.34":
version "1.3.34"
resolved "https://registry.yarnpkg.com/@types/lz-string/-/lz-string-1.3.34.tgz#69bfadde419314b4a374bf2c8e58659c035ed0a5"
integrity sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow==

"@types/mdast@^3.0.0":
version "3.0.10"
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.10.tgz#4724244a82a4598884cbbe9bcfd73dff927ee8af"
Expand Down Expand Up @@ -7047,7 +7052,7 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

binaryextensions@2, binaryextensions@^2.1.2:
binaryextensions@2:
version "2.3.0"
resolved "https://registry.yarnpkg.com/binaryextensions/-/binaryextensions-2.3.0.tgz#1d269cbf7e6243ea886aa41453c3651ccbe13c22"
integrity sha512-nAihlQsYGyc5Bwq6+EsubvANYGExeJKHDO3RjnvwU042fawQTQfM3Kxn7IHUXQOz4bzfwsGYYHGSvXyW4zOGLg==
Expand Down Expand Up @@ -8076,15 +8081,6 @@ codesandbox-import-utils@^1.2.3:
istextorbinary "2.2.1"
lz-string "^1.4.4"

codesandbox-import-utils@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/codesandbox-import-utils/-/codesandbox-import-utils-2.2.3.tgz#f7b4801245b381cb8c90fe245e336624e19b6c84"
integrity sha512-ymtmcgZKU27U+nM2qUb21aO8Ut/u2S9s6KorOgG81weP+NA0UZkaHKlaRqbLJ9h4i/4FLvwmEXYAnTjNmp6ogg==
dependencies:
codesandbox-import-util-types "^2.2.3"
istextorbinary "^2.2.1"
lz-string "^1.4.4"

collapse-white-space@^1.0.2:
version "1.0.6"
resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287"
Expand Down Expand Up @@ -9908,14 +9904,6 @@ editions@^1.3.3:
resolved "https://registry.yarnpkg.com/editions/-/editions-1.3.4.tgz#3662cb592347c3168eb8e498a0ff73271d67f50b"
integrity sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==

editions@^2.2.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/editions/-/editions-2.3.1.tgz#3bc9962f1978e801312fbd0aebfed63b49bfe698"
integrity sha512-ptGvkwTvGdGfC0hfhKg0MT+TRLRKGtUiWGBInxOm5pz7ssADezahjCUaYuZ8Dr+C05FW0AECIIPt4WBxVINEhA==
dependencies:
errlop "^2.0.0"
semver "^6.3.0"

editorconfig@^0.15.3:
version "0.15.3"
resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5"
Expand Down Expand Up @@ -10127,11 +10115,6 @@ err-code@^2.0.2:
resolved "https://registry.yarnpkg.com/err-code/-/err-code-2.0.3.tgz#23c2f3b756ffdfc608d30e27c9a941024807e7f9"
integrity sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==

errlop@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/errlop/-/errlop-2.2.0.tgz#1ff383f8f917ae328bebb802d6ca69666a42d21b"
integrity sha512-e64Qj9+4aZzjzzFpZC7p5kmm/ccCrbLhAJplhsDXQFs87XTsXwOpH4s1Io2s90Tau/8r2j9f4l/thhDevRjzxw==

errno@^0.1.1, errno@^0.1.3, errno@~0.1.7:
version "0.1.8"
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f"
Expand Down Expand Up @@ -14017,15 +14000,6 @@ [email protected]:
editions "^1.3.3"
textextensions "2"

istextorbinary@^2.2.1:
version "2.6.0"
resolved "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-2.6.0.tgz#60776315fb0fa3999add276c02c69557b9ca28ab"
integrity sha512-+XRlFseT8B3L9KyjxxLjfXSLMuErKDsd8DBNrsaxoViABMEZlOSCstwmw0qpoFX3+U6yWU1yhLudAe6/lETGGA==
dependencies:
binaryextensions "^2.1.2"
editions "^2.2.0"
textextensions "^2.5.0"

iterate-iterator@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/iterate-iterator/-/iterate-iterator-1.0.2.tgz#551b804c9eaa15b847ea6a7cdc2f5bf1ec150f91"
Expand Down Expand Up @@ -22053,7 +22027,7 @@ [email protected], text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=

textextensions@2, textextensions@^2.5.0:
textextensions@2:
version "2.6.0"
resolved "https://registry.yarnpkg.com/textextensions/-/textextensions-2.6.0.tgz#d7e4ab13fe54e32e08873be40d51b74229b00fc4"
integrity sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==
Expand Down