Skip to content

Commit 3917050

Browse files
SaraVieiraCompuIves
authored andcommitted
make carroussel go arround; fix placeholders (codesandbox#1607)
1 parent 0892a9a commit 3917050

File tree

3 files changed

+26
-20
lines changed
  • packages
    • app/src/app/pages
      • Sandbox/Editor/Header/CollectionInfo
      • common/Modals/PreferencesModal/Appearance
    • homepage/src/pages

3 files changed

+26
-20
lines changed

packages/app/src/app/pages/Sandbox/Editor/Header/CollectionInfo/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class CollectionInfo extends React.Component {
7373

7474
render() {
7575
const { sandbox, isLoggedIn, signals } = this.props;
76+
const { nameValue, updatingName } = this.state;
77+
78+
const value = nameValue !== 'Untitled' && updatingName ? nameValue : '';
7679

7780
const folderName = sandbox.collection
7881
? basename(sandbox.collection.path) ||
@@ -85,7 +88,7 @@ class CollectionInfo extends React.Component {
8588
opacity: 1,
8689
}}
8790
to={
88-
this.state.updatingName
91+
updatingName
8992
? {
9093
opacity: 0,
9194
pointerEvents: 'none',
@@ -125,7 +128,7 @@ class CollectionInfo extends React.Component {
125128
</div>
126129
)}
127130
/>
128-
{this.state.updatingName ? (
131+
{updatingName ? (
129132
<form
130133
css={{
131134
position: 'absolute',
@@ -147,7 +150,8 @@ class CollectionInfo extends React.Component {
147150
onKeyUp={this.handleKeyUp}
148151
onBlur={this.handleBlur}
149152
onChange={this.handleInputUpdate}
150-
value={this.state.nameValue}
153+
placeholder={nameValue}
154+
value={value}
151155
/>
152156
</form>
153157
) : (

packages/app/src/app/pages/common/Modals/PreferencesModal/Appearance/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,12 @@ function EditorSettings({ store, signals }) {
127127
{'"'} as your color theme.
128128
</SubDescription>
129129

130-
<PreferenceText
131-
isTextArea
132-
style={{ fontFamily: 'Source Code Pro', fontSize: '.8rem' }}
133-
block
134-
rows={7}
135-
defaultValue={`You can use your own theme from VSCode directly:
136-
130+
<PreferenceText
131+
isTextArea
132+
style={{ fontFamily: 'Source Code Pro', fontSize: '.8rem' }}
133+
block
134+
rows={7}
135+
placeholder={`You can use your own theme from VSCode directly:
137136
1. Open VSCode
138137
2. Press (CMD or CTRL) + SHIFT + P
139138
3. Enter: '> Developer: Generate Color Scheme From Current Settings'
@@ -165,7 +164,7 @@ function EditorSettings({ store, signals }) {
165164
style={{ fontFamily: 'Source Code Pro', fontSize: '.8rem' }}
166165
block
167166
rows={7}
168-
defaultValue={`You can use your own theme from VSCode directly:
167+
placeholder={`You can use your own theme from VSCode directly:
169168
1. Open VSCode
170169
2. Press (CMD or CTRL) + SHIFT + P
171170
3. Enter: '> Developer: Generate Color Scheme From Current Settings'

packages/homepage/src/pages/explore.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,29 @@ export default class Explore extends React.PureComponent {
107107
};
108108

109109
navigateToNextSandbox = () => {
110-
this.setState(state => ({
111-
featuredSandboxIndex: state.featuredSandboxIndex + 1,
112-
}));
110+
const next = this.state.featuredSandboxIndex + 1;
111+
// if last go to first
112+
this.setState({
113+
featuredSandboxIndex: next === featuredSandboxes.length ? 0 : next,
114+
});
113115
};
114116

115117
navigateToPreviousSandbox = () => {
116-
this.setState(state => ({
117-
featuredSandboxIndex: state.featuredSandboxIndex - 1,
118-
}));
118+
const index = this.state.featuredSandboxIndex;
119+
120+
// if first go to last
121+
this.setState({
122+
featuredSandboxIndex:
123+
index === 0 ? featuredSandboxes.length - 1 : index - 1,
124+
});
119125
};
120126

121127
handleKeyPress = ({ keyCode }) => {
122-
const { featuredSandboxIndex } = this.state;
123128
switch (keyCode) {
124129
case ARROW_LEFT:
125-
if (featuredSandboxIndex === 0) return;
126130
this.navigateToPreviousSandbox();
127131
break;
128132
case ARROW_RIGHT:
129-
if (featuredSandboxIndex === featuredSandboxes.length - 1) return;
130133
this.navigateToNextSandbox();
131134
break;
132135
default:

0 commit comments

Comments
 (0)