From bf64f56f7c83cac0844f9175e13418ed1c84b730 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Sat, 17 Aug 2024 23:50:13 +0100 Subject: [PATCH] refactor: begin redesign of tab errors --- src/components/Elements/MainModal/Main.jsx | 2 +- .../Elements/MainModal/backend/Tabs.jsx | 2 +- .../Elements/MainModal/backend/newTabs.jsx | 100 ++++++++++-------- .../Elements/MainModal/scss/index.scss | 2 - .../MainModal/scss/marketplace/_main.scss | 7 +- .../MainModal/scss/modules/_sidebar.scss | 2 +- .../Layout/Settings/Header/Header.jsx | 10 +- .../Layout/Settings/Item/SettingsItem.jsx | 12 +-- .../PreferencesWrapper/PreferencesWrapper.jsx | 18 ++-- src/features/marketplace/views/ItemPage.jsx | 4 +- .../marketplace/views/oldItemPage.jsx | 4 +- src/features/misc/modals/Modals.jsx | 2 +- src/features/misc/views/Addons.jsx | 7 +- src/features/misc/views/Marketplace.jsx | 2 +- tailwind.config.js | 5 + 15 files changed, 98 insertions(+), 81 deletions(-) diff --git a/src/components/Elements/MainModal/Main.jsx b/src/components/Elements/MainModal/Main.jsx index 0386d5c0..fe1970a7 100644 --- a/src/components/Elements/MainModal/Main.jsx +++ b/src/components/Elements/MainModal/Main.jsx @@ -69,7 +69,7 @@ const MainModalContent = ({ modalClose }) => { animate="center" exit="exit" transition={{ type: 'tween', duration: 0.8 }} - className="flex w-full min-w-full" + className="flex w-full min-w-full overflow-y-auto" > {renderTab()} diff --git a/src/components/Elements/MainModal/backend/Tabs.jsx b/src/components/Elements/MainModal/backend/Tabs.jsx index ddf8611b..4713add4 100644 --- a/src/components/Elements/MainModal/backend/Tabs.jsx +++ b/src/components/Elements/MainModal/backend/Tabs.jsx @@ -68,7 +68,7 @@ const Tabs = (props) => { {reminderInfo} )} -
+
{props.children.map((tab, index) => { if (tab.props.label !== currentTab) { return null; diff --git a/src/components/Elements/MainModal/backend/newTabs.jsx b/src/components/Elements/MainModal/backend/newTabs.jsx index 9b039975..1c9418ed 100644 --- a/src/components/Elements/MainModal/backend/newTabs.jsx +++ b/src/components/Elements/MainModal/backend/newTabs.jsx @@ -2,7 +2,7 @@ import { useState, useCallback, memo, useMemo } from 'react'; import variables from 'config/variables'; import Tab from './Tab'; import { useTab } from './TabContext'; -import { MdRefresh, MdClose } from 'react-icons/md'; +import { MdOutlineWarning, MdRefresh, MdClose } from 'react-icons/md'; const Sidebar = memo(({ sections, currentTab, setCurrentTab }) => { const { subTab, setSubTab, setSubSection } = useTab(); @@ -14,33 +14,6 @@ const Sidebar = memo(({ sections, currentTab, setCurrentTab }) => { [setSubTab, setSubSection], ); - const hideReminder = () => { - localStorage.setItem('showReminder', false); - document.querySelector('.reminder-info').style.display = 'none'; - }; - - const reminderInfo = useMemo( - () => ( -
-
- {variables.getMessage('settings:reminder.title')} - - - -
- {variables.getMessage('settings:reminder.message')} - -
- ), - [], - ); - return (
{sections.map((section, index) => ( @@ -52,28 +25,65 @@ const Sidebar = memo(({ sections, currentTab, setCurrentTab }) => { navbarTab={section.navbar || false} /> ))} - {reminderInfo}
); }); -const Content = memo(({ sections, currentTab }) => ( - <> - {sections.map( - ({ label, name, component: Component }) => - variables.getMessage(label) === currentTab && ( -
{ + const hideReminder = () => { + localStorage.setItem('showReminder', false); + document.querySelector('.reminder-info').style.display = 'none'; + }; + + const reminderInfo = useMemo( + () => ( +
+
+ + {variables.getMessage('settings:reminder.message')} +
+
+
- ), - )} - -)); + {variables.getMessage('modals.main.error_boundary.refresh')} + + +
+
+ ), + [], + ); + + return ( + <> + {sections.map( + ({ label, name, component: Component }) => + variables.getMessage(label) === currentTab && ( +
+ {reminderInfo} + +
+ ), + )} + + ); +}); const Tabs = ({ sections }) => { const { subTab, setSubTab, setSubSection } = useTab(); diff --git a/src/components/Elements/MainModal/scss/index.scss b/src/components/Elements/MainModal/scss/index.scss index dc8a78c0..0aef15e0 100644 --- a/src/components/Elements/MainModal/scss/index.scss +++ b/src/components/Elements/MainModal/scss/index.scss @@ -258,8 +258,6 @@ h5 { .reminder-info { display: flex; flex-flow: column; - position: absolute; - bottom: 0; padding: 15px; gap: 15px; diff --git a/src/components/Elements/MainModal/scss/marketplace/_main.scss b/src/components/Elements/MainModal/scss/marketplace/_main.scss index 027625d5..51b1fbd3 100644 --- a/src/components/Elements/MainModal/scss/marketplace/_main.scss +++ b/src/components/Elements/MainModal/scss/marketplace/_main.scss @@ -158,7 +158,7 @@ width: 100%; height: auto; border-radius: 12px; - box-shadow: 0 5px 25px rgba(0, 0, 0, .75); + box-shadow: 0 5px 25px rgba(0, 0, 0, 0.75); aspect-ratio: 1 / 1; object-fit: cover; } @@ -259,9 +259,9 @@ p.author { margin-top: -5px; } -#item>img, +#item > img, .updateImage, -.updateChangelog>p>img { +.updateChangelog > p > img { border-radius: 12px; height: 200px; width: auto; @@ -452,7 +452,6 @@ p.author { display: flex; align-items: center; justify-content: space-between; - margin-bottom: 15px; .tooltip { margin-right: 25px; diff --git a/src/components/Elements/MainModal/scss/modules/_sidebar.scss b/src/components/Elements/MainModal/scss/modules/_sidebar.scss index d232ba1b..aae47c6d 100644 --- a/src/components/Elements/MainModal/scss/modules/_sidebar.scss +++ b/src/components/Elements/MainModal/scss/modules/_sidebar.scss @@ -9,7 +9,7 @@ padding: 0 5px; border-radius: 12px 0 0 12px; overflow: hidden auto; - height: 67vh; + height: calc(80vh - 80px); min-width: 250px; .mainTitle { diff --git a/src/components/Layout/Settings/Header/Header.jsx b/src/components/Layout/Settings/Header/Header.jsx index 123db588..b6357449 100644 --- a/src/components/Layout/Settings/Header/Header.jsx +++ b/src/components/Layout/Settings/Header/Header.jsx @@ -1,10 +1,6 @@ import variables from 'config/variables'; import { useState, useEffect } from 'react'; -import { - MdFlag, - MdOutlineVisibilityOff, - MdOutlineVisibility, -} from 'react-icons/md'; +import { MdFlag, MdOutlineVisibilityOff, MdOutlineVisibility } from 'react-icons/md'; import EventBus from 'utils/eventbus'; import { Button } from 'components/Elements'; @@ -64,8 +60,8 @@ function Header(props) { }; return ( -
-
+
+
{props.visibilityToggle && } {props.report !== false && } {props.children} diff --git a/src/components/Layout/Settings/Item/SettingsItem.jsx b/src/components/Layout/Settings/Item/SettingsItem.jsx index 20854636..b469e35c 100644 --- a/src/components/Layout/Settings/Item/SettingsItem.jsx +++ b/src/components/Layout/Settings/Item/SettingsItem.jsx @@ -1,19 +1,19 @@ const Row = (props) => { - const classes = `${props.final ? 'settingsRow settingsNoBorder' : 'settingsRow'} ${props.inactive ? 'opacity-50 pointer-events-none transition-400 ease-in-out' : ''}`; + const classes = `${props.final ? 'border-b-0' : 'border-b border-gray-500'} ${props.inactive ? 'opacity-50 pointer-events-none transition duration-400 ease-in-out' : ''} flex items-center min-h-[100px] justify-between py-4 transition duration-400 ease-in-out`; return
{props.children}
; }; const Content = (props) => { return ( -
- {props.title} - {props.subtitle} +
+ {props.title} + {props.subtitle}
); }; const Action = (props) => { - return
{props.children}
; + return
{props.children}
; }; -export { Row, Content, Action }; \ No newline at end of file +export { Row, Content, Action }; diff --git a/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx b/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx index 74c3e2e5..e28e13e5 100644 --- a/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx +++ b/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx @@ -7,8 +7,10 @@ import values from 'utils/data/slider_values.json'; import EventBus from 'utils/eventbus'; const PreferencesWrapper = ({ children, ...props }) => { - const [shown, setShown] = useState(localStorage.getItem(props.setting) === 'true' || props.default || false); - console.log(props.default) + const [shown, setShown] = useState( + localStorage.getItem(props.setting) === 'true' || props.default || false, + ); + console.log(props.default); EventBus.on('toggle', (setting) => { if (setting === props.setting) { @@ -17,13 +19,17 @@ const PreferencesWrapper = ({ children, ...props }) => { }); return ( -
+
{props.zoomSetting && ( diff --git a/src/features/marketplace/views/ItemPage.jsx b/src/features/marketplace/views/ItemPage.jsx index 0b6fc766..32a35d4f 100644 --- a/src/features/marketplace/views/ItemPage.jsx +++ b/src/features/marketplace/views/ItemPage.jsx @@ -354,7 +354,9 @@ const ItemPage = () => { }; useEffect(() => { - document.querySelector('#modal').scrollTop = 0; + if (document.querySelector('#modal')) { + document.querySelector('#modal').scrollTop = 0; + } }); return ( diff --git a/src/features/marketplace/views/oldItemPage.jsx b/src/features/marketplace/views/oldItemPage.jsx index c9d30417..9044c1be 100644 --- a/src/features/marketplace/views/oldItemPage.jsx +++ b/src/features/marketplace/views/oldItemPage.jsx @@ -72,7 +72,9 @@ class ItemPage extends PureComponent { componentDidMount() { this.getCurator(this.props.data.author); - document.querySelector('#modal').scrollTop = 0; + if (document.querySelector('#modal')) { + document.querySelector('#modal').scrollTop = 0; + } this.setState({ button: this.props.data.local.installed ? this.buttons.uninstall : this.buttons.install, }); diff --git a/src/features/misc/modals/Modals.jsx b/src/features/misc/modals/Modals.jsx index 1813a6aa..f5b8330a 100644 --- a/src/features/misc/modals/Modals.jsx +++ b/src/features/misc/modals/Modals.jsx @@ -57,7 +57,7 @@ function Modals() { onRequestClose={() => toggleModal('main', false)} isOpen={main} id="#modal" - className="z-[100] h-[80vh] w-modal border-3 border-modal ease-in-out duration-800 transition-all backdrop-blur-3xl bg-modal-light dark:bg-modal-dark text-black dark:text-white overflow-y-auto shadow-xl rounded" + className="overflow-y-hidden z-[100] h-[80vh] w-modal border-3 border-modal ease-in-out duration-800 transition-all backdrop-blur-3xl bg-modal-light dark:bg-modal-dark text-black dark:text-white shadow-xl rounded" overlayClassName="grid place-content-center absolute top-0 left-0 h-screen w-screen" ariaHideApp={false} > diff --git a/src/features/misc/views/Addons.jsx b/src/features/misc/views/Addons.jsx index a80bfde7..2d8032f1 100644 --- a/src/features/misc/views/Addons.jsx +++ b/src/features/misc/views/Addons.jsx @@ -1,8 +1,7 @@ import variables from 'config/variables'; import { memo } from 'react'; -import Added from '../../marketplace/views/Library'; -import Create from '../../marketplace/views/Create'; +import Library from '../../marketplace/views/Library'; function Addons(props) { return ( @@ -16,8 +15,8 @@ function Addons(props) { */ }, ( -
- +
+
) ); diff --git a/src/features/misc/views/Marketplace.jsx b/src/features/misc/views/Marketplace.jsx index 44014082..829061ab 100644 --- a/src/features/misc/views/Marketplace.jsx +++ b/src/features/misc/views/Marketplace.jsx @@ -54,7 +54,7 @@ function Marketplace() { return (