Skip to content

Commit e58d2aa

Browse files
committed
live
1 parent f436444 commit e58d2aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+11496
-0
lines changed

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"useBuiltIns": "entry"
7+
}
8+
]
9+
]
10+
}

.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": [
7+
"eslint:recommended"
8+
],
9+
"globals": {
10+
"Evaluatly": "writeable",
11+
"Atomics": "readonly",
12+
"SharedArrayBuffer": "readonly",
13+
"Stripe": "readonly",
14+
"gtag": "readonly"
15+
},
16+
"parserOptions": {
17+
"ecmaFeatures": {
18+
"jsx": true
19+
},
20+
"ecmaVersion": 2018,
21+
"sourceType": "module"
22+
},
23+
"rules": {
24+
"no-console" : "off",
25+
"no-unused-vars" : ["warn", { "varsIgnorePattern": "ignored" }]
26+
},
27+
"settings": {
28+
"propWrapperFunctions": [
29+
"forbidExtraProps",
30+
{"property": "freeze", "object": "Object"},
31+
{"property": "myFavoriteWrapper"}
32+
],
33+
"linkComponents": [
34+
"Hyperlink",
35+
{"name": "Link", "linkAttribute": "to"}
36+
]
37+
}
38+
};

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
node_modules
3+
vendor
4+
5+
dist
6+

entry.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'core-js/stable';
2+
import 'regenerator-runtime/runtime';
3+
4+
import { loadUrl, loadVar } from './src/Loader';
5+
6+
Evaluatly = window.Evaluatly = (() => (
7+
{
8+
loadVar: loadVar,
9+
loadUrl: loadUrl
10+
}
11+
))();

examples/simple/index.html

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Simple example</title>
7+
</head>
8+
<body>
9+
<script src="/dist/evaluatly.js"></script>
10+
<script>
11+
Evaluatly.loadVar({
12+
"hash": "example/simple",
13+
"story": {
14+
"env": {
15+
"back_label": "Back"
16+
},
17+
"pages": [
18+
{
19+
"items": [
20+
{ "type": "question", "value": "Choose a fruit!"},
21+
{ "type": "radio", "save_key": "fruit", "required": true,
22+
"options": [
23+
{ "label": "Apple 🍎" },
24+
{ "label": "Orange 🍊" },
25+
{ "label": "Banana 🍌" }
26+
]
27+
}
28+
],
29+
"submit" : { "label": "Next", "program": {"next_page": true} }
30+
},
31+
{
32+
"items": [
33+
{ "type": "title", "value": "{{fruit.label}} is awesome!" }
34+
]
35+
}
36+
]
37+
},
38+
"theme": {
39+
"page": {
40+
"font-family": "google:Lato",
41+
"font-size": "20px",
42+
"color": "#4b3f32",
43+
"background-color": "#f5f1ed"
44+
},
45+
"content": {
46+
"align-items": "center",
47+
"text-align": "center",
48+
"justify-content": "center"
49+
},
50+
"title": {
51+
"color" : "#000000"
52+
},
53+
"subtitle": {
54+
"color" : "#000000"
55+
},
56+
"question": {
57+
"color" : "#000000"
58+
},
59+
"button": {
60+
"background-color": "#f1574b",
61+
"color": "#ffffff",
62+
"border-radius" : "100px",
63+
"border-width" : "3px"
64+
},
65+
"button:hover": {
66+
"background-color": "#ffffff",
67+
"color": "#f1574b"
68+
},
69+
"link": {
70+
"color": "#f1574b"
71+
},
72+
"form_submit.inputs": {
73+
"background-color": "#fff"
74+
},
75+
"form_submit .input": {
76+
"color": "#000"
77+
},
78+
"form .option:hover": {
79+
"color": "#3e306e"
80+
},
81+
"form_submit .option:hover": {
82+
"color": "#3e306e"
83+
}
84+
}
85+
});
86+
</script>
87+
</body>
88+
</html>
89+
90+

examples/url/data.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"hash": "example/url",
3+
"story": {
4+
"env": {
5+
"back_label": "Back"
6+
},
7+
"pages": [
8+
{
9+
"items": [
10+
{ "type": "question", "value": "Choose a fruit!"},
11+
{ "type": "radio", "save_key": "fruit", "required": true,
12+
"options": [
13+
{ "label": "Apple 🍎" },
14+
{ "label": "Orange 🍊" },
15+
{ "label": "Banana 🍌" }
16+
]
17+
}
18+
],
19+
"submit" : { "label": "Next", "program": {"next_page": true} }
20+
},
21+
{
22+
"items": [
23+
{ "type": "title", "value": "{{fruit.label}} is awesome!" }
24+
]
25+
}
26+
]
27+
},
28+
"theme": {
29+
"page": {
30+
"font-family": "google:Lato",
31+
"font-size": "20px",
32+
"color": "#4b3f32",
33+
"background-color": "#f5f1ed"
34+
},
35+
"content": {
36+
"align-items": "center",
37+
"text-align": "center",
38+
"justify-content": "center"
39+
},
40+
"title": {
41+
"color" : "#000000"
42+
},
43+
"subtitle": {
44+
"color" : "#000000"
45+
},
46+
"question": {
47+
"color" : "#000000"
48+
},
49+
"button": {
50+
"background-color": "#f1574b",
51+
"color": "#ffffff",
52+
"border-radius" : "100px",
53+
"border-width" : "3px"
54+
},
55+
"button:hover": {
56+
"background-color": "#ffffff",
57+
"color": "#f1574b"
58+
},
59+
"link": {
60+
"color": "#f1574b"
61+
},
62+
"form_submit.inputs": {
63+
"background-color": "#fff"
64+
},
65+
"form_submit .input": {
66+
"color": "#000"
67+
},
68+
"form .option:hover": {
69+
"color": "#3e306e"
70+
},
71+
"form_submit .option:hover": {
72+
"color": "#3e306e"
73+
}
74+
}
75+
}
76+
77+

examples/url/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>URL example</title>
7+
</head>
8+
<body>
9+
<script src="/dist/evaluatly.js"></script>
10+
<script>
11+
Evaluatly.loadUrl('data.json');
12+
</script>
13+
</body>
14+
</html>
15+
16+

examples/wdr/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"title": "Choose a fruit",
3+
"options": [
4+
"Apple 🍎",
5+
"Orange 🍊",
6+
"Banana 🍌"
7+
],
8+
"render": "<html hidden></html><script src=dist/render.js></script></html>",
9+
"noscript": "<noscript><style>html{display:block !important; white-space:pre}</style></noscript>"
10+
}

examples/wdr/src/index.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
const wdrLoader = require("wdr-loader");
2+
3+
wdrLoader(data=> {
4+
render(data);
5+
})
6+
7+
function render(data) {
8+
document.title = 'WDR example';
9+
loadScript("/dist/evaluatly.js", () => Evaluatly.loadVar(template(data)));
10+
}
11+
12+
function template(data) {
13+
14+
return (
15+
{
16+
"hash": "example/wdr",
17+
"story": {
18+
"env": {
19+
"back_label": "Back"
20+
},
21+
"pages": [
22+
{
23+
"items": [
24+
{ "type": "question", "value": data.title},
25+
{ "type": "radio", "save_key": "fruit", "required": true,
26+
"options": data.options.map(item => ({ "label": item }))
27+
}
28+
],
29+
"submit" : { "label": "Next", "program": {"next_page": true} }
30+
},
31+
{
32+
"items": [
33+
{ "type": "title", "value": "{{fruit.label}} is awesome!" }
34+
]
35+
}
36+
]
37+
},
38+
"theme": {
39+
"page": {
40+
"font-family": "google:Lato",
41+
"font-size": "20px",
42+
"color": "#4b3f32",
43+
"background-color": "#f5f1ed"
44+
},
45+
"content": {
46+
"align-items": "center",
47+
"text-align": "center",
48+
"justify-content": "center"
49+
},
50+
"title": {
51+
"color" : "#000000"
52+
},
53+
"subtitle": {
54+
"color" : "#000000"
55+
},
56+
"question": {
57+
"color" : "#000000"
58+
},
59+
"button": {
60+
"background-color": "#f1574b",
61+
"color": "#ffffff",
62+
"border-radius" : "100px",
63+
"border-width" : "3px"
64+
},
65+
"button:hover": {
66+
"background-color": "#ffffff",
67+
"color": "#f1574b"
68+
},
69+
"link": {
70+
"color": "#f1574b"
71+
},
72+
"form_submit.inputs": {
73+
"background-color": "#fff"
74+
},
75+
"form_submit .input": {
76+
"color": "#000"
77+
},
78+
"form .option:hover": {
79+
"color": "#3e306e"
80+
},
81+
"form_submit .option:hover": {
82+
"color": "#3e306e"
83+
}
84+
}
85+
});
86+
87+
}
88+
89+
function loadScript(url, onload) {
90+
const script = document.createElement('script');
91+
script.type = 'text/javascript';
92+
script.async = true;
93+
document.head.appendChild(script);
94+
script.onload = onload;
95+
script.src = url;
96+
}

0 commit comments

Comments
 (0)