[PCCompat > Components > Settings] Rewrite to use separate files for each component

This commit is contained in:
Ducko 2021-04-22 21:17:01 +01:00 committed by Lexi Sother
parent 0a8d8f09c8
commit ddddc6015b
No known key found for this signature in database
GPG key ID: 355968D14144B739
5 changed files with 43 additions and 41 deletions

View file

@ -0,0 +1,12 @@
const { React } = goosemodScope.webpackModules.common;
const FormDivider = goosemodScope.webpackModules.findByDisplayName('FormDivider');
const SettingsFormClasses = goosemodScope.webpackModules.findByProps('dividerDefault', 'titleDefault');
export default class Divider extends React.PureComponent {
render() {
return React.createElement(FormDivider, {
className: SettingsFormClasses.dividerDefault
});
}
}

View file

@ -1,7 +1,5 @@
const { React } = goosemodScope.webpackModules.common;
const OriginalTextInput = goosemodScope.webpackModules.findByDisplayName('TextInput');
const OriginalFormItem = goosemodScope.webpackModules.findByDisplayName('FormItem');
const OriginalFormText = goosemodScope.webpackModules.findByDisplayName('FormText');
@ -9,18 +7,7 @@ const Flex = goosemodScope.webpackModules.findByDisplayName('Flex');
const Margins = goosemodScope.webpackModules.findByProps('marginTop20', 'marginBottom20');
const FormClasses = goosemodScope.webpackModules.findByProps('formText', 'description');
const FormDivider = goosemodScope.webpackModules.findByDisplayName('FormDivider');
const SettingsFormClasses = goosemodScope.webpackModules.findByProps('dividerDefault', 'titleDefault');
class Divider extends React.PureComponent {
render() {
return React.createElement(FormDivider, {
className: SettingsFormClasses.dividerDefault
});
}
}
class FormItem extends React.PureComponent {
export default class FormItem extends React.PureComponent {
render() {
return React.createElement(OriginalFormItem, {
title: this.props.title,
@ -38,28 +25,3 @@ class FormItem extends React.PureComponent {
);
}
}
class TextInput extends React.PureComponent {
render() {
const title = this.props.children;
delete this.props.children;
return React.createElement(FormItem, {
title,
note: this.props.note,
required: this.props.required,
noteHasMargin: true
},
React.createElement(OriginalTextInput, {
...this.props
})
);
}
}
module.exports = {
FormItem,
TextInput
};

View file

@ -0,0 +1,3 @@
export { default as FormItem } from './formItem';
export { default as TextInput } from './textInput';
export { default as Divider } from './divider';

View file

@ -0,0 +1,25 @@
const { React } = goosemodScope.webpackModules.common;
import FormItem from './formItem';
const OriginalTextInput = goosemodScope.webpackModules.findByDisplayName('TextInput');
export default class TextInput extends React.PureComponent {
render() {
const title = this.props.children;
delete this.props.children;
return React.createElement(FormItem, {
title,
note: this.props.note,
required: this.props.required,
noteHasMargin: true
},
React.createElement(OriginalTextInput, {
...this.props
})
);
}
}

View file

@ -33,7 +33,7 @@
"powercord/injector": "./moduleWrappers/powercord/injector.js",
"powercord/webpack": "./moduleWrappers/powercord/webpack.js",
"powercord/util": "./moduleWrappers/powercord/util.js",
"powercord/components/settings": "./moduleWrappers/powercord/components/settings.js",
"powercord/components/settings": "./moduleWrappers/powercord/components/settings/index.js",
"_powercord/global": "./moduleWrappers/powercord/global/index.js"
},