Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix spacings & improvements #24

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/components/channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ export default function Channel({ channel }: Readonly<MessagesBoxProps>) {
}

useEffect(() => {
mainRef.current?.scrollIntoView({
behavior: 'smooth'
});
}, []);
setTimeout(
() =>
mainRef.current?.scrollIntoView({
behavior: 'smooth'
}),
50
);
}, [channel.id]);

return (
<Stack w='100%' h='100%' ref={mainRef} wordBreak='break-all' className='adjustScreen'>
Expand All @@ -162,9 +166,9 @@ export default function Channel({ channel }: Readonly<MessagesBoxProps>) {

return (
<>
{isHeadless ? null : <MessageGroupSpacer />}
{!isHeadless && <MessageGroupSpacer />}
{MessageElement}
{i === stateMessages.length - 1 ? <MessageGroupSpacer /> : null}
{i === stateMessages.length - 1 && <MessageGroupSpacer />}
</>
);
})}
Expand Down
39 changes: 24 additions & 15 deletions src/components/channel/ChannelTopBarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useThemeColors from '@/hooks/useThemeColors';
import { toggleChannelMembers } from '@/store/slices/collapsiblesSlice';
import { ChannelTypes } from '@/types/enums/ChannelTypes';
import type { Channel } from '@/types/interfaces/Channel';
import { Flex, Icon, IconButton, Spacer, useDisclosure } from '@chakra-ui/react';
import { Flex, Icon, IconButton, Spacer, useDisclosure } from '@chakra-ui/react';
import { useState } from 'react';
import { MdAlternateEmail, MdMenu, MdNumbers, MdPeople, MdPhone, MdSearch, MdVideocam } from 'react-icons/md';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -60,23 +60,32 @@ export default function ChannelTopBarContent({
}}
/>
)}
<Icon
color={getColorValue('textMutedColor')}
as={channel.type === ChannelTypes.Text ? MdNumbers : MdAlternateEmail}
boxSize='24px'
/>
<Flex gap={['3px', '5px', '10px']} alignItems='center' minW='0px'>
<Icon
color={getColorValue('textMutedColor')}
as={
channel.type === ChannelTypes.Text
? MdNumbers
: channel.type === ChannelTypes.Group
? MdPeople
: MdAlternateEmail
}
boxSize='24px'
/>
<OverflownText
fontSize='lg'
fontWeight='600'
_hover={{
cursor: channel.type === ChannelTypes.DirectMessage ? 'pointer' : undefined
}}
onClick={channel.type === ChannelTypes.DirectMessage ? onOpen : undefined}
>
{channel.type === ChannelTypes.DirectMessage ? recipient.username : channel.name}
</OverflownText>
</Flex>
{channel.type === ChannelTypes.DirectMessage && (
<UserProfileModal isOpen={isOpen} onClose={onClose} user={recipient} />
)}
<OverflownText
fontSize='lg'
_hover={{
cursor: channel.type === ChannelTypes.DirectMessage ? 'pointer' : undefined
}}
onClick={channel.type === ChannelTypes.DirectMessage ? onOpen : undefined}
>
{channel.type === ChannelTypes.DirectMessage ? recipient.username : channel.name}
</OverflownText>
{channel.type === ChannelTypes.DirectMessage && (
<>
<StatusIndicator status={recipient.status} size='13' positioned={false} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/channel/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export default function Message({ message, headless, onShowAuthor, ...props }: M
</Box>
)}
<Box textAlign='left'>
{headless ? null : (
{!headless && (
<Flex gap='6px' alignItems='center'>
<Text
className='text-bold'
fontWeight='600'
fontSize='md'
onClick={onShowAuthor}
_hover={{
Expand Down
82 changes: 35 additions & 47 deletions src/components/friends/FriendsTopBarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,55 @@ import OverflownText from '../misc/OverflownText';
export default function FriendsTopBarContent({
friendsFlexRef,
friendsRef
}: {
}: Readonly<{
friendsFlexRef: any;
friendsRef: any;
}) {
}>) {
const { getColorValue } = useThemeColors();
const { isMobile } = useDevice();
const [mobileShowSidebar, setMobileShowSidebar] = useState(true);

return (
<>
<Flex gap='8px' h='100%' minW='30px' maxH='100%'>
<Flex gap='8px' h='100%' minW='30px' maxH='100%' alignItems='center'>
{isMobile && (
<Center>
<IconButton
aria-label='Show menu'
bg='transparent'
size='sm'
fontSize='24px'
icon={<MdMenu />}
onClick={() => {
if (mobileShowSidebar) {
friendsFlexRef.current?.scrollIntoView({
behavior: 'smooth'
});
setMobileShowSidebar(false);
} else {
friendsRef.current?.scrollIntoView({
behavior: 'smooth'
});
setMobileShowSidebar(true);
}
}}
/>
</Center>
)}
<Center>
<Icon color={getColorValue('textMutedColor')} as={MdPeople} boxSize='24px' />
</Center>
<Center minW='0px'>
<OverflownText fontSize='lg'>Friends</OverflownText>
</Center>
<Center minW='0px'>
<OverflownText fontSize='sm' color={getColorValue('textMutedColor')}>
20
</OverflownText>
</Center>
</Flex>
<Spacer />
<Flex gap='24px'>
<Center>
<IconButton
aria-label='Search Friend'
aria-label='Show menu'
bg='transparent'
size='sm'
fontSize='24px'
icon={<MdSearch />}
icon={<MdMenu />}
onClick={() => {
if (mobileShowSidebar) {
friendsFlexRef.current?.scrollIntoView({
behavior: 'smooth'
});
setMobileShowSidebar(false);
} else {
friendsRef.current?.scrollIntoView({
behavior: 'smooth'
});
setMobileShowSidebar(true);
}
}}
/>
</Center>
<Center>
<IconButton aria-label='Add Friend' bg='transparent' size='sm' fontSize='24px' icon={<MdAdd />} />
</Center>
)}
<Flex gap='3px' alignItems='center' minW='0px'>
<Icon color={getColorValue('textMutedColor')} as={MdPeople} boxSize='24px' />

<OverflownText fontSize='lg' fontWeight='600'>
Friends
</OverflownText>
</Flex>

<OverflownText fontSize='sm' color={getColorValue('textMutedColor')}>
20
</OverflownText>
</Flex>
<Spacer />
<Flex gap={['5px', '10px', '24px']} alignItems='center'>
<IconButton aria-label='Search Friend' bg='transparent' size='sm' fontSize='24px' icon={<MdSearch />} />
<IconButton aria-label='Add Friend' bg='transparent' size='sm' fontSize='24px' icon={<MdAdd />} />
</Flex>
</>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/general/AppWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function AppWrapper({ children }: any) {
scrollSnapType='x mandatory'
scrollSnapStop='always'
scrollBehavior='smooth'
style={{ scrollbarWidth: 'none' }}
overflow='auto'
>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/GuildSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Box, Center, Flex, Icon, Stack } from '@chakra-ui/react';
import Link from 'next/link';
import { useState } from 'react';
import { MdNumbers } from 'react-icons/md';
import { useDispatch, useSelector } from 'react-redux';
import { useSelector } from 'react-redux';
import OverflownText from '../misc/OverflownText';
import ProfileBox from './ProfileBox';

Expand Down Expand Up @@ -98,7 +98,7 @@ export default function GuildSidebar({ guild }: { guild: IGuild }) {
bg={getColorValue('ternaryBackground')}
alignItems='center'
>
<OverflownText fontWeight='bold'>{guild.name}</OverflownText>
<OverflownText fontWeight='600'>{guild.name}</OverflownText>
</Flex>
<Box h='100%' w='100%' bg={getColorValue('sidebarBackground')} overflow='auto' padding='10px'>
<GuildSidebarContent guild={guild} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/UserProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function UserProfileModal({
</Center>
<Center>
<Box textAlign='left'>
<OverflownText fontSize='xl' tooltipPlacement='top' fontWeight='bold'>
<OverflownText fontSize='xl' tooltipPlacement='top' fontWeight='600'>
@{user.username}
</OverflownText>
{user.presence && (
Expand Down
4 changes: 0 additions & 4 deletions src/components/screens/GuildChannelScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ export default function GuildChannelScreen() {
return <ChannelLoadingScreen guild={undefined} />;
}

console.log(selectedState);

const channel = channels.find((channel) => channel.id === selectedState.guilds[guild.id]);

if (!channel) {
console.log('Sending to friends (no channel) GuildchannelScreen');

router.prefetch(`/guilds/${guild.id}`);
router.push(`/guilds/${guild.id}`);

Expand Down
2 changes: 0 additions & 2 deletions src/components/screens/GuildScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export default function GuildScreen() {
const guild = guildsState.guilds.find((guildState) => guildState.id === selectedState.selectedGuild);

if (!guild) {
console.log('Sending to friends (no guild) GuildScreen');

router.prefetch('/friends');
router.push('/friends');

Expand Down
2 changes: 2 additions & 0 deletions src/components/user/StatusIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default function StatusIndicator({ status, size, positioned = true, toolt
<Box
w={`${size}px`}
h={`${size}px`}
minW={`${size}px`}
minH={`${size}px`}
position='relative'
borderWidth='2px'
borderRadius='50%'
Expand Down
4 changes: 0 additions & 4 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ body {
user-select: none;
}

.text-bold {
font-weight: 600;
}


.adjustScreen {
min-width: 200px;
Expand Down