Skip to content

Commit d85b7d5

Browse files
committed
Make toggling on restore instead of a button
1 parent 22dee37 commit d85b7d5

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { p5SoundURL, useP5Version } from '../../hooks/useP5Version';
2323
import VersionPicker from '../VersionPicker';
2424
import { updateFileContent } from '../../actions/files';
2525
import { CmControllerContext } from '../../pages/IDEView';
26-
import Button from '../../../../common/Button';
2726
import Stars from '../Stars';
2827

2928
export default function Preferences() {
@@ -531,7 +530,19 @@ export default function Preferences() {
531530
<div className="preference__options">
532531
<input
533532
type="radio"
534-
onChange={() => updateHTML(versionInfo.setP5Sound(true))}
533+
onChange={() => {
534+
if (versionInfo.lastP5SoundURL) {
535+
// If the sketch previously used a nonstandard p5.sound
536+
// URL, restore that URL
537+
updateHTML(
538+
versionInfo.setP5SoundURL(versionInfo.lastP5SoundURL)
539+
);
540+
versionInfo.setLastP5SoundURL(undefined);
541+
} else {
542+
// Otherwise, turn on the default p5.sound URL
543+
updateHTML(versionInfo.setP5Sound(true));
544+
}
545+
}}
535546
aria-label={t('Preferences.AutosaveOnARIA')}
536547
name="soundaddon"
537548
id="soundaddon-on"
@@ -567,16 +578,9 @@ export default function Preferences() {
567578
{t('Preferences.Off')}
568579
</label>
569580
{versionInfo.lastP5SoundURL && (
570-
<Button
571-
onClick={() => {
572-
updateHTML(
573-
versionInfo.setP5SoundURL(versionInfo.lastP5SoundURL)
574-
);
575-
versionInfo.setLastP5SoundURL(undefined);
576-
}}
577-
>
581+
<span className="preference__warning">
578582
{t('Preferences.UndoSoundVersion')}
579-
</Button>
583+
</span>
580584
)}
581585
</div>
582586
</div>

client/styles/abstracts/_variables.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ $themes: (
8686
table-row-stripe-color-alternate: $medium-light,
8787
codefold-icon-open: url("../images/triangle-arrow-down.svg?byUrl"),
8888
codefold-icon-closed: url("../images/triangle-arrow-right.svg?byUrl"),
89+
preferences-warning-color: $p5js-pink,
8990

9091
table-button-color: $lightest,
9192
table-button-background-color: $middle-gray,
@@ -182,6 +183,7 @@ $themes: (
182183
table-row-stripe-color-alternate: $darker,
183184
codefold-icon-open: url("../images/triangle-arrow-down-white.svg?byUrl"),
184185
codefold-icon-closed: url("../images/triangle-arrow-right-white.svg?byUrl"),
186+
preferences-warning-color: $yellow,
185187

186188
table-button-color: $lightest,
187189
table-button-background-color: $middle-gray,
@@ -276,6 +278,7 @@ $themes: (
276278
table-row-stripe-color-alternate: $darker,
277279
codefold-icon-open: url("../images/triangle-arrow-down-white.svg?byUrl"),
278280
codefold-icon-closed: url("../images/triangle-arrow-right-white.svg?byUrl"),
281+
preferences-warning-color: $yellow,
279282

280283
table-button-color: $dark,
281284
table-button-background-color: $middle-gray,

client/styles/components/_preferences.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@
137137
}
138138
}
139139

140+
.preference__warning {
141+
@include themify() {
142+
font-weight: bold;
143+
color: getThemifyVariable("preferences-warning-color");
144+
}
145+
}
146+
140147
.preference__radio-button {
141148
@extend %hidden-element;
142149
}

translations/locales/en-US/translations.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
"SoundAddon": "p5.sound.js Addon",
221221
"PreloadAddon": "p5.js 2.0 Addon - Preload",
222222
"ShapesAddon": "p5.js 2.0 Addon - Shapes",
223-
"UndoSoundVersion": "Put back previous p5.sound.js version"
223+
"UndoSoundVersion": "Want to use p5.sound.js again? Turning it back on will restore the version you were using before."
224224
},
225225
"KeyboardShortcuts": {
226226
"Title": " Keyboard Shortcuts",

0 commit comments

Comments
 (0)