Skip to content

Commit 5042faa

Browse files
committed
Add info for custom versions
1 parent cf963b7 commit 5042faa

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
setLinewrap,
2020
setPreferencesTab
2121
} from '../../actions/preferences';
22+
import { useP5Version } from '../../hooks/useP5Version';
23+
import VersionPicker from '../VersionPicker';
2224

2325
export default function Preferences() {
2426
const { t } = useTranslation();
@@ -40,6 +42,7 @@ export default function Preferences() {
4042
} = useSelector((state) => state.preferences);
4143

4244
const [state, setState] = useState({ fontSize });
45+
const { versionInfo } = useP5Version();
4346

4447
function onFontInputChange(event) {
4548
const INTEGER_REGEX = /^[0-9\b]+$/;
@@ -466,7 +469,47 @@ export default function Preferences() {
466469
</div>
467470
</div>
468471
</TabPanel>
469-
<TabPanel>TODO</TabPanel>
472+
<TabPanel>
473+
<div className="preference">
474+
<h4 className="preference__title">
475+
{t('Preferences.LibraryVersion')}
476+
</h4>
477+
<div className="preference__options">
478+
<VersionPicker />
479+
</div>
480+
<div className="preference__subtitle">
481+
{versionInfo ? (
482+
<p className="preference__paragraph">
483+
{t('Preferences.LibraryVersionInfo')}
484+
</p>
485+
) : (
486+
<>
487+
<p className="preference__paragraph">
488+
{t('Preferences.CustomVersionInfo')}
489+
</p>
490+
<p className="preference__paragraph">
491+
{t('Preferences.CustomVersionReset')}
492+
</p>
493+
<textarea className="preference__textarea">
494+
{'<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.js"></script>\n' +
495+
'<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/addons/p5.sound.min.js"></script>'}
496+
</textarea>
497+
</>
498+
)}
499+
</div>
500+
</div>
501+
{versionInfo ? (
502+
<>
503+
<p>Test</p>
504+
<p>Test</p>
505+
</>
506+
) : (
507+
<>
508+
<p>Test</p>
509+
<p>Test</p>
510+
</>
511+
)}
512+
</TabPanel>
470513
</Tabs>
471514
</section>
472515
);

client/modules/IDE/components/VersionPicker.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useCallback } from 'react';
22
import { useDispatch } from 'react-redux';
3+
import { useTranslation } from 'react-i18next';
34

45
import { useP5Version, p5Versions } from '../hooks/useP5Version';
56
import MenuItem from '../../../components/Dropdown/MenuItem';
@@ -8,6 +9,7 @@ import { updateFileContent } from '../actions/files';
89

910
const VersionPicker = () => {
1011
const { indexID, versionInfo } = useP5Version();
12+
const { t } = useTranslation();
1113
const dispatch = useDispatch();
1214
const dispatchReplaceVersion = useCallback(
1315
(version) => {
@@ -18,11 +20,18 @@ const VersionPicker = () => {
1820
);
1921

2022
if (!versionInfo) {
21-
return <p>Custom</p>;
23+
return (
24+
<button disabled className="versionPicker">
25+
{t('Toolbar.CustomLibraryVersion')}
26+
</button>
27+
);
2228
}
2329

2430
return (
25-
<DropdownMenu anchor={<span>{versionInfo.version}</span>} align="left">
31+
<DropdownMenu
32+
anchor={<button className="versionPicker">{versionInfo.version}</button>}
33+
align="left"
34+
>
2635
{p5Versions.map((version) => (
2736
<MenuItem key={version} onClick={() => dispatchReplaceVersion(version)}>
2837
{version}

client/styles/components/_preferences.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@
6767
margin-top: 0;
6868
}
6969

70+
.preference__paragraph {
71+
margin-bottom: #{math.div(10, $base-font-size)}rem;
72+
}
73+
74+
.preference__textarea {
75+
width: 100%;
76+
min-height: 8em;
77+
}
78+
7079
.preference__value {
7180
@include themify() {
7281
border: #{math.div(1, $base-font-size)}rem solid

translations/locales/en-US/translations.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@
212212
"PlainText": "Plain-text",
213213
"TextOutputARIA": "text output on",
214214
"TableText": "Table-text",
215-
"TableOutputARIA": "table output on"
215+
"TableOutputARIA": "table output on",
216+
"LibraryVersion": "p5.js Version",
217+
"LibraryVersionInfo": "TODO Add helpful info about the new p5.js version, compatibility, etc.",
218+
"CustomVersionInfo": "It looks like you've changed the <script> tag to manage the version yourself. In that case, the version can't be managed from this tab, only from the code in index.html.",
219+
"CustomVersionReset": "If you do want to use the default libraries, you can replace your script tags in index.html to the following:"
216220
},
217221
"KeyboardShortcuts": {
218222
"Title": " Keyboard Shortcuts",

0 commit comments

Comments
 (0)