Skip to content

Commit

Permalink
Add jsx example to playground
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Mar 1, 2024
1 parent 7cb9e7d commit 06735e2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion valuescript_vm/src/jsx_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl fmt::Display for JsxElement {

fn write_attributes(f: &mut fmt::Formatter<'_>, attrs: &Vec<(String, Val)>) -> fmt::Result {
for (key, val) in attrs {
write!(f, " {}=\x1b[33m\"{}\"\x1b[39m", key, val)?;
write!(f, " {}=\"{}\"", key, val)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion website/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{ "rule": "*", "severity": "warn" }
],
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"editor.tabSize": 2
}
1 change: 1 addition & 0 deletions website/src/playground/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import raw from "./raw.ts";
export const orderedFiles = [
"/tutorial/hello.ts",
"/tutorial/alsoJavaScript.js",
"/tutorial/alsoJsx.tsx",
"/tutorial/valueSemantics.ts",
"/tutorial/cantMutateCaptures.ts",
"/tutorial/classBehavior.ts",
Expand Down
14 changes: 14 additions & 0 deletions website/src/playground/files/root/tutorial/alsoJsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// You can also use JSX.

export default function main() {
return greet("world");
}

function greet(name: string) {
return (
<h1>
Hello
<span style="color: green;">{name}!</span>
</h1>
);
}
1 change: 1 addition & 0 deletions website/src/playground/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ESNext,
allowImportingTsExtensions: true,
jsx: monaco.languages.typescript.JsxEmit.Preserve,
});

0 comments on commit 06735e2

Please sign in to comment.