Skip to content

Commit 753b1cf

Browse files
authored
Merge pull request #2224 from hexlet-codebattle/add_copy_btn
add_copy_btn
2 parents 3a4602e + 98b007f commit 753b1cf

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
3+
import copy from 'copy-to-clipboard';
4+
5+
import i18n from '../../../i18n';
6+
7+
const CopyEditorButton = ({ editor }) => {
8+
const className = 'btn btn-sm btn-secondary cb-btn-secondary cb-rounded mx-1';
9+
const text = i18n.t('Copy');
10+
11+
const handleCopyClick = () => {
12+
copy(editor.value);
13+
};
14+
15+
return (
16+
<button
17+
type="button"
18+
className={className}
19+
onClick={handleCopyClick}
20+
title={text}
21+
>
22+
{text}
23+
</button>
24+
);
25+
};
26+
27+
export default CopyEditorButton;

services/app/apps/codebattle/assets/js/widgets/pages/game/EditorToolbar.jsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import GameRoomModes from '../../config/gameModes';
66
import Placements from '../../config/placements';
77

88
// import DarkModeButton from './DarkModeButton';
9+
import CopyEditorButton from './CopyEditorButton';
910
import EditorResultIcon from './EditorResultIcon';
1011
import GameActionButtons from './GameActionButtons';
1112
import GameBanPlayerButton from './GameBanPlayerButton';
@@ -66,22 +67,27 @@ const EditorToolbar = ({
6667
{showControlBtns && !isHistory && editorState !== 'banned' && (
6768
<GameActionButtons {...actionBtnsProps} />
6869
)}
69-
<div
70-
className="btn-group btn-group-sm py-2 mx-2"
71-
role="group"
72-
aria-label="Report actions"
73-
>
74-
{!showControlBtns && (
70+
{!showControlBtns && (
71+
<div
72+
className="py-2"
73+
role="group"
74+
aria-label="Report actions"
75+
>
7576
<GameReportButton userId={player.id} gameId={gameId} />
76-
)}
77-
{isAdmin && !showControlBtns && (
78-
<GameBanPlayerButton
79-
userId={player.id}
80-
status={status}
81-
tournamentId={tournamentId}
82-
/>
83-
)}
84-
</div>
77+
{isAdmin && (
78+
<>
79+
<GameBanPlayerButton
80+
userId={player.id}
81+
status={status}
82+
tournamentId={tournamentId}
83+
/>
84+
<CopyEditorButton
85+
editor={editor}
86+
/>
87+
</>
88+
)}
89+
</div>
90+
)}
8591
<div
8692
className={userInfoClassNames}
8793
role="group"

services/app/apps/codebattle/assets/js/widgets/pages/game/GameActionButtons.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function GameActionButtons({
188188

189189
return (
190190
<div
191-
className="d-flex py-2 mr-2"
191+
className="d-flex py-2"
192192
role="group"
193193
aria-label="Game actions"
194194
>

services/app/apps/codebattle/assets/js/widgets/pages/game/InfoPanel.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const InfoPanel = ({
2424
return (
2525
<>
2626
<div className="col-12 col-lg-6 p-1 cb-height-info">
27-
<div className="d-flex shadow-sm flex-column h-100 cb-bg-panel">
27+
<div className="d-flex shadow-sm flex-column h-100 cb-bg-panel cb-rounded">
2828
<nav>
2929
<div
3030
className="nav nav-tabs cb-border-color text-uppercase font-weight-bold text-center"

0 commit comments

Comments
 (0)