Add tabs between home feed and local

This commit is contained in:
Alex Gleason 2025-01-24 23:39:52 -06:00
parent f56dabe458
commit aaa0d4c4f4
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 19 additions and 8 deletions

View File

@ -87,7 +87,7 @@ const ScrollTopButton: React.FC<IScrollTopButton> = ({
} }
return ( return (
<div className='fixed left-1/2 top-20 z-50 -translate-x-1/2'> <div className='fixed left-1/2 top-28 z-50 -translate-x-1/2'>
<button <button
className='flex cursor-pointer items-center space-x-1.5 whitespace-nowrap rounded-full bg-primary-600 px-4 py-2 text-white transition-transform hover:scale-105 hover:bg-primary-700 active:scale-100' className='flex cursor-pointer items-center space-x-1.5 whitespace-nowrap rounded-full bg-primary-600 px-4 py-2 text-white transition-transform hover:scale-105 hover:bg-primary-700 active:scale-100'
onClick={handleClick} onClick={handleClick}

View File

@ -37,7 +37,7 @@ const CommunityTimeline = () => {
}, [onlyMedia]); }, [onlyMedia]);
return ( return (
<Column label={instance.domain} slim> <Column label={instance.domain} slim withHeader={false}>
<PullToRefresh onRefresh={handleRefresh}> <PullToRefresh onRefresh={handleRefresh}>
<Timeline <Timeline
className='black:p-4 black:sm:p-5' className='black:p-4 black:sm:p-5'

View File

@ -399,9 +399,7 @@ const Thread = (props: IThread) => {
</div> </div>
</HotKeys> </HotKeys>
{hasDescendants && ( <hr className='-mx-4 mt-2 max-w-[100vw] border-t-2 black:border-t dark:border-gray-800' />
<hr className='-mx-4 mt-2 max-w-[100vw] border-t-2 black:border-t dark:border-gray-800' />
)}
</div> </div>
); );

View File

@ -1,13 +1,14 @@
import clsx from 'clsx'; import clsx from 'clsx';
import { useRef } from 'react'; import { useRef } from 'react';
import { useIntl } from 'react-intl'; import { FormattedMessage, useIntl } from 'react-intl';
import { Link } from 'react-router-dom'; import { Link, useLocation } from 'react-router-dom';
import { uploadCompose } from 'soapbox/actions/compose.ts'; import { uploadCompose } from 'soapbox/actions/compose.ts';
import Avatar from 'soapbox/components/ui/avatar.tsx'; import Avatar from 'soapbox/components/ui/avatar.tsx';
import { Card, CardBody } from 'soapbox/components/ui/card.tsx'; import { Card, CardBody } from 'soapbox/components/ui/card.tsx';
import HStack from 'soapbox/components/ui/hstack.tsx'; import HStack from 'soapbox/components/ui/hstack.tsx';
import Layout from 'soapbox/components/ui/layout.tsx'; import Layout from 'soapbox/components/ui/layout.tsx';
import Tabs from 'soapbox/components/ui/tabs.tsx';
import LinkFooter from 'soapbox/features/ui/components/link-footer.tsx'; import LinkFooter from 'soapbox/features/ui/components/link-footer.tsx';
import { import {
WhoToFollowPanel, WhoToFollowPanel,
@ -24,11 +25,11 @@ import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts'; import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts';
import { useDraggedFiles } from 'soapbox/hooks/useDraggedFiles.ts'; import { useDraggedFiles } from 'soapbox/hooks/useDraggedFiles.ts';
import { useFeatures } from 'soapbox/hooks/useFeatures.ts'; import { useFeatures } from 'soapbox/hooks/useFeatures.ts';
import { useInstance } from 'soapbox/hooks/useInstance.ts';
import { useIsMobile } from 'soapbox/hooks/useIsMobile.ts'; import { useIsMobile } from 'soapbox/hooks/useIsMobile.ts';
import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts'; import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts';
import { useSoapboxConfig } from 'soapbox/hooks/useSoapboxConfig.ts'; import { useSoapboxConfig } from 'soapbox/hooks/useSoapboxConfig.ts';
import ComposeForm from '../features/compose/components/compose-form.tsx'; import ComposeForm from '../features/compose/components/compose-form.tsx';
interface IHomePage { interface IHomePage {
@ -38,11 +39,13 @@ interface IHomePage {
const HomePage: React.FC<IHomePage> = ({ children }) => { const HomePage: React.FC<IHomePage> = ({ children }) => {
const intl = useIntl(); const intl = useIntl();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { pathname } = useLocation();
const me = useAppSelector(state => state.me); const me = useAppSelector(state => state.me);
const { account } = useOwnAccount(); const { account } = useOwnAccount();
const features = useFeatures(); const features = useFeatures();
const soapboxConfig = useSoapboxConfig(); const soapboxConfig = useSoapboxConfig();
const { instance } = useInstance();
const composeId = 'home'; const composeId = 'home';
const composeBlock = useRef<HTMLDivElement>(null); const composeBlock = useRef<HTMLDivElement>(null);
@ -90,6 +93,16 @@ const HomePage: React.FC<IHomePage> = ({ children }) => {
</Card> </Card>
)} )}
<div className='sticky top-12 z-20 bg-white/90 backdrop-blur black:bg-black/90 dark:bg-primary-900/90 lg:top-0'>
<Tabs
items={[
{ name: 'home', text: <FormattedMessage id='tabs_bar.home' defaultMessage='Home' />, to: '/' },
{ name: 'local', text: <div className='block max-w-xs truncate'>{instance.domain}</div>, to: '/timeline/local' },
]}
activeItem={pathname === '/timeline/local' ? 'local' : 'home'}
/>
</div>
{children} {children}
{!me && ( {!me && (