Skip to content

Commit 67c3748

Browse files
committed
Merge branch 'next' into react-master
2 parents 22a84fd + d51cc76 commit 67c3748

File tree

93 files changed

+4628
-2826
lines changed

Some content is hidden

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

93 files changed

+4628
-2826
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
build
55
pnpm-lock.yaml
66
yarn.lock
7+
yarn-error.log

package.json

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
22
"name": "omega-website",
3-
"version": "2.0.3",
3+
"version": "3.0.0-dev",
44
"private": true,
55
"dependencies": {
6-
"@quentinguidee/react-jade-ui": "^0.3.2",
6+
"@octokit/core": "^3.4.0",
77
"@testing-library/jest-dom": "^4.2.4",
88
"@testing-library/react": "^9.5.0",
99
"@testing-library/user-event": "^7.2.1",
10-
"firebase": "^7.24.0",
11-
"jszip": "^3.6.0",
10+
"@types/jest": "^26.0.22",
11+
"@types/node": "^14.14.37",
12+
"@types/react": "^17.0.3",
13+
"@types/react-dom": "^17.0.3",
14+
"classnames": "^2.3.1",
15+
"firebase": "^7.17.2",
16+
"jszip": "^3.5.0",
1217
"monaco-editor": "^0.20.0",
1318
"monaco-editor-webpack-plugin": "^1.9.1",
1419
"node-sass": "^4.14.1",
@@ -22,7 +27,8 @@
2227
"react-resize-detector": "^4.2.3",
2328
"react-reveal": "^1.2.2",
2429
"react-router-dom": "^5.2.0",
25-
"react-scripts": "^3.4.4"
30+
"react-scripts": "^3.4.1",
31+
"typescript": "^4.2.4"
2632
},
2733
"scripts": {
2834
"start": "react-app-rewired start",
@@ -48,6 +54,7 @@
4854
]
4955
},
5056
"devDependencies": {
51-
"react-app-rewired": "^2.1.8"
57+
"@types/react-router-dom": "^5.1.7",
58+
"react-app-rewired": "^2.1.6"
5259
}
5360
}

public/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
</body>
4545
<script src="https://www.gstatic.com/firebasejs/7.16.1/firebase-app.js"></script>
4646
<script src="https://www.gstatic.com/firebasejs/7.16.1/firebase-analytics.js"></script>
47-
<script src="https://www.gstatic.com/firebasejs/7.16.1/firebase-messaging.js"></script>
4847

4948
<script>
5049
// Your web app's Firebase configuration
@@ -63,7 +62,7 @@
6362
if (window.location.hostname != "localhost") {
6463
firebase.analytics();
6564
} else {
66-
console.log("GA Disabled with localhost");
65+
console.log("%c FIREBASE %c GA Disabled with localhost", "background-color: #F57C00; color: #ffffff;", "");
6766
}
6867
</script>
6968
</html>

src/App.js

-89
This file was deleted.

src/App.tsx

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import React, { useState } from "react";
2+
3+
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
4+
import Header from "./components/header/Header";
5+
import Footer from "./components/footer/Footer";
6+
import Home from "./pages/Home";
7+
import Simulator from "./pages/Simulator";
8+
import FullSimulator from "./pages/simulator/FullSimulator";
9+
import Releases from "./pages/Releases";
10+
import Policy from "./pages/Policy";
11+
import Install from "./pages/Install";
12+
import IDEMain from "./pages/IDE";
13+
import IDEEditor from "./pages/omega-ide/src/ide/Editor";
14+
import IDESimulator from "./pages/omega-ide/src/ide/Simulator";
15+
import NotFound from "./pages/NotFound";
16+
import GithubConnector from "./GithubConnector";
17+
import CookiesConsent from "./components/cookiesconsent/CookiesConsent";
18+
19+
import { IntlProvider } from "react-intl";
20+
import translations from "./i18n/locales";
21+
import classNames from "classnames";
22+
import { getCookie, setCookie } from "./cookies";
23+
24+
import "./sass/omega.library.sass";
25+
26+
function App() {
27+
const getLang = () => {
28+
if (navigator.languages !== undefined) return navigator.languages[0];
29+
else return navigator.language;
30+
};
31+
32+
let initLang: any = localStorage.getItem("locale");
33+
if (initLang == null) initLang = getLang();
34+
if (!(initLang in translations)) {
35+
initLang = "en";
36+
}
37+
38+
const [theme, setTheme] = useState(getCookie("theme") || "light");
39+
const [lang, setLang] = useState(initLang);
40+
// @ts-ignore
41+
const [messages, setMessages] = useState(translations[initLang]);
42+
43+
const onChangeLanguage = (lang: string) => {
44+
localStorage.setItem("locale", lang);
45+
setLang(lang);
46+
// @ts-ignore
47+
setMessages(translations[lang]);
48+
};
49+
50+
const toggleTheme = () => {
51+
var newTheme = theme === "light" ? "dark" : "light";
52+
53+
setTheme(newTheme);
54+
setCookie("theme", newTheme);
55+
};
56+
57+
return (
58+
<IntlProvider locale={lang} messages={messages}>
59+
<Router>
60+
<div className={classNames("body", theme)}>
61+
{!window.location.pathname.includes("/simulator/run") && (
62+
<React.Fragment>
63+
<CookiesConsent linkToPolicy="/policy" />
64+
<Header theme={theme} toggleTheme={toggleTheme} />
65+
</React.Fragment>
66+
)}
67+
<Switch>
68+
<Route path="/simulator" component={Simulator} exact />
69+
<Route
70+
path="/simulator/run/full"
71+
component={FullSimulator}
72+
exact
73+
/>
74+
<Route path="/releases" component={Releases} exact />
75+
{/* <Route path="/beta" component={Beta} exact /> */}
76+
<Route path="/install" component={Install} exact />
77+
<Route path="/install/:version" component={Install} />
78+
<Route path="/policy" component={Policy} exact />
79+
<Route path="/ide/" component={IDEMain} exact />
80+
<Route
81+
path="/ide/editor"
82+
component={() => (
83+
<IDEEditor
84+
base="/ide/"
85+
connector={GithubConnector}
86+
vercel={true}
87+
/>
88+
)}
89+
exact
90+
/>
91+
<Route
92+
path="/ide/simulator"
93+
component={IDESimulator}
94+
exact
95+
/>
96+
{/* <Route path="/wiki" component={Wiki} exact /> */}
97+
<Route
98+
path="/"
99+
component={() => <Home theme={theme} />}
100+
exact
101+
/>
102+
<Route component={NotFound} />
103+
</Switch>
104+
{!window.location.pathname.includes("/simulator/run") && (
105+
<Footer
106+
locale={lang}
107+
onChangeLanguage={onChangeLanguage}
108+
/>
109+
)}
110+
</div>
111+
</Router>
112+
</IntlProvider>
113+
);
114+
}
115+
116+
export default App;

src/GithubConnector.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
import firebase from "firebase"
1+
import firebase from "./firebase"
32

43
/**
54
* Github connector class. Makes link between the firebase API and the frontend

src/components/button/Button.tsx

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import React, { Component } from "react";
2+
import styles from "./sass/Button.module.sass";
3+
import { Link } from "react-router-dom";
4+
import classNames from "classnames";
5+
6+
type ButtonProps = React.HTMLProps<HTMLDivElement> & {
7+
blue?: boolean;
8+
outline?: boolean;
9+
disabled?: boolean;
10+
loading?: boolean;
11+
big?: boolean;
12+
leftIcon?: string;
13+
rightIcon?: string;
14+
to?: string;
15+
isExternalLink?: boolean;
16+
};
17+
18+
export default class Button extends Component<ButtonProps> {
19+
constructor(props: ButtonProps) {
20+
super(props);
21+
22+
this.renderLeftIcon = this.renderLeftIcon.bind(this);
23+
this.renderRightIcon = this.renderRightIcon.bind(this);
24+
25+
this.renderContent = this.renderContent.bind(this);
26+
}
27+
28+
renderLeftIcon(icon?: string) {
29+
if (icon) {
30+
return (
31+
<i
32+
className={classNames(
33+
styles.icon,
34+
styles.iconLeft,
35+
"material-icons"
36+
)}
37+
>
38+
{icon}
39+
</i>
40+
);
41+
}
42+
}
43+
44+
renderRightIcon(icon?: string) {
45+
if (icon) {
46+
return (
47+
<i
48+
className={classNames(
49+
styles.icon,
50+
styles.iconRight,
51+
"material-icons"
52+
)}
53+
>
54+
{icon}
55+
</i>
56+
);
57+
}
58+
}
59+
60+
renderContent() {
61+
return (
62+
<React.Fragment>
63+
{this.renderLeftIcon(this.props.leftIcon)}
64+
{this.props.children}
65+
{this.renderRightIcon(this.props.rightIcon)}
66+
</React.Fragment>
67+
);
68+
}
69+
70+
render() {
71+
const props = {
72+
className: classNames({
73+
[styles.button]: true,
74+
[styles.blue]: this.props.blue,
75+
[styles.outline]: this.props.outline,
76+
[styles.disabled]: this.props.disabled,
77+
[styles.loading]: this.props.loading,
78+
[styles.big]: this.props.big,
79+
[this.props.className || ""]: true,
80+
}),
81+
};
82+
83+
let component;
84+
if (this.props.to) {
85+
component = (
86+
<Link to={this.props.to} {...props}>
87+
{this.renderContent()}
88+
</Link>
89+
);
90+
} else if (this.props.href) {
91+
let external;
92+
93+
if (this.props.isExternalLink) {
94+
external = {
95+
target: "_blank",
96+
rel: "noopener noreferrer",
97+
};
98+
}
99+
100+
component = (
101+
<a href={this.props.href} {...props} {...external}>
102+
{this.renderContent()}
103+
</a>
104+
);
105+
} else {
106+
component = (
107+
<div {...props} onClick={this.props.onClick}>
108+
{this.renderContent()}
109+
</div>
110+
);
111+
}
112+
113+
return component;
114+
}
115+
}

0 commit comments

Comments
 (0)