BetterDiscordApp-rauenzi/src/ui/settings/themecard.js

75 lines
3.5 KiB
JavaScript
Raw Normal View History

2019-05-31 07:53:11 +02:00
import {React, ThemeManager} from "modules";
2019-06-09 22:30:33 +02:00
// import ReloadIcon from "../icons/reload";
2019-06-09 04:24:05 +02:00
// import Toasts from "../toasts";
2019-05-28 23:27:25 +02:00
2019-05-30 07:06:17 +02:00
export default class V2C_ThemeCard extends React.Component {
2019-05-28 20:19:48 +02:00
constructor(props) {
super(props);
this.state = {
2019-06-09 04:24:05 +02:00
checked: ThemeManager.isEnabled(this.props.content.id),
2019-05-28 20:19:48 +02:00
reloads: 0
};
2019-06-09 04:24:05 +02:00
this.onChange = this.onChange.bind(this);
// this.reload = this.reload.bind(this);
2019-05-28 20:19:48 +02:00
}
2019-06-09 04:24:05 +02:00
// onReload(themeName) {
// if (themeName !== this.props.theme.name) return;
// this.setState({reloads: this.state.reloads + 1});
2019-05-28 20:19:48 +02:00
// }
2019-06-09 04:24:05 +02:00
// reload() {
// const theme = this.props.theme.name;
// const error = ThemeManager.reloadTheme(theme);
// if (error) Toasts.show(`Could not reload ${Themes[theme].name}. Check console for details.`, {type: "error"});
// else Toasts.show(`${Themes[theme].name} v${Themes[theme].version} has been reloaded.`, {type: "success"});
// // this.setState(this.state);
// this.props.theme = Themes[theme];
// this.onReload(this.props.theme.name);
2019-05-28 20:19:48 +02:00
// }
render() {
2019-06-09 04:24:05 +02:00
const {content} = this.props;
const name = content.name;
const description = content.description;
const version = content.version;
const author = content.author;
const website = content.website;
const source = content.source;
2019-05-28 20:19:48 +02:00
2019-05-30 07:06:17 +02:00
return React.createElement("li", {"data-name": name, "data-version": version, "className": "settings-closed ui-switch-item"},
React.createElement("div", {className: "bda-header"},
React.createElement("span", {className: "bda-header-title"},
React.createElement("span", {className: "bda-name"}, name),
2019-05-28 20:19:48 +02:00
" v",
2019-05-30 07:06:17 +02:00
React.createElement("span", {className: "bda-version"}, version),
2019-05-28 20:19:48 +02:00
" by ",
2019-05-30 07:06:17 +02:00
React.createElement("span", {className: "bda-author"}, author)
2019-05-28 20:19:48 +02:00
),
2019-05-30 07:06:17 +02:00
React.createElement("div", {className: "bda-controls"},
2019-06-09 04:24:05 +02:00
//!SettingsCookie["fork-ps-5"] && React.createElement(ReloadIcon, {className: "bd-reload-card", onClick: this.reload}),
2019-05-30 07:06:17 +02:00
React.createElement("label", {className: "ui-switch-wrapper ui-flex-child", style: {flex: "0 0 auto"}},
React.createElement("input", {checked: this.state.checked, onChange: this.onChange, className: "ui-switch-checkbox", type: "checkbox"}),
React.createElement("div", {className: this.state.checked ? "ui-switch checked" : "ui-switch"})
2019-05-28 20:19:48 +02:00
)
)
),
2019-05-30 07:06:17 +02:00
React.createElement("div", {className: "bda-description-wrap scroller-wrap fade"},
React.createElement("div", {className: "bda-description scroller"}, description)
2019-05-28 20:19:48 +02:00
),
2019-05-30 07:06:17 +02:00
(website || source) && React.createElement("div", {className: "bda-footer"},
React.createElement("span", {className: "bda-links"},
website && React.createElement("a", {className: "bda-link", href: website, target: "_blank"}, "Website"),
2019-05-28 20:19:48 +02:00
website && source && " | ",
2019-05-30 07:06:17 +02:00
source && React.createElement("a", {className: "bda-link", href: source, target: "_blank"}, "Source")
2019-05-28 20:19:48 +02:00
)
)
);
}
onChange() {
this.setState({checked: !this.state.checked});
2019-06-09 04:24:05 +02:00
ThemeManager.toggleTheme(this.props.content.id);
2019-05-28 20:19:48 +02:00
}
}