Skip to content

Commit f3a4552

Browse files
committed
Merge branch 'develop' of https://github.com/PenguinMod/penguinmod.github.io into develop
2 parents 2ceb180 + ead06cc commit f3a4552

File tree

10 files changed

+286
-112
lines changed

10 files changed

+286
-112
lines changed

src/addons/addons/drag-drop/userscript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export default async function ({ addon, console }) {
6262
(el = e.target.closest('div[class*="selector_wrapper"]'))
6363
) {
6464
callback = (files) => {
65-
const hdFilter = addon.settings.get("use-hd-upload") ? "" : ":not(.sa-better-img-uploads-input)";
65+
// do not use HD uploads if we drop a GIF, Scratch will split its frames individualy.
66+
const hasGif = [...files].some(f => f.type === "image/gif");
67+
const hdFilter = !hasGif && addon.settings.get("use-hd-upload") ? "" : ":not(.sa-better-img-uploads-input)";
6668
const fileInput = el.querySelector('input[class*="action-menu_file-input"]' + hdFilter);
6769
fileInput.files = files;
6870
fileInput.dispatchEvent(new Event("change", { bubbles: true }));

src/components/box/box.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ Box.propTypes = {
9999
/**
100100
* A callback function whose first parameter is the underlying dom elements.
101101
* This call back will be executed immediately after the component is mounted or unmounted
102+
* Can also be a ref of Element
102103
*/
103-
componentRef: PropTypes.func,
104+
componentRef: PropTypes.oneOfType([
105+
PropTypes.func,
106+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
107+
]),
104108
/** https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction */
105109
direction: PropTypes.oneOf([
106110
'row', 'row-reverse', 'column', 'column-reverse'

src/components/modal/modal.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import styles from './modal.css';
1616
const ModalComponent = props => (
1717
<ReactModal
1818
isOpen
19+
ref={props.componentRef}
1920
className={classNames(styles.modalContent, props.className, {
2021
[styles.fullScreen]: props.fullScreen
2122
})}
@@ -24,10 +25,12 @@ const ModalComponent = props => (
2425
[styles.scrollable]: props.scrollable
2526
})}
2627
onRequestClose={props.onRequestClose}
28+
style={{ content: props.styleContent, overlay: props.styleOverlay }}
2729
>
2830
<Box
2931
dir={props.isRtl ? 'rtl' : 'ltr'}
3032
direction="column"
33+
componentRef={props.boxRef}
3134
grow={1}
3235
>
3336
<div className={classNames(styles.header, props.headerClassName)}>
@@ -98,6 +101,16 @@ const ModalComponent = props => (
98101

99102
ModalComponent.propTypes = {
100103
children: PropTypes.node,
104+
componentRef: PropTypes.oneOfType([
105+
PropTypes.func,
106+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
107+
]),
108+
boxRef: PropTypes.oneOfType([
109+
PropTypes.func,
110+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
111+
]),
112+
styleContent: PropTypes.object,
113+
styleOverlay: PropTypes.object,
101114
className: PropTypes.string,
102115
contentLabel: PropTypes.oneOfType([
103116
PropTypes.string,

src/components/monitor/monitor.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import LargeMonitor from './large-monitor.jsx';
1111
import SliderMonitor from '../../containers/slider-monitor.jsx';
1212
import ListMonitor from '../../containers/list-monitor.jsx';
1313

14-
1514
import styles from './monitor.css';
1615

1716
const categories = {
@@ -37,7 +36,7 @@ const MonitorComponent = props => (
3736
// TW: if export is defined, we always show it, even outside of the editor
3837
disable={!props.draggable && !props.onExport}
3938
holdToDisplay={props.mode === 'slider' ? -1 : 1000}
40-
id={`monitor-${props.label}`}
39+
id={`monitor-${props.id}`}
4140
>
4241
<Draggable
4342
bounds=".monitor-overlay" // Class for monitor container
@@ -66,7 +65,7 @@ const MonitorComponent = props => (
6665
// positioning conflicts between the monitors `transform: scale` and
6766
// the context menus `position: fixed`. For more details, see
6867
// http://meyerweb.com/eric/thoughts/2011/09/12/un-fixing-fixed-elements-with-css-transforms/
69-
<ContextMenu id={`monitor-${props.label}`}>
68+
<ContextMenu id={`monitor-${props.id}`}>
7069
{props.draggable && props.onSetModeToDefault &&
7170
<MenuItem onClick={props.onSetModeToDefault}>
7271
<FormattedMessage

src/components/prompt/prompt.jsx

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Modal from '../../containers/modal.jsx';
99
import styles from './prompt.css';
1010
import { SCRATCH_MAX_CLOUD_VARIABLES } from '../../lib/tw-cloud-limits.js';
1111

12-
1312
const messages = defineMessages({
1413
forAllSpritesMessage: {
1514
defaultMessage: 'For all sprites',
@@ -40,30 +39,57 @@ const messages = defineMessages({
4039
}
4140
});
4241

42+
const customButtonStyle = (button) => {
43+
// if class is manually specified, dont try to guess the intended style
44+
if (button.class) {
45+
switch (button.class) {
46+
case "ok":
47+
return styles.okButton;
48+
case "cancel":
49+
return styles.cancelButton;
50+
default:
51+
return styles.cancelButton;
52+
}
53+
}
54+
55+
// assume intended style from role
56+
if (button.role) {
57+
switch (button.role) {
58+
case "ok":
59+
return styles.okButton;
60+
case "close":
61+
return styles.cancelButton;
62+
}
63+
}
64+
return styles.cancelButton;
65+
};
4366
const PromptComponent = props => props.isCustom ? (
4467
<Modal
4568
className={styles.modalContent}
4669
contentLabel={props.title}
4770
id="customModal"
4871
onRequestClose={props.onCancel}
72+
componentRef={props.ref}
73+
boxRef={props.boxRef}
74+
styleContent={props.styleContent}
75+
styleOverlay={props.styleOverlay}
76+
scrollable={props.config.scrollable}
4977
>
5078
<Box className={styles.body}>
51-
<Box>
52-
</Box>
53-
<Box className={styles.buttonRow}>
54-
<button
55-
className={styles.cancelButton}
56-
onClick={props.onCancel}
57-
>
58-
{props.closeTitle}
59-
</button>
60-
<button
61-
className={styles.okButton}
62-
onClick={props.onOk}
63-
>
64-
{props.enterTitle}
65-
</button>
79+
<Box componentRef={props.customRef}>
6680
</Box>
81+
{(props.customButtons && props.customButtons.length > 0 ? <Box className={styles.buttonRow}>
82+
{/* slice then reverse to avoid mutating the array. reversing cause scratch modals put OK on the right & usually you define OK button first */}
83+
{props.customButtons.slice().reverse().map(button => (
84+
<button
85+
className={customButtonStyle(button)}
86+
style={button.style}
87+
onClick={() => props.onCustomButton(button)}
88+
>
89+
{button.name}
90+
</button>
91+
))}
92+
</Box> : null)}
6793
</Box>
6894
</Modal>
6995
) : (
@@ -72,6 +98,10 @@ const PromptComponent = props => props.isCustom ? (
7298
contentLabel={props.title}
7399
id="variableModal"
74100
onRequestClose={props.onCancel}
101+
componentRef={props.componentRef}
102+
boxRef={props.boxRef}
103+
styleContent={props.styleContent}
104+
styleOverlay={props.styleOverlay}
75105
>
76106
<Box className={styles.body}>
77107
<Box className={styles.label}>
@@ -232,11 +262,26 @@ PromptComponent.propTypes = {
232262
onScopeOptionSelection: PropTypes.func,
233263
showCloudOption: PropTypes.bool,
234264
showVariableOptions: PropTypes.bool,
265+
componentRef: PropTypes.oneOfType([
266+
PropTypes.func,
267+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
268+
]),
269+
boxRef: PropTypes.oneOfType([
270+
PropTypes.func,
271+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
272+
]),
273+
styleContent: PropTypes.object,
274+
styleOverlay: PropTypes.object,
235275

236276
/* custom modals */
237277
isCustom: PropTypes.bool,
238-
enterTitle: PropTypes.string,
239-
closeTitle: PropTypes.string
278+
config: PropTypes.object,
279+
onCustomButton: PropTypes.func,
280+
customButtons: PropTypes.arrayOf(PropTypes.object),
281+
customRef: PropTypes.oneOfType([
282+
PropTypes.func,
283+
PropTypes.shape({ current: PropTypes.instanceOf(Element) })
284+
]),
240285
};
241286

242287
export default PromptComponent;

0 commit comments

Comments
 (0)