mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 19:55:53 +03:00
groups: show group settings menu when pressing settings cog on mobile
This commit is contained in:
parent
a15efab60c
commit
9f25f74d93
21
pkg/interface/src/logic/lib/useMedia.ts
Normal file
21
pkg/interface/src/logic/lib/useMedia.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
export const useMedia = (mediaQuery: string) => {
|
||||
const [match, setMatch] = useState(false);
|
||||
|
||||
const update = useCallback((e: MediaQueryListEvent) => {
|
||||
setMatch(e.matches);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const query = window.matchMedia(mediaQuery);
|
||||
|
||||
query.addEventListener('change', update);
|
||||
update({ matches: query.matches } as MediaQueryListEvent);
|
||||
return () => {
|
||||
query.removeEventListener('change', update);
|
||||
};
|
||||
}, [update]);
|
||||
|
||||
return match;
|
||||
};
|
@ -10,6 +10,7 @@ import { Link } from 'react-router-dom';
|
||||
import { uxToHex } from '~/logic/lib/util';
|
||||
import { getTitleFromWorkspace } from '~/logic/lib/workspace';
|
||||
import useMetadataState from '~/logic/state/metadata';
|
||||
import { useMedia } from '~/logic/lib/useMedia';
|
||||
import { Workspace } from '~/types/workspace';
|
||||
import { Dropdown } from '~/views/components/Dropdown';
|
||||
import { MetadataIcon } from './MetadataIcon';
|
||||
@ -76,6 +77,7 @@ export function GroupSwitcher(props: {
|
||||
isAdmin: any;
|
||||
}) {
|
||||
const { workspace, isAdmin } = props;
|
||||
const isMobile = useMedia('(max-width: 639px)')
|
||||
const associations = useMetadataState(state => state.associations);
|
||||
const title = getTitleFromWorkspace(associations, workspace);
|
||||
const metadata = (workspace.type === 'home' || workspace.type === 'messages')
|
||||
@ -144,14 +146,26 @@ export function GroupSwitcher(props: {
|
||||
/>
|
||||
<Text> Participants</Text>
|
||||
</GroupSwitcherItem>
|
||||
<GroupSwitcherItem to={navTo('/popover/settings')}>
|
||||
<Icon
|
||||
mr={2}
|
||||
color="gray"
|
||||
icon="Gear"
|
||||
/>
|
||||
<Text> Group Settings</Text>
|
||||
</GroupSwitcherItem>
|
||||
{isMobile ? (
|
||||
<GroupSwitcherItem to={navTo('/popover')}>
|
||||
<Icon
|
||||
mr={2}
|
||||
color="gray"
|
||||
icon="Gear"
|
||||
/>
|
||||
<Text> Group Settings</Text>
|
||||
</GroupSwitcherItem>
|
||||
|
||||
) : (
|
||||
<GroupSwitcherItem to={navTo('/popover/settings')}>
|
||||
<Icon
|
||||
mr={2}
|
||||
color="gray"
|
||||
icon="Gear"
|
||||
/>
|
||||
<Text> Group Settings</Text>
|
||||
</GroupSwitcherItem>
|
||||
)}
|
||||
{isAdmin && (<GroupSwitcherItem bottom to={navTo('/invites')}>
|
||||
<Icon
|
||||
mr={2}
|
||||
@ -181,9 +195,15 @@ export function GroupSwitcher(props: {
|
||||
ml='12px'
|
||||
/>
|
||||
</Link>)}
|
||||
<Link to={navTo('/popover/settings')}>
|
||||
<Icon color='gray' display="inline-block" ml={'12px'} icon="Gear" />
|
||||
</Link>
|
||||
{isMobile ? (
|
||||
<Link to={navTo('/popover')}>
|
||||
<Icon color='gray' display="inline-block" ml={'12px'} icon="Gear" />
|
||||
</Link>
|
||||
) : (
|
||||
<Link to={navTo('/popover/settings')}>
|
||||
<Icon color='gray' display="inline-block" ml={'12px'} icon="Gear" />
|
||||
</Link>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Row>
|
||||
|
Loading…
Reference in New Issue
Block a user