aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/index.tsx
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-22 19:54:51 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-22 19:54:51 +0200
commit8cbf8fdcfdceab8a330bdc82e4260a55c125c37d (patch)
tree0354dcc6ce0704fc953e7665ecfcc700609549a2 /language-web/src/main/js/index.tsx
parentBump Material-UI version (diff)
downloadrefinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.tar.gz
refinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.tar.zst
refinery-8cbf8fdcfdceab8a330bdc82e4260a55c125c37d.zip
Covert language-web to TypeScript
Diffstat (limited to 'language-web/src/main/js/index.tsx')
-rw-r--r--language-web/src/main/js/index.tsx79
1 files changed, 79 insertions, 0 deletions
diff --git a/language-web/src/main/js/index.tsx b/language-web/src/main/js/index.tsx
new file mode 100644
index 00000000..f59b40a9
--- /dev/null
+++ b/language-web/src/main/js/index.tsx
@@ -0,0 +1,79 @@
1import { CacheProvider } from "@emotion/react";
2import React from 'react';
3import { render } from 'react-dom';
4import CssBaseline from '@material-ui/core/CssBaseline';
5import { ThemeProvider, createTheme } from '@material-ui/core/styles';
6import { getCache } from "tss-react/cache";
7
8import App from './App';
9import RootStore, { RootStoreProvider } from './RootStore';
10
11import '../css/index.scss';
12
13const initialValue = `class Family {
14 contains Person[] members
15}
16
17class Person {
18 Person[] children opposite parent
19 Person[0..1] parent opposite children
20 int age
21 TaxStatus taxStatus
22}
23
24enum TaxStatus {
25 child, student, adult, retired
26}
27
28% A child cannot have any dependents.
29error invalidTaxStatus(Person p) <->
30 taxStatus(p, child), children(p, _q).
31
32unique family.
33Family(family).
34members(family, anne).
35members(family, bob).
36members(family, ciri).
37children(anne, ciri).
38?children(bob, ciri).
39default children(ciri, *): false.
40taxStatus(anne, adult).
41age(anne, 35).
42bobAge: 27.
43age(bob, bobAge).
44!age(ciri, bobAge).
45
46scope Family = 1, Person += 5..10.
47`;
48
49const rootStore = new RootStore();
50rootStore.editorStore.updateValue(initialValue);
51
52const theme = createTheme({
53 palette: {
54 mode: 'dark',
55 background: {
56 default: '#212121',
57 paper: '#2f2f2f',
58 },
59 primary: {
60 main: '#82aaff',
61 },
62 secondary: {
63 main: '#ff5370',
64 },
65 },
66});
67
68const app = (
69 <CacheProvider value={getCache()}>
70 <ThemeProvider theme={theme}>
71 <CssBaseline/>
72 <RootStoreProvider rootStore={rootStore}>
73 <App/>
74 </RootStoreProvider>
75 </ThemeProvider>
76 </CacheProvider>
77);
78
79render(app, document.getElementById('app'));