diff --git a/src/app.tsx b/src/app.tsx index 41ebdb41..b28f0b92 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -9,7 +9,6 @@ import Home from './views/home'; import NotFound from './views/not-found'; import PendingPost from './views/pending-post'; import PostPage from './views/post-page'; -import Settings from './views/settings'; import BoardBanner from './components/board-banner'; import { DesktopBoardButtons, MobileBoardButtons } from './components/board-buttons'; import BoardNav from './components/board-nav'; @@ -70,17 +69,23 @@ const App = () => { } /> }> } /> + } /> } /> + } /> } /> + } /> + } /> + } /> + } /> + } /> } /> + } /> - } /> - } /> diff --git a/src/components/board-nav/board-nav.tsx b/src/components/board-nav/board-nav.tsx index 21b75a69..08c0f252 100644 --- a/src/components/board-nav/board-nav.tsx +++ b/src/components/board-nav/board-nav.tsx @@ -12,7 +12,9 @@ interface BoardNavProps { const BoardNavDesktop = ({ subplebbitAddresses }: BoardNavProps) => { const { t } = useTranslation(); - const isInCatalogView = isCatalogView(useLocation().pathname, useParams()); + const location = useLocation(); + const params = useParams(); + const isInCatalogView = isCatalogView(location.pathname, params); return (
@@ -30,7 +32,8 @@ const BoardNavDesktop = ({ subplebbitAddresses }: BoardNavProps) => { ] - [{t('settings')}] [{t('home')}] + [{t('settings')}] [{t('home')} + ]
); @@ -68,7 +71,7 @@ const BoardNavMobile = ({ subplebbitAddresses, subplebbitAddress }: BoardNavProp {boardSelect}
- {t('settings')} + {t('settings')} {t('home')}
diff --git a/src/components/settings-modal/index.ts b/src/components/settings-modal/index.ts new file mode 100644 index 00000000..aef1be49 --- /dev/null +++ b/src/components/settings-modal/index.ts @@ -0,0 +1 @@ +export { default } from './settings-modal'; diff --git a/src/components/settings-modal/settings-modal.module.css b/src/components/settings-modal/settings-modal.module.css new file mode 100644 index 00000000..97815432 --- /dev/null +++ b/src/components/settings-modal/settings-modal.module.css @@ -0,0 +1,50 @@ +.settingsModal { + top: 60px; + width: 400px; + height: auto; + max-height: 80%; + left: calc(50% - 25px); + overflow-y: auto; + margin-left: -178px; + position: absolute; + padding: 2px 5px 5px; + font-size: 14px; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.25); +} + +.header { + font-size: 16px; + font-weight: 700; + margin-bottom: 5px; + margin-top: 5px; + padding-bottom: 5px; + text-align: center; + line-height: 14px; +} + +.version { + font-size: 11px; + position: absolute; + display: block; + margin-left: 5px; +} + +.closeButton { + right: 5px; + width: 18px; + height: 18px; + display: block; + background-size: 100%; + cursor: pointer; + position: absolute; + top: 5px; + image-rendering: pixelated; +} + +@media (max-width: 640px) { + .settingsModal { + width: 350px !important; + max-height: 60% !important; + left: calc(50% - 2px) !important; + } +} \ No newline at end of file diff --git a/src/components/settings-modal/settings-modal.tsx b/src/components/settings-modal/settings-modal.tsx new file mode 100644 index 00000000..6694996a --- /dev/null +++ b/src/components/settings-modal/settings-modal.tsx @@ -0,0 +1,18 @@ +import styles from './settings-modal.module.css'; +import { useNavigate } from 'react-router-dom'; + +const SettingsModal = () => { + const navigate = useNavigate(); + + return ( +
+
+ v0.2.0 + Settings + navigate(-1)} /> +
+
+ ); +}; + +export default SettingsModal; diff --git a/src/hooks/use-reply-modal.ts b/src/hooks/use-reply-modal.ts index 11fc3045..acb4a8df 100644 --- a/src/hooks/use-reply-modal.ts +++ b/src/hooks/use-reply-modal.ts @@ -27,7 +27,7 @@ const useReplyModal = () => { setShowReplyModal(true); } }, - [activeCid, closeModal, isMobile], + [activeCid, isMobile], ); return { activeCid, closeModal, openReplyModal, scrollY, showReplyModal }; diff --git a/src/views/board/board.tsx b/src/views/board/board.tsx index 8477d7a3..3571bf8e 100644 --- a/src/views/board/board.tsx +++ b/src/views/board/board.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useRef } from 'react'; -import { useParams } from 'react-router-dom'; +import { useLocation, useParams } from 'react-router-dom'; import { useFeed, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso'; import { useTranslation } from 'react-i18next'; @@ -9,6 +9,7 @@ import useReplyModal from '../../hooks/use-reply-modal'; import LoadingEllipsis from '../../components/loading-ellipsis'; import Post from '../../components/post'; import ReplyModal from '../../components/reply-modal'; +import SettingsModal from '../../components/settings-modal'; import SubplebbitDescription from '../../components/subplebbit-description'; import SubplebbitRules from '../../components/subplebbit-rules'; @@ -16,6 +17,7 @@ const lastVirtuosoStates: { [key: string]: StateSnapshot } = {}; const Board = () => { const { t } = useTranslation(); + const location = useLocation(); const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>(); const subplebbitAddresses = useMemo(() => [subplebbitAddress], [subplebbitAddress]) as string[]; const sortType = 'active'; @@ -62,6 +64,7 @@ const Board = () => { return (
+ {location.pathname === `/p/${subplebbitAddress}/settings` && } {showReplyModal && activeCid && } {feed.length > 0 && ( <> diff --git a/src/views/catalog/catalog.tsx b/src/views/catalog/catalog.tsx index 9c4b8c58..1d60d82e 100644 --- a/src/views/catalog/catalog.tsx +++ b/src/views/catalog/catalog.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useRef } from 'react'; -import { useParams } from 'react-router-dom'; +import { useLocation, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Subplebbit, useFeed, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso'; @@ -7,6 +7,7 @@ import useFeedStateString from '../../hooks/use-feed-state-string'; import useWindowWidth from '../../hooks/use-window-width'; import CatalogRow from '../../components/catalog-row'; import LoadingEllipsis from '../../components/loading-ellipsis'; +import SettingsModal from '../../components/settings-modal'; import styles from './catalog.module.css'; import _ from 'lodash'; @@ -69,6 +70,7 @@ const columnWidth = 180; const Catalog = () => { const { t } = useTranslation(); + const location = useLocation(); const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>(); const subplebbitAddresses = useMemo(() => [subplebbitAddress], [subplebbitAddress]) as string[]; @@ -122,6 +124,7 @@ const Catalog = () => { return (
+ {location.pathname === `/p/${subplebbitAddress}/catalog/settings` && }
{ const { t } = useTranslation(); const params = useParams(); + const location = useLocation(); const { commentCid, subplebbitAddress } = params; + const showSettings = + location.pathname === `/p/${subplebbitAddress}/c/${commentCid}/settings` || + location.pathname === `/p/${subplebbitAddress}/description/settings` || + location.pathname === `/p/${subplebbitAddress}/rules/settings`; + const isInDescriptionView = isDescriptionView(location.pathname, params); + const isInRulesView = isRulesView(location.pathname, params); const subplebbit = useSubplebbit({ subplebbitAddress }); const { createdAt, description, rules, shortAddress, suggested, title } = subplebbit; - const location = useLocation(); - const isInDescriptionView = isDescriptionView(location.pathname, params); - const isInRulesView = isRulesView(location.pathname, params); - const { activeCid, closeModal, openReplyModal, showReplyModal, scrollY } = useReplyModal(); const post = useComment({ commentCid }); @@ -34,6 +38,7 @@ const PostPage = () => { return (
+ {showSettings && } {showReplyModal && activeCid && } {isInDescriptionView ? ( { - const [theme, setTheme] = useTheme(); - - return ( - - ); -}; - -// prettier-ignore -const availableLanguages = ['ar', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fil', 'fr', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'mr', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sq', 'sv', 'te', 'th', 'tr', 'uk', 'ur', 'vi', 'zh']; - -const LanguageSettings = () => { - const { i18n } = useTranslation(); - const { changeLanguage, language } = i18n; - - const onSelectLanguage = (e: React.ChangeEvent) => { - changeLanguage(e.target.value); - }; - - return ( -
- -
- ); -}; - -const Settings = () => { - return ( -
-
- - v{packageJson.version} - - {isElectron && ( - - node stats - - )} - {commitRef && ( - - {commitRef.slice(0, 7)} - - )} -
-
- Home -
- - -
- ); -}; - -export default Settings;