diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4cd0530d..3979815b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,5 @@ Inspired features are fine. ### Bug Fixes See the note in general. - ## Final Note -Contact us before doing anything if you don't want to have to change 1000 things and/or have your pull request closed. +Contact us before doing anything if you don't want to have to change 1000 things and/or have your pull request closed. \ No newline at end of file diff --git a/package.json b/package.json index 6cdb9e5a..7f9c2d59 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,10 @@ "react-beforeunload": "^2.4.0", "react-clock": "^3.0.0", "react-color-gradient-picker": "^0.1.2", - "react-date-picker": "^8.0.5", + "react-date-picker": "^8.0.6", "react-dom": "17.0.1", "react-modal": "3.12.1", - "react-toastify": "6.2.0", - "supports-webp": "2.0.1" + "react-toastify": "6.2.0" }, "devDependencies": { "node-sass": "^4.14.1", diff --git a/public/icons/mue_verified.svg b/public/icons/mue_verified.svg deleted file mode 100644 index 3db434a7..00000000 --- a/public/icons/mue_verified.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/App.jsx b/src/App.jsx index 8e565140..3fd0423a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,15 +1,8 @@ import React from 'react'; import Background from './components/widgets/background/Background'; -import Clock from './components/widgets/time/Clock'; -import Greeting from './components/widgets/greeting/Greeting'; -import Quote from './components/widgets/quote/Quote'; -import Search from './components/widgets/search/Search'; -import Maximise from './components/widgets/background/Maximise'; -import Favourite from './components/widgets/background/Favourite'; +import Widgets from './components/widgets/Widgets'; import PhotoInformation from './components/widgets/background/PhotoInformation'; -import Date from './components/widgets/time/Date'; - import Navbar from './components/widgets/navbar/Navbar'; import SettingsFunctions from './modules/helpers/settings'; @@ -38,8 +31,10 @@ export default class App extends React.PureComponent { componentDidMount() { if (!localStorage.getItem('firstRun')) SettingsFunctions.setDefaultSettings(); if (localStorage.getItem('showWelcome') === 'true') this.setState({ welcomeModal: true }); + const css = localStorage.getItem('customcss'); if (css) document.head.insertAdjacentHTML('beforeend', ''); + if (localStorage.getItem('darkTheme') === 'true') document.getElementsByClassName('Toastify')[0].classList.add('dark'); } @@ -68,15 +63,9 @@ export default class App extends React.PureComponent {
- this.setState({ mainModal: true })} updateModalOpen={() => this.setState({ updateModal: true })} feedbackModalOpen={() => this.setState({ feedbackModal: true })} language={language} /> - - - - + - - this.setState({ mainModal: false })} isOpen={this.state.mainModal} className={modalClassList} overlayClassName={overlayClassList} ariaHideApp={false}>
this.setState({ mainModal: false })} /> diff --git a/src/components/modals/Update.jsx b/src/components/modals/Update.jsx index 5d7de5cf..c93e341e 100644 --- a/src/components/modals/Update.jsx +++ b/src/components/modals/Update.jsx @@ -6,54 +6,37 @@ export default class Update extends React.PureComponent { super(...args); this.state = { title: this.props.language.title, - date: '???', + date: null, content: this.props.language.title, - author: 'Mue', - html: this.props.language.loading + html: this.props.language.loading, + image: null }; } async getUpdate() { - const supportText = `

${this.props.language.contact_support}: https://muetab.com/contact

`; - - const removeStuff = () => { // quick code to make update modal a bit better, will replace later - document.getElementById('author').innerText = ''; - const img = document.getElementsByTagName('img')[0]; - img.parentNode.removeChild(img); - } - if (localStorage.getItem('offlineMode') === 'true') { - removeStuff(); return this.setState({ title: this.props.language.offline.title, html: this.props.language.offline.description }); } - try { // Get update log from the API - const data = await (await fetch(Constants.API_URL + '/getUpdate')).json(); - if (data.statusCode === 500) { - removeStuff(); - return this.setState({ - title: this.props.language.error.title, - html: this.props.language.error.description + supportText - }); - } - - this.setState({ - title: data.title, - date: data.published, - image: data.image, - author: data.author, - html: data.content + `

${this.props.language.read_blog}: ${data.url}

` - }); - } catch (e) { // If it fails, we send an error - removeStuff(); - this.setState({ + const data = await (await fetch(Constants.API_URL + '/getUpdate')).json(); + if (data.statusCode === 500 || data.title === null) { + const supportText = `

${this.props.language.contact_support}: https://muetab.com/contact

`; + return this.setState({ title: this.props.language.error.title, html: this.props.language.error.description + supportText }); } + + this.setState({ + title: data.title, + date: data.published, + image: data.image || null, + author: data.author, + html: data.content + }); } componentDidMount() { @@ -64,8 +47,8 @@ export default class Update extends React.PureComponent { return
×

{this.state.title}

-
By {this.state.author} • {this.state.date}
- Update +
{this.state.date}
+ {this.state.image ? Update : null}

; } diff --git a/src/components/modals/settings/sections/BackgroundSettings.jsx b/src/components/modals/settings/sections/BackgroundSettings.jsx index b48c05d6..446cf265 100644 --- a/src/components/modals/settings/sections/BackgroundSettings.jsx +++ b/src/components/modals/settings/sections/BackgroundSettings.jsx @@ -1,12 +1,15 @@ import React from 'react'; -import { toast } from 'react-toastify'; + import Checkbox from '../Checkbox'; import Dropdown from '../Dropdown'; import Section from '../Section'; import FileUpload from '../FileUpload'; + import { ColorPicker } from 'react-color-gradient-picker'; import hexToRgb from '../../../../modules/helpers/background/hexToRgb'; import rgbToHex from '../../../../modules/helpers/background/rgbToHex'; + +import { toast } from 'react-toastify'; import { Beforeunload } from 'react-beforeunload'; import 'react-color-gradient-picker/dist/index.css'; diff --git a/src/components/modals/settings/sections/CountdownSettings.jsx b/src/components/modals/settings/sections/CountdownSettings.jsx deleted file mode 100644 index e69de29b..00000000 diff --git a/src/components/widgets/Widgets.jsx b/src/components/widgets/Widgets.jsx new file mode 100644 index 00000000..b2cad9d0 --- /dev/null +++ b/src/components/widgets/Widgets.jsx @@ -0,0 +1,41 @@ +import React from 'react'; + +import Clock from './time/Clock'; +import Greeting from './greeting/Greeting'; +import Quote from './quote/Quote'; +import Search from './search/Search'; +import Maximise from './background/Maximise'; +import Favourite from './background/Favourite'; +import Date from './time/Date'; + +export default class Widgets extends React.PureComponent { + enabled(key) { + const old = localStorage.getItem(key); + let val = true; + + if (old !== null) { + if (old === 'true') val = true; + if (old === 'false') val = false; + } + + return val; + } + + // Render all the components + render() { + const { language, languagecode } = this.props; + const enabled = this.enabled; + + return ( + + {enabled('searchBar') ? : null} + {enabled('greeting') ? : null} + {enabled('clock') ? : null} + {enabled('date') ? : null} + {enabled('quote') ? : null} + {enabled('view') ? : null} + {enabled('favouriteEnabled') ? : null} + + ); + } +} diff --git a/src/components/widgets/background/Favourite.jsx b/src/components/widgets/background/Favourite.jsx index ce3794d6..fd120f11 100644 --- a/src/components/widgets/background/Favourite.jsx +++ b/src/components/widgets/background/Favourite.jsx @@ -18,13 +18,16 @@ export default class Favourite extends React.PureComponent { const url = document.getElementById('backgroundImage').style.backgroundImage.replace('url("', '').replace('")', ''); const credit = document.getElementById('credit').textContent; const location = document.getElementById('location').textContent; + localStorage.setItem('favourite', JSON.stringify({ url: url, credit: credit, location: location })); this.setState({ favourited: this.favourite()} /> }); } } componentDidMount() { - if (localStorage.getItem('favourite')) this.setState({ favourited: this.favourite()} /> }); + if (localStorage.getItem('favourite')) { + this.setState({ favourited: this.favourite()} /> }); + } } render() { diff --git a/src/components/widgets/background/Maximise.jsx b/src/components/widgets/background/Maximise.jsx index a339cbb1..301f6287 100644 --- a/src/components/widgets/background/Maximise.jsx +++ b/src/components/widgets/background/Maximise.jsx @@ -16,29 +16,29 @@ export default class View extends React.PureComponent { ); } - viewStuff() { - const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time']; // elements to hide - elements.forEach((element) => { - try { - (this.state.hidden === false) ? document.querySelector(element).style.display = 'none' : document.querySelector(element).style.display = 'block'; - } catch (e) { - return; - } - }); + viewStuff() { + const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time']; // elements to hide + elements.forEach((element) => { + try { + (this.state.hidden === false) ? document.querySelector(element).style.display = 'none' : document.querySelector(element).style.display = 'block'; + } catch (e) { + return; + } + }); + + if (this.state.hidden === false) { + this.setState({ hidden: true }); + this.setAttribute(0, 100); + } else { + this.setState({ hidden: false }); + this.setAttribute(localStorage.getItem('blur'), localStorage.getItem('brightness')); + } + } - if (this.state.hidden === false) { - this.setState({ hidden: true }); - this.setAttribute(0, 100); - } else { - this.setState({ hidden: false }); - this.setAttribute(localStorage.getItem('blur'), localStorage.getItem('brightness')); + render() { + if (localStorage.getItem('background') === 'false') return null; + return
+ this.viewStuff()} /> +
} - } - - render() { - if (localStorage.getItem('view') === 'false' || localStorage.getItem('background') === 'false') return null; - return
- this.viewStuff()} /> -
- } } \ No newline at end of file diff --git a/src/components/widgets/background/PhotoInformation.jsx b/src/components/widgets/background/PhotoInformation.jsx index f907ebf5..81c9a6b8 100644 --- a/src/components/widgets/background/PhotoInformation.jsx +++ b/src/components/widgets/background/PhotoInformation.jsx @@ -7,14 +7,11 @@ import Photographer from '@material-ui/icons/Person'; export default class PhotoInformation extends React.PureComponent { render() { - let classList = 'infoCard'; - if (this.props.className) classList = this.props.className; - return (

{this.props.language.credit}

-
+

{this.props.language.information}


diff --git a/src/components/widgets/background/scss/_photoinformation.scss b/src/components/widgets/background/scss/_photoinformation.scss index 8bba3f82..30131846 100644 --- a/src/components/widgets/background/scss/_photoinformation.scss +++ b/src/components/widgets/background/scss/_photoinformation.scss @@ -9,6 +9,7 @@ float: left; margin-right: 1rem; font-size: calc(10px + 2vmin); + cursor: pointer; } svg, @@ -72,10 +73,6 @@ } } -.photoInformationHover { - cursor: pointer; -} - .dark hr { background-color: white !important; } \ No newline at end of file diff --git a/src/components/widgets/greeting/Greeting.jsx b/src/components/widgets/greeting/Greeting.jsx index abecabc3..042d9d89 100644 --- a/src/components/widgets/greeting/Greeting.jsx +++ b/src/components/widgets/greeting/Greeting.jsx @@ -56,7 +56,6 @@ export default class Greeting extends React.PureComponent { } componentDidMount() { - if (localStorage.getItem('greeting') === 'false') return; this.getGreeting(); } diff --git a/src/components/widgets/navbar/Navbar.jsx b/src/components/widgets/navbar/Navbar.jsx index c4f06188..571ee800 100644 --- a/src/components/widgets/navbar/Navbar.jsx +++ b/src/components/widgets/navbar/Navbar.jsx @@ -1,10 +1,12 @@ import React from 'react'; + import RefreshIcon from '@material-ui/icons/RefreshRounded'; import Gear from '@material-ui/icons/SettingsRounded'; import NewReleases from '@material-ui/icons/NewReleasesRounded'; import NotesIcon from '@material-ui/icons/AssignmentRounded'; import Tooltip from '@material-ui/core/Tooltip'; import Report from '@material-ui/icons/SmsFailed'; + import * as Constants from '../../../modules/constants'; import './scss/index.scss'; @@ -20,6 +22,7 @@ export default class Navbar extends React.PureComponent { window.location.reload()} /> ); + if (localStorage.getItem('refresh') === 'false') refreshHTML = null; // toggle feedback button @@ -28,6 +31,7 @@ export default class Navbar extends React.PureComponent { ); + if (Constants.BETA_VERSION === false) feedbackHTML = null; return ( diff --git a/src/components/widgets/navbar/Notes.jsx b/src/components/widgets/navbar/Notes.jsx index e6fd5f89..71bd9c10 100644 --- a/src/components/widgets/navbar/Notes.jsx +++ b/src/components/widgets/navbar/Notes.jsx @@ -23,12 +23,15 @@ export default class Notes extends React.PureComponent { } componentDidMount() { - if (localStorage.getItem('notesPinned') === 'true') document.getElementById('noteContainer').classList.toggle('visibilityshow'); + if (localStorage.getItem('notesPinned') === 'true') { + document.getElementById('noteContainer').classList.toggle('visibilityshow'); + } } render() { let classList = 'notescontainer'; if (localStorage.getItem('darkTheme') === 'true') classList += ' dark'; + return (
diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index 6b0b15b8..e489b918 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -93,15 +93,12 @@ export default class Quote extends React.PureComponent { } componentDidMount() { - if (localStorage.getItem('quote') === 'false') return; if (localStorage.getItem('favouriteQuote')) this.setState({ favourited: this.favourite()} /> }); if (localStorage.getItem('favouriteQuoteEnabled') === 'false') this.setState({ favourited: null }); this.getQuote(); } render() { - if (localStorage.getItem('quote') === 'false') return null; - let copy = this.copyQuote()}>; if (localStorage.getItem('copyButton') === 'false') copy = null; diff --git a/src/components/widgets/search/Search.jsx b/src/components/widgets/search/Search.jsx index 9873f497..2d906966 100644 --- a/src/components/widgets/search/Search.jsx +++ b/src/components/widgets/search/Search.jsx @@ -18,13 +18,12 @@ export default class Search extends React.PureComponent { startSpeechRecognition() { const voiceSearch = new window.webkitSpeechRecognition(); voiceSearch.start(); - voiceSearch.onresult = (event) => document.getElementById('searchtext').value = event.results[0][0].transcript; - voiceSearch.onend = () => setTimeout(() => window.location.href = this.state.url + `?${this.state.query}=` + document.getElementById('searchtext').value, 1000); + const searchText = document.getElementById('searchtext'); + voiceSearch.onresult = (event) => searchText.value = event.results[0][0].transcript; + voiceSearch.onend = () => setTimeout(() => window.location.href = this.state.url + `?${this.state.query}=` + searchText.value, 1000); } render() { - if (localStorage.getItem('searchBar') === 'false') return null; - let url; let query = 'q'; @@ -52,8 +51,8 @@ export default class Search extends React.PureComponent { } return ( -