Skip to content

Commit 507a8ba

Browse files
Added few default examples in playground. Made a few corrections in the readme.
1 parent 71b529d commit 507a8ba

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Datadance
22
Datadance is a Typescript based library to transform JSON data using a JSON output specification.
33

4+
Checkout the playground here : [Datadance Playground](https://datadance.app/design/build)
5+
46
# How to run the server
5-
```deno task serve```
7+
8+
```bash
9+
cd server
10+
deno task start
11+
```
612

713
# Transforms Expression Language Reference
814

@@ -148,6 +154,7 @@ Output:
148154
```
149155

150156
## Example using the CLI
151-
```
157+
```bash
158+
deno task compile # builds the binary
152159
./bin/datadance -i '{"hello": "world"}' -t '[{"also": "\"hello \" + input.hello"}]' -s '{"merge_method": "overwrite"}'
153160
```

server/islands/Playground/Playground.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,41 @@ import { useEffect, useRef, useState } from "preact/hooks";
22
import AceEditor from "ace-builds";
33
import ace from "ace-builds";
44
import Dracula from "ace-builds/src-noconflict/theme-dracula";
5-
import 'ace-builds/src-noconflict/ext-language_tools';
5+
import "ace-builds/src-noconflict/ext-language_tools";
66
import { transform } from "../../../core/transform.ts";
77
import { DataObject } from "../../../core/types.ts";
88
import { SerialOperations } from "../../../core/types.ts";
99

10-
ace.config.set('basePath', 'https://esm.sh/ace-builds@1.35.4/src-noconflict');
11-
ace.config.setModuleUrl('ace/mode/yaml', 'https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/mode-yaml.js');
10+
ace.config.set("basePath", "https://esm.sh/ace-builds@1.35.4/src-noconflict");
11+
ace.config.setModuleUrl(
12+
"ace/mode/yaml",
13+
"https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/mode-yaml.js"
14+
);
1215

1316
const Playground = () => {
14-
const [input, setInput] = useState<string>("{}");
15-
const [transforms, setTransforms] = useState<string>("");
17+
const [input, setInput] = useState<string>(`{
18+
"name": {
19+
"first": " malory",
20+
"last": "Archer"
21+
},
22+
"exes": [
23+
" Nikolai Jakov ",
24+
"Len Trexler",
25+
"Burt Reynolds"
26+
],
27+
"lastEx": 2
28+
}`);
29+
const [transforms, setTransforms] = useState<string>(
30+
`lastEx : derived.lastEx + 5
31+
modified : derived.lastEx
32+
original : input.lastEx
33+
nameObject :
34+
name : input.name.first | trim | capitalize + ' ' + input.name.last
35+
age : 25
36+
ex1 : '=>' + input.exes[0] | rtrim
37+
isMinor : derived.nameObject.age > 18
38+
nameLength : derived.nameObject.name | length
39+
nameUpper : derived.nameObject.name | upper`);
1640
const [output, setOutput] = useState<string>("");
1741
const [mergeMethod, setMergeMethod] = useState<string>("overwrite");
1842
const [errorMessage, setErrorMessage] = useState<string>("");
@@ -27,11 +51,11 @@ const Playground = () => {
2751
maxLines: 15,
2852
enableBasicAutocompletion: true,
2953
enableLiveAutocompletion: true,
30-
enableSnippets: true
54+
enableSnippets: true,
3155
});
3256
editor.setTheme(Dracula);
3357
editor.setValue(transforms, -1);
34-
ace.config.loadModule('ace/mode/yaml', (yamlMode: any) => {
58+
ace.config.loadModule("ace/mode/yaml", (yamlMode: any) => {
3559
editor.session.setMode(new yamlMode.Mode());
3660
});
3761
editor.session.on("change", async () => {

server/routes/_app.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function App({ Component }: PageProps) {
4444
</a>
4545
</li>
4646
<li>
47-
<a href="/docs" class="nav-link">
47+
<a href="https://docs.datadance.app" class="nav-link">
4848
Docs
4949
</a>
5050
</li>
@@ -56,11 +56,15 @@ export default function App({ Component }: PageProps) {
5656

5757
<Component />
5858
<br></br>
59-
<div class="container">
60-
<footer>
61-
<p class="text-center text-body-secondary">© 2024 Datadance, <a href="https://yakshavingdevs.org">Yak Shaving Devs</a></p>
62-
</footer>
63-
</div>
59+
60+
<footer class="container">
61+
<p class="text-center text-body-secondary">
62+
© 2024 Datadance,{" "}
63+
<a href="https://yakshavingdevs.org">Yak Shaving Devs</a>
64+
</p>
65+
</footer>
66+
<br></br>
67+
6468
<script
6569
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"
6670
integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy"

0 commit comments

Comments
 (0)