Skip to content

Commit 81b262b

Browse files
authored
Merge pull request #309 from hatemhosny/update-livecodes
LiveCodes theme color & i18n
2 parents 6967d35 + e894545 commit 81b262b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

components/playgroundEditor/LiveCodes.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Config, Playground } from "livecodes";
33
import LiveCodesPlayground from "livecodes/react";
44
import { luaTestRunner, type Language } from "lib/playground/livecodes";
55
import { useDarkTheme } from "hooks/darkTheme";
6+
import { useRouter } from "next/router";
67

78
export default function LiveCodes({
89
language,
@@ -15,6 +16,14 @@ export default function LiveCodes({
1516
}) {
1617
const [playground, setPlayground] = useState<Playground | undefined>();
1718
const [darkTheme] = useDarkTheme();
19+
const { locale } = useRouter();
20+
21+
const getLanguageFromLocale = (locale_: string | undefined) =>
22+
!locale_
23+
? "en"
24+
: locale_ === "zh_Hans"
25+
? "zh-CN"
26+
: (locale_.split("_")[0] as Config["appLanguage"]);
1827

1928
const onReady = (sdk: Playground) => {
2029
setPlayground(sdk);
@@ -31,6 +40,7 @@ export default function LiveCodes({
3140
}, [playground, darkTheme]);
3241

3342
const baseConfig: Partial<Config> = {
43+
appLanguage: getLanguageFromLocale(locale),
3444
autoupdate: true,
3545
languages: [language === "jupyter" ? "python-wasm" : language],
3646
script: {
@@ -42,6 +52,7 @@ export default function LiveCodes({
4252
active: "console",
4353
status: "full",
4454
},
55+
themeColor: "hsl(205, 17%, 50%)", // the original theme color is "#3a4852" which is "hsl(205, 17%, 27%)"
4556
};
4657

4758
const getJSTSConfig = (
@@ -223,7 +234,7 @@ ${test.replace(pattern, "\n")}`.trimStart();
223234

224235
return (
225236
<LiveCodesPlayground
226-
appUrl="https://v34.livecodes.io/"
237+
appUrl="https://v39.livecodes.io/"
227238
loading="eager"
228239
config={config}
229240
style={{ borderRadius: "0", resize: "none" }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"highlight.js": "^11.5.1",
3636
"iframe-resizer-react": "^1.1.0",
3737
"katex": "^0.13.24",
38-
"livecodes": "0.6.0",
38+
"livecodes": "0.7.2",
3939
"marked": "^4.0.17",
4040
"next": "^12.1.0",
4141
"next-i18next": "^8.10.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,10 +2996,10 @@ levn@~0.3.0:
29962996
prelude-ls "~1.1.2"
29972997
type-check "~0.3.2"
29982998

2999-
livecodes@0.6.0:
3000-
version "0.6.0"
3001-
resolved "https://registry.yarnpkg.com/livecodes/-/livecodes-0.6.0.tgz#3ad0d4361f6615cea62b8d40acfa33a892d1542f"
3002-
integrity sha512-nUqS6yy3NAKhVw+wt6yLKiqKSNbpbaJddI+KgtpMeQuIclBZbvhXK/enF8w/vQfxODPf5tmXkq765DIDxwTLTA==
2999+
livecodes@0.7.2:
3000+
version "0.7.2"
3001+
resolved "https://registry.yarnpkg.com/livecodes/-/livecodes-0.7.2.tgz#117bea6a171e677a49958dc52d21e96ca6aa8bea"
3002+
integrity sha512-9u8s+/mOztX6Ll1ru1Tpv2V8Ctb5TRprxXxyhl4U71nUPQIgaGt5ZiwTdRg4HofPiEKsdC1drTnAi9gNL3XRhA==
30033003

30043004
locate-path@^2.0.0:
30053005
version "2.0.0"

0 commit comments

Comments
 (0)