From d21df83278515531f81155b32b6358f402a2a2bf Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Mon, 25 Jul 2022 23:06:07 +0100 Subject: [PATCH] feat: redo of message UI & widget order experiment --- .../main/scss/modules/_tab-content.scss | 42 ++++++ .../scss/settings/modules/tabs/_order.scss | 25 ++++ .../modals/main/settings/sections/Message.jsx | 55 +++++++- .../main/settings/sections/Overview.jsx | 128 ++++++++++++++++++ src/components/modals/main/tabs/Settings.jsx | 8 +- .../modals/main/tabs/backend/Tab.jsx | 10 +- 6 files changed, 260 insertions(+), 8 deletions(-) create mode 100644 src/components/modals/main/settings/sections/Overview.jsx diff --git a/src/components/modals/main/scss/modules/_tab-content.scss b/src/components/modals/main/scss/modules/_tab-content.scss index 25a142b2..5918e9ee 100644 --- a/src/components/modals/main/scss/modules/_tab-content.scss +++ b/src/components/modals/main/scss/modules/_tab-content.scss @@ -108,3 +108,45 @@ table { font-size: 1.5rem !important; } } + +.messageMap { + display: flex; + flex-flow: row; + align-items: center; + gap: 25px; + padding: 25px; + justify-content: space-between; + div:nth-child(1) { + display: flex; + flex-flow: row; + gap: 25px; + align-items: center; + } + .icon { + border-radius: 100%; + display: grid; + place-items: center; + padding: 15px; + font-size: 25px; + @include themed() { + background: t($modal-sidebarActive); + } + } + .messageText { + display: flex; + flex-flow: column; + } + .messageAction { + float: right; + } + @include themed() { + background: t($modal-sidebar); + border-radius: t($borderRadius); + } +} + +.messagesContainer { + display: flex; + flex-flow: column; + gap: 25px; +} \ No newline at end of file diff --git a/src/components/modals/main/scss/settings/modules/tabs/_order.scss b/src/components/modals/main/scss/settings/modules/tabs/_order.scss index 7a046987..cf67ebef 100644 --- a/src/components/modals/main/scss/settings/modules/tabs/_order.scss +++ b/src/components/modals/main/scss/settings/modules/tabs/_order.scss @@ -80,3 +80,28 @@ } } } + +.overviewGrid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + grid-gap: 30px; +} + +.tabPreview { + width: 100%; + aspect-ratio: 2 / 1; + display: flex; + align-items: center; + justify-content: center; + margin-top: 16px; + @include themed() { + background: t($modal-sidebar); + border-radius: t($borderRadius); + } + .previewContainer { + + } + .previewItem { + + } +} \ No newline at end of file diff --git a/src/components/modals/main/settings/sections/Message.jsx b/src/components/modals/main/settings/sections/Message.jsx index 802310c3..51b9f723 100644 --- a/src/components/modals/main/settings/sections/Message.jsx +++ b/src/components/modals/main/settings/sections/Message.jsx @@ -1,6 +1,6 @@ import variables from 'modules/variables'; import { PureComponent } from 'react'; -import { MdCancel, MdAdd } from 'react-icons/md'; +import { MdCancel, MdAdd, MdOutlineTextsms } from 'react-icons/md'; import { toast } from 'react-toastify'; import { TextareaAutosize } from '@mui/material'; import SettingsItem from '../SettingsItem'; @@ -79,7 +79,7 @@ export default class Message extends PureComponent { {this.getMessage('modals.main.settings.sections.message.add')} - + {/*
@@ -107,7 +107,56 @@ export default class Message extends PureComponent { ))}
{this.getMessage('modals.main.settings.sections.message.messages')} {this.getMessage('modals.main.settings.sections.quote.custom_buttons')}
-
+ */} +
+ {this.state.messages.map((_url, index) => ( +
+
+
+ +
+
+ + {this.getMessage('modals.main.settings.sections.message.title')} + + this.message(e, true, index)} + varient="outlined" + /> +
+
+
+
+ +
+
+
+ ))} +
+ {this.state.messages.length === 0 ? ( +
+
+ + + No messages + + + Go ahead and add some. + + +
+
+ ) : null} ); } diff --git a/src/components/modals/main/settings/sections/Overview.jsx b/src/components/modals/main/settings/sections/Overview.jsx new file mode 100644 index 00000000..02327823 --- /dev/null +++ b/src/components/modals/main/settings/sections/Overview.jsx @@ -0,0 +1,128 @@ +import variables from 'modules/variables'; +import { PureComponent } from 'react'; +import { MdOutlineDragIndicator } from 'react-icons/md'; +import { sortableContainer, sortableElement } from 'react-sortable-hoc'; +import { toast } from 'react-toastify'; +import Greeting from '../../../../widgets/greeting/Greeting'; + +import EventBus from 'modules/helpers/eventbus'; + +const getMessage = (text) => variables.language.getMessage(variables.languagecode, text); +const widget_name = { + greeting: getMessage('modals.main.settings.sections.greeting.title'), + time: getMessage('modals.main.settings.sections.time.title'), + quicklinks: getMessage('modals.main.settings.sections.quicklinks.title'), + quote: getMessage('modals.main.settings.sections.quote.title'), + date: getMessage('modals.main.settings.sections.date.title'), + message: getMessage('modals.main.settings.sections.message.title'), + reminder: 'reminder', +}; + +const SortableItem = sortableElement(({ value }) => ( +
  • + {widget_name[value]} + +
  • +)); + +const SortableContainer = sortableContainer(({ children }) => ( + +)); + +export default class OrderSettings extends PureComponent { + constructor() { + super(); + this.state = { + items: JSON.parse(localStorage.getItem('order')), + }; + } + + arrayMove(array, oldIndex, newIndex) { + const result = Array.from(array); + const [removed] = result.splice(oldIndex, 1); + result.splice(newIndex, 0, removed); + + return result; + } + + onSortEnd = ({ oldIndex, newIndex }) => { + this.setState({ + items: this.arrayMove(this.state.items, oldIndex, newIndex), + }); + }; + + reset = () => { + localStorage.setItem( + 'order', + JSON.stringify(['greeting', 'time', 'quicklinks', 'quote', 'date', 'message', 'reminder']), + ); + + this.setState({ + items: JSON.parse(localStorage.getItem('order')), + }); + + toast(getMessage('toasts.reset')); + }; + + enabled = (setting) => { + switch (setting) { + case 'quicklinks': + return localStorage.getItem('quicklinksenabled') === 'true'; + default: + return localStorage.getItem(setting) === 'true'; + } + }; + + componentDidUpdate() { + localStorage.setItem('order', JSON.stringify(this.state.items)); + variables.stats.postEvent('setting', 'Widget order'); + EventBus.dispatch('refresh', 'widgets'); + } + + render() { + return ( + <> + + {getMessage('modals.main.marketplace.product.overview')} + + {/*{getMessage('modals.main.marketplace.product.overview')} + + {getMessage('modals.main.settings.buttons.reset')} + */} +
    +
    + Preview +
    +
    + {this.state.items.map((value, index) => { + if (!this.enabled(value)) { + return null; + } + + return
    {value}
    ; + })} +
    +
    +
    +
    + {getMessage('modals.main.settings.sections.order.title')} + + {this.state.items.map((value, index) => { + if (!this.enabled(value)) { + return null; + } + + return ; + })} + +
    +
    + + ); + } +} diff --git a/src/components/modals/main/tabs/Settings.jsx b/src/components/modals/main/tabs/Settings.jsx index f275a568..791120e5 100644 --- a/src/components/modals/main/tabs/Settings.jsx +++ b/src/components/modals/main/tabs/Settings.jsx @@ -1,6 +1,7 @@ import variables from 'modules/variables'; import Tabs from './backend/Tabs'; +import Overview from '../settings/sections/Overview'; import Navbar from '../settings/sections/Navbar'; import Greeting from '../settings/sections/Greeting'; import Time from '../settings/sections/Time'; @@ -27,6 +28,9 @@ export default function Settings(props) { return ( props.changeTab(type)} current="settings"> +
    + +
    -
    + {/*
    -
    +
    */}
    diff --git a/src/components/modals/main/tabs/backend/Tab.jsx b/src/components/modals/main/tabs/backend/Tab.jsx index 00a06346..9fb1b5b3 100644 --- a/src/components/modals/main/tabs/backend/Tab.jsx +++ b/src/components/modals/main/tabs/backend/Tab.jsx @@ -27,6 +27,7 @@ import { MdCode as Sideload, MdAddCircleOutline as Added, MdAddCircleOutline as Create, + MdViewAgenda as Overview, } from 'react-icons/md'; function Tab({ label, currentTab, onClick, navbarTab }) { @@ -46,6 +47,9 @@ function Tab({ label, currentTab, onClick, navbarTab }) { let icon, divider; switch (label) { + case getMessage('modals.main.marketplace.product.overview'): + icon = ; + break; case getMessage('modals.main.navbar.settings'): icon = ; break; @@ -59,6 +63,9 @@ function Tab({ label, currentTab, onClick, navbarTab }) { case getMessage('modals.main.settings.sections.appearance.navbar.title'): icon = ; break; + case getMessage('modals.main.settings.sections.order.title'): + icon = ; + break; case getMessage('modals.main.settings.sections.greeting.title'): icon = ; break; @@ -87,9 +94,6 @@ function Tab({ label, currentTab, onClick, navbarTab }) { icon = ; divider = true; break; - case getMessage('modals.main.settings.sections.order.title'): - icon = ; - break; case 'Reminder': icon = ; break;