Skip to content

Commit e43fa0f

Browse files
committed
Imrove FE
1 parent ae3917c commit e43fa0f

7 files changed

Lines changed: 44 additions & 28 deletions

File tree

.githooks/pre-commit

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ set -euo pipefail
44
ROOT_DIR="$(git rev-parse --show-toplevel)"
55
cd "$ROOT_DIR"
66

7-
TARGET_PREFIX="apps/codebattle/assets/js/"
7+
JS_PREFIX="apps/codebattle/assets/js/"
8+
SCSS_PREFIX="apps/codebattle/assets/css/"
89
APP_DIR="apps/codebattle"
910
APP_PREFIX="apps/codebattle/"
1011
ELIXIR_PATTERN='(^mix\.exs$|^\.formatter\.exs$|^config/.*\.exs$|.*\.(ex|exs)$)'
@@ -14,7 +15,15 @@ while IFS= read -r file; do
1415
JS_STAGED_FILES+=("$file")
1516
done < <(
1617
git diff --cached --name-only --diff-filter=ACMR |
17-
grep -E "^${TARGET_PREFIX}.*\\.(js|jsx|ts|tsx)$" || true
18+
grep -E "^${JS_PREFIX}.*\\.(js|jsx|ts|tsx)$" || true
19+
)
20+
21+
SCSS_STAGED_FILES=()
22+
while IFS= read -r file; do
23+
SCSS_STAGED_FILES+=("$file")
24+
done < <(
25+
git diff --cached --name-only --diff-filter=ACMR |
26+
grep -E "^${SCSS_PREFIX}.*\\.scss$" || true
1827
)
1928

2029
ELIXIR_STAGED_FILES=()
@@ -25,7 +34,9 @@ done < <(
2534
grep -E "${ELIXIR_PATTERN}" || true
2635
)
2736

28-
if [ "${#JS_STAGED_FILES[@]}" -eq 0 ] && [ "${#ELIXIR_STAGED_FILES[@]}" -eq 0 ]; then
37+
if [ "${#JS_STAGED_FILES[@]}" -eq 0 ] \
38+
&& [ "${#SCSS_STAGED_FILES[@]}" -eq 0 ] \
39+
&& [ "${#ELIXIR_STAGED_FILES[@]}" -eq 0 ]; then
2940
exit 0
3041
fi
3142

@@ -36,12 +47,23 @@ if [ "${#ELIXIR_STAGED_FILES[@]}" -gt 0 ]; then
3647
fi
3748

3849
if [ "${#JS_STAGED_FILES[@]}" -gt 0 ]; then
39-
APP_FILES=()
50+
JS_APP_FILES=()
4051
for file in "${JS_STAGED_FILES[@]}"; do
41-
APP_FILES+=("${file#${APP_PREFIX}}")
52+
JS_APP_FILES+=("${file#${APP_PREFIX}}")
4253
done
4354

44-
pnpm --dir "$APP_DIR" exec oxfmt --write "${APP_FILES[@]}"
55+
pnpm --dir "$APP_DIR" exec oxfmt --write "${JS_APP_FILES[@]}"
56+
pnpm --dir "$APP_DIR" exec oxlint --fix "${JS_APP_FILES[@]}" || true
4557
git add -- "${JS_STAGED_FILES[@]}"
46-
pnpm --dir "$APP_DIR" exec oxlint "${APP_FILES[@]}"
58+
fi
59+
60+
if [ "${#SCSS_STAGED_FILES[@]}" -gt 0 ]; then
61+
SCSS_APP_FILES=()
62+
for file in "${SCSS_STAGED_FILES[@]}"; do
63+
SCSS_APP_FILES+=("${file#${APP_PREFIX}}")
64+
done
65+
66+
pnpm --dir "$APP_DIR" exec prettier --write "${SCSS_APP_FILES[@]}"
67+
pnpm --dir "$APP_DIR" exec stylelint --fix "${SCSS_APP_FILES[@]}" || true
68+
git add -- "${SCSS_STAGED_FILES[@]}"
4769
fi

apps/codebattle/assets/js/widgets/pages/groupTournament/EditorPanel.jsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,21 @@ function EditorPanel({ text, lang }) {
1414
fontSize: 14,
1515
editable: false,
1616
roomMode: "group_tournament",
17-
checkResult: () => { },
18-
toggleMuteSound: () => { },
17+
checkResult: () => {},
18+
toggleMuteSound: () => {},
1919
mute: false,
2020
userType: "spectator",
2121
userId: 0,
22-
onChangeCursorSelection: () => { },
23-
onChangeCursorPosition: () => { },
22+
onChangeCursorSelection: () => {},
23+
onChangeCursorPosition: () => {},
2424
syntax: lang || "javascript",
2525
gameStartTimeMs: 0,
26-
onTelemetryEvent: () => { },
26+
onTelemetryEvent: () => {},
2727
loading: false,
2828
canSendCursor: false,
2929
};
3030

31-
const {
32-
options,
33-
handleEditorWillMount,
34-
handleEditorDidMount,
35-
} = useEditor(editorProps);
31+
const { options, handleEditorWillMount, handleEditorDidMount } = useEditor(editorProps);
3632

3733
return (
3834
<div className="card border rounded max-vh-66 h-100">

apps/codebattle/assets/js/widgets/pages/groupTournament/GroupTournamentPageOld.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function GroupTournamentPage() {
366366
{data.groupTournament.name}
367367
<span className="cb-text ml-2">{data.groupTournament.state}</span>
368368
{data.groupTournament.state === "waiting_participants" &&
369-
timeline.startsInSeconds !== null
369+
timeline.startsInSeconds !== null
370370
? ` • starts in ${formatDuration(timeline.startsInSeconds)}`
371371
: ""}
372372
</div>
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React from "react";
22

33
function Header({ status }) {
4-
return (
5-
<div className="border rounded p-3">
6-
{/* Header component placeholder */}
7-
</div>
8-
);
4+
return <div className="border rounded p-3">{/* Header component placeholder */}</div>;
95
}
106

117
export default Header;

apps/codebattle/assets/js/widgets/pages/groupTournament/LogPanel.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ function LogPanel({ logs, className }) {
1212
<div className="mt-2 small">
1313
<ul className="list-unstyled mb-0">
1414
{logs.slice(0, 3).map((log, idx) => (
15-
<li key={idx} className="text-truncate">{log}</li>
15+
<li key={idx} className="text-truncate">
16+
{log}
17+
</li>
1618
))}
1719
{logs.length > 3 && <li>... and {logs.length - 3} more</li>}
1820
</ul>

apps/codebattle/assets/js/widgets/selectors/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ export const editorDataSelector = (playerId, roomMachineState) => (state) => {
130130

131131
const currentLangSlug =
132132
roomMachineState &&
133-
roomMachineState.matches({
134-
replayer: replayerMachineStates.on,
135-
})
133+
roomMachineState.matches({
134+
replayer: replayerMachineStates.on,
135+
})
136136
? meta.historyCurrentLangSlug
137137
: meta.currentLangSlug;
138138

apps/codebattle/assets/js/widgets/slices/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import chat, { actions as chatActions } from "./chat";
22
import completedGames, { actions as completedGamesActions } from "./completedGames";
33
import editor, { actions as editorActions } from "./editor";
4-
import groupTournament, { actions as groupTournamentActions } from './groupTournament';
4+
import groupTournament, { actions as groupTournamentActions } from "./groupTournament";
55
import event, { actions as eventActions } from "./event";
66
import executionOutput, { actions as executionOutputActions } from "./executionOutput";
77
import game, { actions as gameActions } from "./game";

0 commit comments

Comments
 (0)