Skip to content

Commit a49f834

Browse files
committed
move ProjectName to a separate file
1 parent aa3b454 commit a49f834

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { useSelector } from 'react-redux';
4+
import { useSketchActions } from '../../hooks';
5+
import { selectProjectName } from '../../selectors/project';
6+
import EditableInput from '../EditableInput';
7+
8+
export default function ProjectName() {
9+
const { t } = useTranslation();
10+
11+
const { changeSketchName, canEditProjectName } = useSketchActions();
12+
13+
const projectName = useSelector(selectProjectName);
14+
15+
return (
16+
<EditableInput
17+
value={projectName}
18+
disabled={!canEditProjectName}
19+
aria-label={t('Toolbar.EditSketchARIA')}
20+
inputProps={{
21+
maxLength: 128,
22+
'aria-label': t('Toolbar.NewSketchNameARIA')
23+
}}
24+
validate={(text) => text.trim().length > 0}
25+
onChange={changeSketchName}
26+
/>
27+
);
28+
}

client/modules/IDE/components/Header/Toolbar.jsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import {
1515
setGridOutput,
1616
setTextOutput
1717
} from '../../actions/preferences';
18-
import { useSketchActions } from '../../hooks';
1918

2019
import PlayIcon from '../../../../images/play.svg';
2120
import StopIcon from '../../../../images/stop.svg';
2221
import PreferencesIcon from '../../../../images/preferences.svg';
23-
import EditableInput from '../EditableInput';
22+
import ProjectName from './ProjectName';
2423

2524
const Toolbar = (props) => {
2625
const { isPlaying, infiniteLoop, preferencesIsVisible } = useSelector(
@@ -31,7 +30,6 @@ const Toolbar = (props) => {
3130
const dispatch = useDispatch();
3231

3332
const { t } = useTranslation();
34-
const { changeSketchName, canEditProjectName } = useSketchActions();
3533

3634
const playButtonClass = classNames({
3735
'toolbar__play-button': true,
@@ -96,17 +94,7 @@ const Toolbar = (props) => {
9694
</label>
9795
</div>
9896
<div className="toolbar__project-name-container">
99-
<EditableInput
100-
value={project.name}
101-
disabled={!canEditProjectName}
102-
aria-label={t('Toolbar.EditSketchARIA')}
103-
inputProps={{
104-
maxLength: 128,
105-
'aria-label': t('Toolbar.NewSketchNameARIA')
106-
}}
107-
validate={(text) => text.trim().length > 0}
108-
onChange={changeSketchName}
109-
/>
97+
<ProjectName />
11098
{(() => {
11199
if (project.owner) {
112100
return (

0 commit comments

Comments
 (0)