From caf4a07473c56dcc998be3751c4009c4c3ad2496 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sat, 27 Feb 2021 13:46:41 +0000 Subject: [PATCH] Add new modal (WIP) Currently broken: marketplace, addons, resizing the modal, gradient settings Not implemented: apply button, reset button, import/export buttons Co-authored-by: Alex Sparkes --- src/App.jsx | 2 +- src/components/modals/Main.jsx | 62 +-- src/components/modals/settings/Section.jsx | 56 --- .../modals/settings/sections/About.jsx | 41 ++ .../modals/settings/sections/Appearance.jsx | 26 ++ ...{BackgroundSettings.jsx => Background.jsx} | 8 +- .../{GreetingSettings.jsx => Greeting.jsx} | 6 +- .../{LanguageSettings.jsx => Language.jsx} | 3 +- .../modals/settings/sections/Quote.jsx | 19 + .../{SearchSettings.jsx => Search.jsx} | 6 +- .../modals/settings/sections/Time.jsx | 25 ++ src/components/modals/tabs-backend/Tab.jsx | 81 ++++ src/components/modals/tabs-backend/Tabs.jsx | 53 +++ src/components/modals/tabs/Settings.jsx | 142 ++----- src/scss/index.scss | 5 +- src/scss/modules/_modal.scss | 270 -------------- src/scss/modules/modals/_feedback.scss | 52 +++ src/scss/modules/modals/_main.scss | 352 ++++++++++++++++++ src/scss/modules/modals/_update.scss | 14 + 19 files changed, 733 insertions(+), 490 deletions(-) delete mode 100644 src/components/modals/settings/Section.jsx create mode 100644 src/components/modals/settings/sections/About.jsx create mode 100644 src/components/modals/settings/sections/Appearance.jsx rename src/components/modals/settings/sections/{BackgroundSettings.jsx => Background.jsx} (97%) rename src/components/modals/settings/sections/{GreetingSettings.jsx => Greeting.jsx} (92%) rename src/components/modals/settings/sections/{LanguageSettings.jsx => Language.jsx} (94%) create mode 100644 src/components/modals/settings/sections/Quote.jsx rename src/components/modals/settings/sections/{SearchSettings.jsx => Search.jsx} (95%) create mode 100644 src/components/modals/settings/sections/Time.jsx create mode 100644 src/components/modals/tabs-backend/Tab.jsx create mode 100644 src/components/modals/tabs-backend/Tabs.jsx delete mode 100644 src/scss/modules/_modal.scss create mode 100644 src/scss/modules/modals/_feedback.scss create mode 100644 src/scss/modules/modals/_main.scss create mode 100644 src/scss/modules/modals/_update.scss diff --git a/src/App.jsx b/src/App.jsx index 8f80bcc0..f3e3fbea 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -96,7 +96,7 @@ export default class App extends React.PureComponent { - this.setState({ mainModal: false })} isOpen={this.state.mainModal} className={modalClassList} overlayClassName={overlayClassList} ariaHideApp={false}> + this.setState({ mainModal: false })} isOpen={this.state.mainModal} className={modalClassList} overlayClassName={overlayClassList} ariaHideApp={false}>
this.setState({ mainModal: false })} /> this.setState({ updateModal: false })} isOpen={this.state.updateModal} className={modalClassList} overlayClassName={overlayClassList} ariaHideApp={false}> diff --git a/src/components/modals/Main.jsx b/src/components/modals/Main.jsx index 3237ed3a..3dd2840a 100644 --- a/src/components/modals/Main.jsx +++ b/src/components/modals/Main.jsx @@ -4,61 +4,27 @@ import Settings from './tabs/Settings'; import Addons from './tabs/Addons'; import Marketplace from './tabs/Marketplace'; -import SettingsIcon from '@material-ui/icons/Settings'; -import AddonsIcon from '@material-ui/icons/Widgets'; -import MarketplaceIcon from '@material-ui/icons/ShoppingBasket'; +import Navigation from './tabs-backend/Tabs'; export default class MainModal extends React.PureComponent { - constructor(...args) { - super(...args); - this.state = { - tab: '', - currentTab: '' - } - this.tabs = { - settings: , - addons: this.changeEnabled('marketplace')}/>, - marketplace: - } - } - - componentDidMount() { - document.getElementById('backgroundImage').classList.toggle('backgroundEffects'); - document.getElementById('center').classList.toggle('backgroundEffects'); - - this.setState({ - tab: this.tabs.settings, - currentTab: 'settings' - }); - } - - componentWillUnmount() { - document.getElementById('backgroundImage').classList.toggle('backgroundEffects'); - document.getElementById('center').classList.toggle('backgroundEffects'); - } - - changeEnabled(input) { - document.getElementById(this.state.currentTab + 'TabLink').classList.toggle('active'); - document.getElementById(input + 'TabLink').classList.toggle('active'); - - this.setState({ - tab: this.tabs[input], - currentTab: input - }); - } - render() { return ( -
+
×

{this.props.language.modals.title}

-
- - - +
+ +
+ +
+
+ +
+
+ +
+
-
- {this.state.tab}
); } diff --git a/src/components/modals/settings/Section.jsx b/src/components/modals/settings/Section.jsx deleted file mode 100644 index 574f949c..00000000 --- a/src/components/modals/settings/Section.jsx +++ /dev/null @@ -1,56 +0,0 @@ -import React from 'react'; - -import Slider from './Slider'; - -import ExpandMore from '@material-ui/icons/ExpandMore'; - -export default class Section extends React.PureComponent { - constructor(...args) { - super(...args); - this.state = { - display: 'none', - transform: 'rotate(0)' - }; - } - - toggleSection() { - const display = (this.state.display === 'none') ? 'block' : 'none'; - - this.setState({ - display: display, - transform: (this.state.transform === 'rotate(0)') ? 'rotate(-180deg)' : 'rotate(0)' - }); - - if (this.props.onToggle) { - this.props.onToggle(display); - } - } - - render() { - let extraHTML, expandMore; - - if (this.props.children) { - extraHTML = ( -
-
  • {this.props.children}
  • -
    - ); - - expandMore = ( - this.toggleSection()} /> - ); - } - - return ( -
    -

    this.toggleSection()}>{this.props.title}

    - {expandMore} - {(this.props.slider !== false) ? : null} - {extraHTML} -
    - ); - } -} \ No newline at end of file diff --git a/src/components/modals/settings/sections/About.jsx b/src/components/modals/settings/sections/About.jsx new file mode 100644 index 00000000..eb4aac39 --- /dev/null +++ b/src/components/modals/settings/sections/About.jsx @@ -0,0 +1,41 @@ +import React from 'react'; + +import Tooltip from '@material-ui/core/Tooltip'; + +export default class About extends React.PureComponent { + constructor(...args) { + super(...args); + this.state = { + contributors: [] + } + } + + async getContributors() { + const data = await (await fetch('https://api.github.com/repos/mue/mue/contributors')).json(); + + this.setState({ + contributors: data // TODO: REMOVE BOTS AND MAKE IT ACTUALLY WORK + }); + } + + componentDidMount() { + this.getContributors(); + } + + render() { + return ( +
    +

    About

    + Mue logo +

    Copyright 2018-2021 Mue Tab (BSD-3 License)

    +

    Version 5.0.0

    +

    Contributors

    + {this.state.contributors.map((item) => + + {item.login} + + )} +
    + ); + } +} \ No newline at end of file diff --git a/src/components/modals/settings/sections/Appearance.jsx b/src/components/modals/settings/sections/Appearance.jsx new file mode 100644 index 00000000..d63f975c --- /dev/null +++ b/src/components/modals/settings/sections/Appearance.jsx @@ -0,0 +1,26 @@ +import React from 'react'; +import Checkbox from '../Checkbox'; + +export default function AppearanceSettings (props) { + return ( +
    +

    Appearance

    + + + +
      +

      {props.language.custom_css} this.resetItem()}>{props.language.reset} NEW

      + +
    +

    Accessibility

    +
      +

      Zoom (100%) {props.language.reset}

      + +
    +
      +

      Toast Duration (2500 milliseconds) {props.language.reset}

      + +
    +
    + ); +} \ No newline at end of file diff --git a/src/components/modals/settings/sections/BackgroundSettings.jsx b/src/components/modals/settings/sections/Background.jsx similarity index 97% rename from src/components/modals/settings/sections/BackgroundSettings.jsx rename to src/components/modals/settings/sections/Background.jsx index 2b598a85..7e840bd2 100644 --- a/src/components/modals/settings/sections/BackgroundSettings.jsx +++ b/src/components/modals/settings/sections/Background.jsx @@ -2,7 +2,6 @@ import React from 'react'; import Checkbox from '../Checkbox'; import Dropdown from '../Dropdown'; -import Section from '../Section'; import FileUpload from '../FileUpload'; import { ColorPicker } from 'react-color-gradient-picker'; @@ -227,8 +226,8 @@ export default class BackgroundSettings extends React.PureComponent { } return ( - -
    +
    +

    Background

      @@ -266,8 +265,7 @@ export default class BackgroundSettings extends React.PureComponent { {this.state.shown && colourSettings}
    -
    -
    +
    ); } } \ No newline at end of file diff --git a/src/components/modals/settings/sections/GreetingSettings.jsx b/src/components/modals/settings/sections/Greeting.jsx similarity index 92% rename from src/components/modals/settings/sections/GreetingSettings.jsx rename to src/components/modals/settings/sections/Greeting.jsx index 04bc31d5..4b014537 100644 --- a/src/components/modals/settings/sections/GreetingSettings.jsx +++ b/src/components/modals/settings/sections/Greeting.jsx @@ -1,6 +1,5 @@ import React from 'react'; -import Section from '../Section'; import Checkbox from '../Checkbox'; import DatePicker from 'react-date-picker'; @@ -41,7 +40,8 @@ export default class GreetingSettings extends React.PureComponent { render() { return ( -
    +
    +

    Greeting

    @@ -53,7 +53,7 @@ export default class GreetingSettings extends React.PureComponent {

    {this.props.language.greeting.birthday_date}

    this.changeDate(data)} value={this.state.birthday}/> -
    +
    ); } } \ No newline at end of file diff --git a/src/components/modals/settings/sections/LanguageSettings.jsx b/src/components/modals/settings/sections/Language.jsx similarity index 94% rename from src/components/modals/settings/sections/LanguageSettings.jsx rename to src/components/modals/settings/sections/Language.jsx index ddb44e0d..15c25120 100644 --- a/src/components/modals/settings/sections/LanguageSettings.jsx +++ b/src/components/modals/settings/sections/Language.jsx @@ -5,7 +5,8 @@ const languages = require('../../../../modules/languages.json'); export default function LanguageSettings (props) { return ( -
    +
    +

    Language

    {props.language.language}

    +

    Quote

    + + + + localStorage.setItem('quotelanguage', document.getElementById('quotelanguage').value)}> + + + +
    + ); +} \ No newline at end of file diff --git a/src/components/modals/settings/sections/SearchSettings.jsx b/src/components/modals/settings/sections/Search.jsx similarity index 95% rename from src/components/modals/settings/sections/SearchSettings.jsx rename to src/components/modals/settings/sections/Search.jsx index 29a539bc..a8f418a2 100644 --- a/src/components/modals/settings/sections/SearchSettings.jsx +++ b/src/components/modals/settings/sections/Search.jsx @@ -2,7 +2,6 @@ import React from 'react'; import { toast } from 'react-toastify'; -import Section from '../Section'; import Dropdown from '../Dropdown'; import Checkbox from '../Checkbox'; @@ -57,7 +56,8 @@ export default class SearchSettings extends React.PureComponent { render() { return ( -
    +
    +

    Search

      {this.props.language.searchbar.custom} this.resetSearch()}>{this.props.language.reset}

    -
    +
    ); } } \ No newline at end of file diff --git a/src/components/modals/settings/sections/Time.jsx b/src/components/modals/settings/sections/Time.jsx new file mode 100644 index 00000000..e108416e --- /dev/null +++ b/src/components/modals/settings/sections/Time.jsx @@ -0,0 +1,25 @@ +import React from 'react'; + +import Checkbox from '../Checkbox'; +import Dropdown from '../Dropdown'; + +export default function TimeSettings (props) { + return ( +
    +

    Time

    + + + + + + +

    Date

    + + localStorage.setItem('dateFormat', document.getElementById('dateformat').value)}> + + + + +
    + ); +} \ No newline at end of file diff --git a/src/components/modals/tabs-backend/Tab.jsx b/src/components/modals/tabs-backend/Tab.jsx new file mode 100644 index 00000000..a5a8316d --- /dev/null +++ b/src/components/modals/tabs-backend/Tab.jsx @@ -0,0 +1,81 @@ +import React from 'react'; + +// navbar +import Settings from '@material-ui/icons/Settings'; +import Addons from '@material-ui/icons/Widgets'; +import Marketplace from '@material-ui/icons/ShoppingBasket'; + +// settings +import Time from '@material-ui/icons/AccessAlarm'; +import Greeting from '@material-ui/icons/EmojiPeople'; +import Quote from '@material-ui/icons/FormatQuote'; +import Background from '@material-ui/icons/Photo'; +import Search from '@material-ui/icons/Search'; +import About from '@material-ui/icons/Info'; +import Plugins from '@material-ui/icons/Widgets'; +import Added from '@material-ui/icons/AddCircle'; +import Appearance from '@material-ui/icons/FormatPaint'; +import Language from '@material-ui/icons/Translate'; +import Changelog from '@material-ui/icons/NewReleasesRounded'; + +export default class Tab extends React.PureComponent { + onClick = () => { + this.props.onClick(this.props.label); + }; + + render() { + let className = 'tab-list-item'; + if (this.props.currentTab === this.props.label) { + className += ' tab-list-active'; + } + + if (this.props.navbar === true) { + className = 'navbar-item'; + if (this.props.currentTab === this.props.label) { + className += ' navbar-item-active'; + } + } + + let icon; + let divider; + + switch (this.props.label) { + // Navbar + case 'Settings': icon = ; break; + case 'My Add-ons': icon = ; break; + case 'Marketplace': icon = ; break; + // Settings + case 'Time': icon =