mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 17:11:17 -08:00
feat(sticker): add a direct link to room/space settings when sticker list is empty
This commit is contained in:
1 parent
4d6137b0d2
commit
9c93c151cc
4 files changed
+61
-19
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Add a direct link to room/space settings when the current sticker list is empty
|
||||
@@ -1,22 +1,47 @@
|
||||
import { Box, toRem, config, Text } from 'folds';
|
||||
import { dropzoneIcon, Sticker } from '$components/icons/phosphor';
|
||||
import {Box, config, Text, toRem} from 'folds';
|
||||
import {dropzoneIcon, Sticker} from '$components/icons/phosphor';
|
||||
import {useOpenRoomSettings} from "$state/hooks/roomSettings.ts";
|
||||
import {useOpenSpaceSettings} from "$state/hooks/spaceSettings.ts";
|
||||
import {useRoomOptionally} from "$hooks/useRoom.ts";
|
||||
import {useSpaceOptionally} from "$hooks/useSpace.ts";
|
||||
import * as css from './styles.css';
|
||||
import {RoomSettingsPage} from "$state/roomSettings.ts";
|
||||
import {SpaceSettingsPage} from "$state/spaceSettings.ts";
|
||||
|
||||
function OptionallyLinkedText(props: {text: string, isLink: boolean, onClick: () => void}) {
|
||||
return props.isLink ? (
|
||||
<Text as="span" className={css.TextLink} onClick={props.onClick} size="Inherit">{props.text}</Text>
|
||||
) : (
|
||||
<>{props.text}</>
|
||||
);
|
||||
}
|
||||
|
||||
export function NoStickerPacks() {
|
||||
return (
|
||||
<Box
|
||||
style={{ padding: `${toRem(60)} ${config.space.S500}` }}
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
direction="Column"
|
||||
gap="300"
|
||||
>
|
||||
{dropzoneIcon(Sticker)}
|
||||
<Box direction="Inherit">
|
||||
<Text align="Center">No Sticker Packs!</Text>
|
||||
<Text priority="300" align="Center" size="T200">
|
||||
Add stickers from user, room or space settings.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
const openRoomSettings = useOpenRoomSettings();
|
||||
const openSpaceSettings = useOpenSpaceSettings();
|
||||
|
||||
const room = useRoomOptionally();
|
||||
const space = useSpaceOptionally();
|
||||
|
||||
return (
|
||||
<Box
|
||||
style={{padding: `${toRem(60)} ${config.space.S500}`}}
|
||||
alignItems="Center"
|
||||
justifyContent="Center"
|
||||
direction="Column"
|
||||
gap="300"
|
||||
>
|
||||
{dropzoneIcon(Sticker)}
|
||||
<Box direction="Inherit">
|
||||
<Text align="Center">No Sticker Packs!</Text>
|
||||
<Text priority="300" align="Center" size="T200">
|
||||
Add stickers from user,{' '}
|
||||
<OptionallyLinkedText text="room" isLink={room !== null} onClick={() => openRoomSettings(room?.roomId as string, space?.roomId, RoomSettingsPage.EmojisStickersPage)} />
|
||||
{', '}or{' '}
|
||||
<OptionallyLinkedText text="space" isLink={room !== null && space !== null} onClick={() => openSpaceSettings(room?.roomId as string, space?.roomId, SpaceSettingsPage.EmojisStickersPage)} />
|
||||
{' '}settings.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -228,3 +228,11 @@ export const GifImg = style({
|
||||
objectFit: 'cover',
|
||||
borderRadius: config.radii.R400,
|
||||
});
|
||||
|
||||
export const TextLink = style({
|
||||
color: color.Secondary.Main,
|
||||
':hover': {
|
||||
textDecoration: 'underline',
|
||||
cursor: 'pointer',
|
||||
}
|
||||
});
|
||||
@@ -11,6 +11,10 @@ export function useRoom(): Room {
|
||||
return room;
|
||||
}
|
||||
|
||||
export function useRoomOptionally(): Room | null {
|
||||
return useContext(RoomContext);
|
||||
}
|
||||
|
||||
const IsDirectRoomContext = createContext(false);
|
||||
|
||||
export const IsDirectRoomProvider = IsDirectRoomContext.Provider;
|
||||
|
||||
Reference in new issue
Block a user