mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
feat(mobile): render global modals as full-screen pages (#1150)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description Search, create room, create space, and bug report open as full-screen pages on mobile via useOpen*Modal hooks checking useScreenSizeContext. Desktop modal flow unchanged. <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes # #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
This commit is contained in:
49 files changed
+1111
-690
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Render the global modals (search, create room, create space, bug report) as full-screen pages on mobile instead of centered modals.
|
||||
@@ -37,6 +37,7 @@
|
||||
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
|
||||
"@choochmeque/tauri-plugin-notifications-api": "0.5.0-rc.11",
|
||||
"@choochmeque/tauri-plugin-sharekit-api": "0.4.0-rc.5",
|
||||
"@fontsource-variable/nunito": "5.2.7",
|
||||
"@fontsource/space-mono": "5.2.9",
|
||||
"@noble/hashes": "^2.2.0",
|
||||
|
||||
Generated
+10
@@ -26,6 +26,9 @@ importers:
|
||||
'@choochmeque/tauri-plugin-notifications-api':
|
||||
specifier: 0.5.0-rc.11
|
||||
version: 0.5.0-rc.11
|
||||
'@choochmeque/tauri-plugin-sharekit-api':
|
||||
specifier: 0.4.0-rc.5
|
||||
version: 0.4.0-rc.5
|
||||
'@fontsource-variable/nunito':
|
||||
specifier: 5.2.7
|
||||
version: 5.2.7
|
||||
@@ -929,6 +932,9 @@ packages:
|
||||
'@choochmeque/[email protected]':
|
||||
resolution: {integrity: sha512-TSuf8HQ4Ayp9IKKB5v2yTdgKMa/I0bqbcACj0IZ46CSpzn/HKner/BKG7rM8tGOarEcyBd/VXnDhK5cJA/YMtw==}
|
||||
|
||||
'@choochmeque/[email protected]':
|
||||
resolution: {integrity: sha512-VpO3Uw5ZmPa0M0ta/oS5WyiW/jdNAPFh1zXbHA5dJtLMeA4RJqqj4vAlVMYoYRqtrE/1Op/GQ3jXvxgU4WgSVA==}
|
||||
|
||||
'@cloudflare/[email protected]':
|
||||
resolution: {integrity: sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==}
|
||||
engines: {node: '>=22.0.0'}
|
||||
@@ -6172,6 +6178,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.11.1
|
||||
|
||||
'@choochmeque/[email protected]':
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.11.1
|
||||
|
||||
'@cloudflare/[email protected]': {}
|
||||
|
||||
'@cloudflare/[email protected]([email protected])([email protected])':
|
||||
|
||||
Generated
+32
@@ -3754,9 +3754,15 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"block2",
|
||||
"libc",
|
||||
"objc2",
|
||||
"objc2-cloud-kit",
|
||||
"objc2-core-data",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-core-image",
|
||||
"objc2-core-text",
|
||||
"objc2-core-video",
|
||||
"objc2-foundation",
|
||||
"objc2-quartz-core",
|
||||
]
|
||||
@@ -3787,6 +3793,7 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
@@ -3800,6 +3807,7 @@ dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"block2",
|
||||
"dispatch2",
|
||||
"libc",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
@@ -3856,8 +3864,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
|
||||
dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
"objc2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-io-surface",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5269,6 +5279,7 @@ dependencies = [
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-process",
|
||||
"tauri-plugin-sharekit",
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-store",
|
||||
"tauri-plugin-updater",
|
||||
@@ -6548,6 +6559,27 @@ dependencies = [
|
||||
"tauri-plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-sharekit"
|
||||
version = "0.4.0-rc.5"
|
||||
source = "git+https://github.com/Choochmeque/tauri-plugin-sharekit?rev=9f2b4c5d8a4f0ab910d900ba234ed8bae0ab854b#9f2b4c5d8a4f0ab910d900ba234ed8bae0ab854b"
|
||||
dependencies = [
|
||||
"log",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"windows",
|
||||
"windows-collections",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-single-instance"
|
||||
version = "2.4.3"
|
||||
|
||||
@@ -101,6 +101,7 @@ tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugi
|
||||
"push-notifications",
|
||||
] }
|
||||
tauri-plugin-edge-to-edge = { git = "https://github.com/SableClient/tauri-plugin-edge-to-edge.git", rev = "33c6116c27be28c06df5a9d02231ecc5fdeb93c5" }
|
||||
tauri-plugin-sharekit = { git = "https://github.com/Choochmeque/tauri-plugin-sharekit", rev = "9f2b4c5d8a4f0ab910d900ba234ed8bae0ab854b" }
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies]
|
||||
objc2 = "0.6"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"core:window:allow-set-badge-count",
|
||||
"deep-link:default",
|
||||
"edge-to-edge:default",
|
||||
"notifications:default"
|
||||
"notifications:default",
|
||||
"sharekit:default"
|
||||
]
|
||||
}
|
||||
@@ -260,7 +260,9 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_dialog::init());
|
||||
|
||||
#[cfg(mobile)]
|
||||
let builder = builder.plugin(tauri_plugin_edge_to_edge::init());
|
||||
let builder = builder
|
||||
.plugin(tauri_plugin_edge_to_edge::init())
|
||||
.plugin(tauri_plugin_sharekit::init());
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
let builder = builder.plugin(tauri_plugin_android_fs::init());
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
|
||||
import { Modal500 } from './Modal500';
|
||||
|
||||
describe('Modal500', () => {
|
||||
it('does not throw when rendered without tabbable children', () => {
|
||||
expect(() =>
|
||||
render(
|
||||
<Modal500 requestClose={vi.fn<() => void>()}>
|
||||
<div>Empty modal content</div>
|
||||
</Modal500>
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<Modal500 requestClose={vi.fn<() => void>()}>
|
||||
<div>Empty modal content</div>
|
||||
</Modal500>
|
||||
</ScreenSizeProvider>
|
||||
)
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
|
||||
type Modal500Props = {
|
||||
@@ -10,6 +11,29 @@ type Modal500Props = {
|
||||
};
|
||||
export function Modal500({ requestClose, children }: Modal500Props) {
|
||||
const modalRef = useRef<HTMLDivElement | null>(null);
|
||||
const screenSize = useScreenSizeContext();
|
||||
|
||||
if (screenSize === ScreenSize.Mobile) {
|
||||
return (
|
||||
<Overlay open>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
escapeDeactivates: stopPropagation,
|
||||
onDeactivate: requestClose,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={modalRef}
|
||||
tabIndex={-1}
|
||||
style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column' }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</FocusTrap>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
|
||||
@@ -13,14 +13,15 @@ type PageRootProps = {
|
||||
rail?: ReactNode;
|
||||
bottomNav?: ReactNode;
|
||||
children: ReactNode;
|
||||
mobileDrawer?: boolean;
|
||||
};
|
||||
|
||||
export function PageRoot({ nav, rail, bottomNav, children }: PageRootProps) {
|
||||
export function PageRoot({ nav, rail, bottomNav, children, mobileDrawer = true }: PageRootProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures');
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
|
||||
if (isMobile && mobileGestures) {
|
||||
if (isMobile && mobileGestures && mobileDrawer) {
|
||||
return (
|
||||
<Box grow="Yes" className={ContainerColor({ variant: 'Background' })}>
|
||||
<MobileNavDrawer nav={nav} rail={rail} bottomNav={bottomNav}>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, IconButton, Text } from 'folds';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { ArrowLeft, composerIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageHeader } from './Page';
|
||||
import { SettingsSectionBody, SettingsSectionHeader } from './style.css';
|
||||
|
||||
type SettingsSectionPageProps = {
|
||||
title: ReactNode;
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
titleAs?: 'h1' | 'h2' | 'h3' | 'span' | 'div';
|
||||
backLabel?: string;
|
||||
actionLabel?: string;
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export function SettingsSectionPage({
|
||||
title,
|
||||
requestBack,
|
||||
requestClose,
|
||||
titleAs,
|
||||
backLabel,
|
||||
actionLabel,
|
||||
children,
|
||||
}: SettingsSectionPageProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const closeLabel = actionLabel ?? 'Close';
|
||||
const showBack = screenSize === ScreenSize.Mobile && requestBack;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader className={SettingsSectionHeader}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
{showBack && (
|
||||
<IconButton aria-label={backLabel ?? 'Back'} onClick={requestBack} variant="Surface">
|
||||
{composerIcon(ArrowLeft)}
|
||||
</IconButton>
|
||||
)}
|
||||
<Text size="H4" as={titleAs} truncate>
|
||||
{title}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton aria-label={closeLabel} onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes" className={SettingsSectionBody}>
|
||||
{children}
|
||||
</Box>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './Page';
|
||||
export * from './SettingsSectionPage';
|
||||
@@ -1,4 +1,4 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { globalStyle, style } from '@vanilla-extract/css';
|
||||
import type { RecipeVariants } from '@vanilla-extract/recipes';
|
||||
import { recipe } from '@vanilla-extract/recipes';
|
||||
import { DefaultReset, color, config, toRem } from 'folds';
|
||||
@@ -123,3 +123,21 @@ export const PageContentCenter = style([
|
||||
margin: 'auto',
|
||||
},
|
||||
]);
|
||||
|
||||
export const SettingsSectionBody = style({
|
||||
width: '100%',
|
||||
maxWidth: toRem(800),
|
||||
marginInline: 'auto',
|
||||
});
|
||||
|
||||
globalStyle(`${SettingsSectionBody} *`, {
|
||||
scrollbarWidth: 'none',
|
||||
});
|
||||
globalStyle(`${SettingsSectionBody} *::-webkit-scrollbar`, {
|
||||
display: 'none',
|
||||
});
|
||||
|
||||
export const SettingsSectionHeader = style({
|
||||
paddingLeft: config.space.S300,
|
||||
paddingRight: config.space.S200,
|
||||
});
|
||||
@@ -35,6 +35,7 @@ import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { useCloseUserRoomProfile } from '$state/hooks/userRoomProfile';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { copyToClipboard } from '$utils/dom';
|
||||
import { shareText } from '$utils/share';
|
||||
import { getExploreServerPath } from '$pages/pathUtils';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { factoryRoomIdByAtoZ } from '$utils/sort';
|
||||
@@ -300,6 +301,26 @@ export function ShareChip({
|
||||
>
|
||||
<Text size="B300">Copy User Link</Text>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
className={css.UserHeroMenuItem}
|
||||
style={heroMenuItemStyle(
|
||||
{
|
||||
backgroundColor: menuItemBg,
|
||||
color: textColor,
|
||||
},
|
||||
chipHoverBrightness
|
||||
)}
|
||||
onClick={async () => {
|
||||
const shared = await shareText(getMatrixToUser(userId));
|
||||
if (shared) setCopied();
|
||||
close();
|
||||
}}
|
||||
>
|
||||
<Text size="B300">Share User Link</Text>
|
||||
</MenuItem>
|
||||
</Box>
|
||||
</div>
|
||||
</Menu>
|
||||
|
||||
@@ -85,8 +85,7 @@ export function buildGitHubUrl(
|
||||
return `https://github.com/${GITHUB_REPO}/issues/new?${new URLSearchParams(params)}`;
|
||||
}
|
||||
|
||||
function BugReportModal() {
|
||||
const close = useCloseBugReportModal();
|
||||
export function BugReportForm({ onDone }: { onDone: () => void }) {
|
||||
const sentryEnabled = Sentry.isInitialized();
|
||||
const [type, setType] = useState<ReportType>('bug');
|
||||
const [title, setTitle] = useState('');
|
||||
@@ -219,9 +218,286 @@ function BugReportModal() {
|
||||
const url = buildGitHubUrl(type, title.trim(), fields);
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
close();
|
||||
onDone();
|
||||
};
|
||||
|
||||
return (
|
||||
<Box direction="Column" style={{ maxHeight: '90vh', overflow: 'hidden' }}>
|
||||
<Header
|
||||
size="500"
|
||||
style={{
|
||||
padding: config.space.S200,
|
||||
paddingLeft: config.space.S400,
|
||||
}}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Report an Issue</Text>
|
||||
</Box>
|
||||
<IconButton size="300" radii="300" onClick={onDone}>
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Scroll size="300" hideTrack>
|
||||
<Box
|
||||
style={{
|
||||
padding: config.space.S400,
|
||||
paddingRight: config.space.S200,
|
||||
}}
|
||||
direction="Column"
|
||||
gap="500"
|
||||
>
|
||||
{/* Type */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Type</Text>
|
||||
<Box gap="200">
|
||||
<Chip
|
||||
radii="Pill"
|
||||
variant={type === 'bug' ? 'Primary' : 'SurfaceVariant'}
|
||||
aria-pressed={type === 'bug'}
|
||||
onClick={() => setType('bug')}
|
||||
>
|
||||
<Text size="T300">Bug Report</Text>
|
||||
</Chip>
|
||||
<Chip
|
||||
radii="Pill"
|
||||
variant={type === 'feature' ? 'Primary' : 'SurfaceVariant'}
|
||||
aria-pressed={type === 'feature'}
|
||||
onClick={() => setType('feature')}
|
||||
>
|
||||
<Text size="T300">Feature Request</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Title + duplicate check */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Title *</Text>
|
||||
<Input
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
autoFocus
|
||||
placeholder="Brief description"
|
||||
value={title}
|
||||
onChange={(e) => setTitle((e.target as HTMLInputElement).value)}
|
||||
/>
|
||||
{searching && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">Searching for similar issues…</Text>
|
||||
</Box>
|
||||
)}
|
||||
{!searching && similarIssues.length > 0 && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="T200">Similar open issues — please check before submitting:</Text>
|
||||
{similarIssues.map((issue) => (
|
||||
<Text key={issue.number} size="T200">
|
||||
{'→ '}
|
||||
<a href={issue.html_url} target="_blank" rel="noopener noreferrer">
|
||||
#{issue.number}: {issue.title}
|
||||
</a>
|
||||
</Text>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Description */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
{type === 'bug' ? 'Describe the bug *' : 'Describe the problem *'}
|
||||
</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={4}
|
||||
placeholder={
|
||||
type === 'bug'
|
||||
? 'A clear description of what the bug is.'
|
||||
: 'A clear description of the problem this feature would solve.'
|
||||
}
|
||||
value={type === 'bug' ? description : problem}
|
||||
onChange={(e) =>
|
||||
type === 'bug'
|
||||
? setDescription((e.target as HTMLTextAreaElement).value)
|
||||
: setProblem((e.target as HTMLTextAreaElement).value)
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Bug: steps to reproduce */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Steps to reproduce (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={3}
|
||||
placeholder={'1. Go to…\n2. Click on…\n3. See error'}
|
||||
value={reproduction}
|
||||
onChange={(e) => setReproduction((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Bug: expected behavior */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Expected behavior (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="A clear description of what you expected to happen."
|
||||
value={expectedBehavior}
|
||||
onChange={(e) => setExpectedBehavior((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Feature: solution */}
|
||||
{type === 'feature' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Describe the solution you'd like *</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={3}
|
||||
placeholder="I would like to…"
|
||||
value={solution}
|
||||
onChange={(e) => setSolution((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Feature: alternatives */}
|
||||
{type === 'feature' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Alternatives considered (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="Any alternative solutions or features you've considered."
|
||||
value={alternatives}
|
||||
onChange={(e) => setAlternatives((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Platform info for bugs */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Platform info (auto-included)</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7, wordBreak: 'break-all' }}>
|
||||
{`Sable v${APP_VERSION}${IS_RELEASE_TAG ? '' : '-dev'} • ${navigator.userAgent}`}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Additional context — shared */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Additional context (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="Any other context or screenshots."
|
||||
value={context}
|
||||
onChange={(e) => setContext((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Sentry integration options (only for bug reports when Sentry is configured) */}
|
||||
{type === 'bug' && sentryEnabled && (
|
||||
<Box direction="Column" gap="200">
|
||||
<Text size="L400">Error Tracking</Text>
|
||||
<Box as="label" gap="200" alignItems="Center" style={{ cursor: 'pointer' }}>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={sendToSentry}
|
||||
onClick={() => setSendToSentry((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">Send anonymous report to Sentry for error tracking</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Helps developers identify and fix issues faster. No personal data is sent.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{sendToSentry && (
|
||||
<Box
|
||||
as="label"
|
||||
gap="200"
|
||||
alignItems="Center"
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
paddingLeft: config.space.S400,
|
||||
}}
|
||||
>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={includeDebugLogs}
|
||||
onClick={() => setIncludeDebugLogs((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">Include recent debug logs (last 100 entries)</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Provides additional context to help diagnose the issue. Logs are filtered for
|
||||
sensitive data.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
<Box as="label" gap="200" alignItems="Center" style={{ cursor: 'pointer' }}>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={openOnGitHub}
|
||||
onClick={() => setOpenOnGitHub((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">Also create a GitHub issue</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Opens a pre-filled GitHub issue in addition to the Sentry report.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<Box gap="300" justifyContent="End">
|
||||
<Button size="400" variant="Secondary" fill="None" radii="400" onClick={onDone}>
|
||||
<Text size="B400">Cancel</Text>
|
||||
</Button>
|
||||
<Button
|
||||
size="400"
|
||||
variant="Primary"
|
||||
radii="400"
|
||||
disabled={!canSubmit}
|
||||
onClick={handleSubmit}
|
||||
after={chipIcon(ArrowRight)}
|
||||
>
|
||||
<Text size="B400">
|
||||
{sentryEnabled && type === 'bug' ? 'Submit Report' : 'Open on GitHub'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function BugReportModal() {
|
||||
const close = useCloseBugReportModal();
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
@@ -234,283 +510,7 @@ function BugReportModal() {
|
||||
}}
|
||||
>
|
||||
<Modal size="500" flexHeight variant="Surface" style={{ maxHeight: '90vh' }}>
|
||||
<Box direction="Column" style={{ maxHeight: '90vh', overflow: 'hidden' }}>
|
||||
<Header
|
||||
size="500"
|
||||
style={{
|
||||
padding: config.space.S200,
|
||||
paddingLeft: config.space.S400,
|
||||
}}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Report an Issue</Text>
|
||||
</Box>
|
||||
<IconButton size="300" radii="300" onClick={close}>
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Scroll size="300" hideTrack>
|
||||
<Box
|
||||
style={{
|
||||
padding: config.space.S400,
|
||||
paddingRight: config.space.S200,
|
||||
}}
|
||||
direction="Column"
|
||||
gap="500"
|
||||
>
|
||||
{/* Type */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Type</Text>
|
||||
<Box gap="200">
|
||||
<Chip
|
||||
radii="Pill"
|
||||
variant={type === 'bug' ? 'Primary' : 'SurfaceVariant'}
|
||||
aria-pressed={type === 'bug'}
|
||||
onClick={() => setType('bug')}
|
||||
>
|
||||
<Text size="T300">Bug Report</Text>
|
||||
</Chip>
|
||||
<Chip
|
||||
radii="Pill"
|
||||
variant={type === 'feature' ? 'Primary' : 'SurfaceVariant'}
|
||||
aria-pressed={type === 'feature'}
|
||||
onClick={() => setType('feature')}
|
||||
>
|
||||
<Text size="T300">Feature Request</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Title + duplicate check */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Title *</Text>
|
||||
<Input
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
autoFocus
|
||||
placeholder="Brief description"
|
||||
value={title}
|
||||
onChange={(e) => setTitle((e.target as HTMLInputElement).value)}
|
||||
/>
|
||||
{searching && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">Searching for similar issues…</Text>
|
||||
</Box>
|
||||
)}
|
||||
{!searching && similarIssues.length > 0 && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="T200">
|
||||
Similar open issues — please check before submitting:
|
||||
</Text>
|
||||
{similarIssues.map((issue) => (
|
||||
<Text key={issue.number} size="T200">
|
||||
{'→ '}
|
||||
<a href={issue.html_url} target="_blank" rel="noopener noreferrer">
|
||||
#{issue.number}: {issue.title}
|
||||
</a>
|
||||
</Text>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* Description */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
{type === 'bug' ? 'Describe the bug *' : 'Describe the problem *'}
|
||||
</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={4}
|
||||
placeholder={
|
||||
type === 'bug'
|
||||
? 'A clear description of what the bug is.'
|
||||
: 'A clear description of the problem this feature would solve.'
|
||||
}
|
||||
value={type === 'bug' ? description : problem}
|
||||
onChange={(e) =>
|
||||
type === 'bug'
|
||||
? setDescription((e.target as HTMLTextAreaElement).value)
|
||||
: setProblem((e.target as HTMLTextAreaElement).value)
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Bug: steps to reproduce */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Steps to reproduce (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={3}
|
||||
placeholder={'1. Go to…\n2. Click on…\n3. See error'}
|
||||
value={reproduction}
|
||||
onChange={(e) => setReproduction((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Bug: expected behavior */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Expected behavior (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="A clear description of what you expected to happen."
|
||||
value={expectedBehavior}
|
||||
onChange={(e) =>
|
||||
setExpectedBehavior((e.target as HTMLTextAreaElement).value)
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Feature: solution */}
|
||||
{type === 'feature' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Describe the solution you'd like *</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={3}
|
||||
placeholder="I would like to…"
|
||||
value={solution}
|
||||
onChange={(e) => setSolution((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Feature: alternatives */}
|
||||
{type === 'feature' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Alternatives considered (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="Any alternative solutions or features you've considered."
|
||||
value={alternatives}
|
||||
onChange={(e) => setAlternatives((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Platform info for bugs */}
|
||||
{type === 'bug' && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Platform info (auto-included)</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7, wordBreak: 'break-all' }}>
|
||||
{`Sable v${APP_VERSION}${IS_RELEASE_TAG ? '' : '-dev'} • ${navigator.userAgent}`}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Additional context — shared */}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Additional context (optional)</Text>
|
||||
<TextArea
|
||||
size="500"
|
||||
variant="SurfaceVariant"
|
||||
radii="400"
|
||||
rows={2}
|
||||
placeholder="Any other context or screenshots."
|
||||
value={context}
|
||||
onChange={(e) => setContext((e.target as HTMLTextAreaElement).value)}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Sentry integration options (only for bug reports when Sentry is configured) */}
|
||||
{type === 'bug' && sentryEnabled && (
|
||||
<Box direction="Column" gap="200">
|
||||
<Text size="L400">Error Tracking</Text>
|
||||
<Box as="label" gap="200" alignItems="Center" style={{ cursor: 'pointer' }}>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={sendToSentry}
|
||||
onClick={() => setSendToSentry((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">
|
||||
Send anonymous report to Sentry for error tracking
|
||||
</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Helps developers identify and fix issues faster. No personal data is
|
||||
sent.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{sendToSentry && (
|
||||
<Box
|
||||
as="label"
|
||||
gap="200"
|
||||
alignItems="Center"
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
paddingLeft: config.space.S400,
|
||||
}}
|
||||
>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={includeDebugLogs}
|
||||
onClick={() => setIncludeDebugLogs((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">Include recent debug logs (last 100 entries)</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Provides additional context to help diagnose the issue. Logs are
|
||||
filtered for sensitive data.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
<Box as="label" gap="200" alignItems="Center" style={{ cursor: 'pointer' }}>
|
||||
<Checkbox
|
||||
variant="Primary"
|
||||
checked={openOnGitHub}
|
||||
onClick={() => setOpenOnGitHub((v) => !v)}
|
||||
/>
|
||||
<Box direction="Column" gap="100" grow="Yes">
|
||||
<Text size="T300">Also create a GitHub issue</Text>
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
Opens a pre-filled GitHub issue in addition to the Sentry report.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<Box gap="300" justifyContent="End">
|
||||
<Button size="400" variant="Secondary" fill="None" radii="400" onClick={close}>
|
||||
<Text size="B400">Cancel</Text>
|
||||
</Button>
|
||||
<Button
|
||||
size="400"
|
||||
variant="Primary"
|
||||
radii="400"
|
||||
disabled={!canSubmit}
|
||||
onClick={handleSubmit}
|
||||
after={chipIcon(ArrowRight)}
|
||||
>
|
||||
<Text size="B400">
|
||||
{sentryEnabled && type === 'bug' ? 'Submit Report' : 'Open on GitHub'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
<BugReportForm onDone={close} />
|
||||
</Modal>
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { BugReportModalRenderer } from './BugReportModal';
|
||||
export { BugReportModalRenderer, BugReportForm, buildGitHubUrl } from './BugReportModal';
|
||||
@@ -1,18 +1,7 @@
|
||||
import { useState, type MouseEventHandler } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Scroll,
|
||||
Button,
|
||||
config,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
type RectCords,
|
||||
} from 'folds';
|
||||
import { CaretDown, composerIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Text, Scroll, Button, config, Menu, MenuItem, PopOut, type RectCords } from 'folds';
|
||||
import { CaretDown, composerIcon } from '$components/icons/phosphor';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
@@ -98,27 +87,14 @@ export function SelectShowPerRoomRoomIcon({ roomId }: { roomId: string }) {
|
||||
}
|
||||
|
||||
type AppearanceProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function Appearance({ requestClose }: AppearanceProps) {
|
||||
export function Appearance({ requestBack, requestClose }: AppearanceProps) {
|
||||
const room = useRoom();
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Appearance
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="Appearance" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -141,6 +117,6 @@ export function Appearance({ requestClose }: AppearanceProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
Header,
|
||||
} from 'folds';
|
||||
import { composerIcon, menuIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
@@ -367,9 +367,10 @@ export function CosmeticsFont({
|
||||
}
|
||||
|
||||
type CosmeticsProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
export function Cosmetics({ requestBack, requestClose }: CosmeticsProps) {
|
||||
const mx = useMatrixClient();
|
||||
const userId = mx.getUserId()!;
|
||||
const profile = useUserProfile(userId);
|
||||
@@ -417,21 +418,7 @@ export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Cosmetics
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="Cosmetics" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -588,6 +575,6 @@ export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Box, Text, IconButton, Scroll, Switch, Button, MenuItem, config, color } from 'folds';
|
||||
import { Box, Text, Scroll, Switch, Button, MenuItem, config, color } from 'folds';
|
||||
import {
|
||||
CaretDown,
|
||||
CaretRight,
|
||||
CaretUp,
|
||||
chipIcon,
|
||||
composerIcon,
|
||||
menuIcon,
|
||||
Plus,
|
||||
X,
|
||||
} from '$components/icons/phosphor';
|
||||
import { EventType, NotificationCountType, type MatrixEvent } from '$types/matrix-sdk';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
@@ -37,9 +35,10 @@ import type { StateEventInfo } from './StateEventEditor';
|
||||
import { StateEventEditor } from './StateEventEditor';
|
||||
|
||||
type DeveloperToolsProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
export function DeveloperTools({ requestBack, requestClose }: DeveloperToolsProps) {
|
||||
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||
const mx = useMatrixClient();
|
||||
const room = useRoom();
|
||||
@@ -191,21 +190,11 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Developer Tools
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage
|
||||
title="Developer Tools"
|
||||
requestBack={requestBack}
|
||||
requestClose={requestClose}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -626,6 +615,6 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, IconButton, Scroll, Text } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Scroll } from 'folds';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import type { ImagePack } from '$plugins/custom-emoji';
|
||||
import { ImagePackView } from '$components/image-pack-view';
|
||||
import { RoomPacks } from './RoomPacks';
|
||||
|
||||
type EmojisStickersProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function EmojisStickers({ requestClose }: EmojisStickersProps) {
|
||||
export function EmojisStickers({ requestBack, requestClose }: EmojisStickersProps) {
|
||||
const [imagePack, setImagePack] = useState<ImagePack>();
|
||||
|
||||
const handleImagePackViewClose = () => {
|
||||
@@ -21,21 +21,11 @@ export function EmojisStickers({ requestClose }: EmojisStickersProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Emojis & Stickers
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage
|
||||
title="Emojis & Stickers"
|
||||
requestBack={requestBack}
|
||||
requestClose={requestClose}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -45,6 +35,6 @@ export function EmojisStickers({ requestClose }: EmojisStickersProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from '$components/icons/phosphor';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import type { RoomMember } from '$types/matrix-sdk';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { useRoomMembers } from '$hooks/useRoomMembers';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -58,9 +58,10 @@ const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||
const mxIdToName = (mxId: string) => getMxIdLocalPart(mxId) ?? mxId;
|
||||
|
||||
type MembersProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function Members({ requestClose }: MembersProps) {
|
||||
export function Members({ requestBack, requestClose }: MembersProps) {
|
||||
const mx = useMatrixClient();
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
@@ -144,21 +145,11 @@ export function Members({ requestClose }: MembersProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
{room.getJoinedMemberCount()} Members
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage
|
||||
title={`${room.getJoinedMemberCount()} Members`}
|
||||
requestBack={requestBack}
|
||||
requestClose={requestClose}
|
||||
>
|
||||
<Box grow="Yes" style={{ position: 'relative' }}>
|
||||
<Scroll ref={scrollRef} hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -359,6 +350,6 @@ export function Members({ requestClose }: MembersProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -40,6 +40,9 @@ import { factoryRoomIdByActivity } from '$utils/sort';
|
||||
import { nameInitials } from '$utils/common';
|
||||
import { useRoomNavigate } from '$hooks/useRoomNavigate';
|
||||
import { useListFocusIndex } from '$hooks/useListFocusIndex';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { getNavigatePath } from '$pages/pathUtils';
|
||||
import { getMxIdLocalPart, guessDmRoomUserId } from '$utils/matrix';
|
||||
import { roomToParentsAtom } from '$state/room/roomToParents';
|
||||
import { roomToUnreadAtom } from '$state/room/roomToUnread';
|
||||
@@ -511,6 +514,9 @@ export function RoomSearchModal({ requestClose, pickRoom, isMobile }: RoomSearch
|
||||
export function SearchModalRenderer() {
|
||||
const [opened, setOpen] = useAtom(searchModalAtom);
|
||||
const [shortcutOverrides] = useSetting(settingsAtom, 'shortcutOverrides');
|
||||
const navigate = useNavigate();
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
|
||||
useKeyDown(
|
||||
window,
|
||||
@@ -518,11 +524,15 @@ export function SearchModalRenderer() {
|
||||
(event) => {
|
||||
if (matchesShortcut('navigation.openRoomSearch', event, shortcutOverrides)) {
|
||||
event.preventDefault();
|
||||
if (isMobile) {
|
||||
navigate(getNavigatePath());
|
||||
return;
|
||||
}
|
||||
setOpen(!opened);
|
||||
return;
|
||||
}
|
||||
},
|
||||
[opened, setOpen, shortcutOverrides]
|
||||
[opened, setOpen, shortcutOverrides, isMobile, navigate]
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useAtomValue } from 'jotai';
|
||||
import { Avatar, Box, config, IconButton, MenuItem, Text } from 'folds';
|
||||
import { JoinRule } from '$types/matrix-sdk';
|
||||
import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '$components/page';
|
||||
import { SettingsSectionHeader } from '$components/page/style.css';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { mxcUrlToHttp } from '$utils/matrix';
|
||||
@@ -124,18 +125,22 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) {
|
||||
};
|
||||
|
||||
const handleSwipeBack = () => {
|
||||
if (screenSize === ScreenSize.Mobile) {
|
||||
requestClose();
|
||||
if (screenSize !== ScreenSize.Mobile) return;
|
||||
if (activePage !== undefined) {
|
||||
setActivePage(undefined);
|
||||
return;
|
||||
}
|
||||
requestClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<SwipeableOverlayWrapper direction="right" onClose={handleSwipeBack}>
|
||||
<PageRoot
|
||||
mobileDrawer={false}
|
||||
nav={
|
||||
screenSize === ScreenSize.Mobile && activePage !== undefined ? undefined : (
|
||||
<PageNav size="300">
|
||||
<PageNavHeader outlined={false}>
|
||||
<PageNavHeader className={SettingsSectionHeader} size="600">
|
||||
<Box grow="Yes" gap="200">
|
||||
<Avatar size="200" radii="300">
|
||||
<RoomAvatar
|
||||
@@ -200,25 +205,25 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) {
|
||||
}
|
||||
>
|
||||
{activePage === RoomSettingsPage.GeneralPage && (
|
||||
<General requestClose={handlePageRequestClose} />
|
||||
<General requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.MembersPage && (
|
||||
<Members requestClose={handlePageRequestClose} />
|
||||
<Members requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.PermissionsPage && (
|
||||
<Permissions requestClose={handlePageRequestClose} />
|
||||
<Permissions requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.CosmeticsPage && (
|
||||
<Cosmetics requestClose={handlePageRequestClose} />
|
||||
<Cosmetics requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.EmojisStickersPage && (
|
||||
<EmojisStickers requestClose={handlePageRequestClose} />
|
||||
<EmojisStickers requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.DeveloperToolsPage && (
|
||||
<DeveloperTools requestClose={handlePageRequestClose} />
|
||||
<DeveloperTools requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === RoomSettingsPage.AbbreviationsPage && (
|
||||
<RoomAbbreviations requestClose={handlePageRequestClose} />
|
||||
<RoomAbbreviations requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
</PageRoot>
|
||||
</SwipeableOverlayWrapper>
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Box, Button, Chip, IconButton, Input, Scroll, Spinner, Text, config } from 'folds';
|
||||
import { composerIcon, menuIcon, Trash, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { menuIcon, Trash } from '$components/icons/phosphor';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
@@ -24,11 +24,12 @@ import { SequenceCardStyle } from '$features/common-settings/styles.css';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
|
||||
type AbbreviationsProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
isSpace?: boolean;
|
||||
};
|
||||
|
||||
export function RoomAbbreviations({ requestClose, isSpace }: AbbreviationsProps) {
|
||||
export function RoomAbbreviations({ requestBack, requestClose, isSpace }: AbbreviationsProps) {
|
||||
const room = useRoom();
|
||||
const mx = useMatrixClient();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
@@ -133,21 +134,11 @@ export function RoomAbbreviations({ requestClose, isSpace }: AbbreviationsProps)
|
||||
};
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Abbreviations
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage
|
||||
title="Abbreviations"
|
||||
requestBack={requestBack}
|
||||
requestClose={requestClose}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -324,6 +315,6 @@ export function RoomAbbreviations({ requestClose, isSpace }: AbbreviationsProps)
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Box, IconButton, Scroll, Text } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Scroll, Text } from 'folds';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import {
|
||||
@@ -17,30 +16,17 @@ import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
|
||||
type GeneralProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function General({ requestClose }: GeneralProps) {
|
||||
export function General({ requestBack, requestClose }: GeneralProps) {
|
||||
const room = useRoom();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
const creators = useRoomCreators(room);
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
General
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="General" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -66,6 +52,6 @@ export function General({ requestClose }: GeneralProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, IconButton, Scroll, Text } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Scroll } from 'folds';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -14,9 +13,10 @@ import { EventType } from '$types/matrix-sdk';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
|
||||
type PermissionsProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function Permissions({ requestClose }: PermissionsProps) {
|
||||
export function Permissions({ requestBack, requestClose }: PermissionsProps) {
|
||||
const mx = useMatrixClient();
|
||||
const room = useRoom();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
@@ -39,21 +39,7 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Permissions
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="Permissions" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -72,6 +58,6 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '$components/page';
|
||||
import { SettingsSectionHeader } from '$components/page/style.css';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useUserProfile } from '$hooks/useUserProfile';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -57,7 +58,6 @@ import { KeyboardShortcuts } from './keyboard-shortcuts';
|
||||
import { Notifications } from './notifications';
|
||||
import { PerMessageProfilePage } from './Persona/ProfilesPage';
|
||||
import { settingsSections, type SettingsSectionId } from './routes';
|
||||
import { settingsHeader } from './styles.css';
|
||||
import { useSettingsFocus } from './useSettingsFocus';
|
||||
import { SettingsLinkProvider } from './SettingsLinkContext';
|
||||
import { useSettingsLinkBaseUrl } from './useSettingsLinkBaseUrl';
|
||||
@@ -285,7 +285,7 @@ export function Settings({
|
||||
nav={
|
||||
screenSize === ScreenSize.Mobile && visibleSection !== null ? undefined : (
|
||||
<PageNav size="300">
|
||||
<PageNavHeader className={settingsHeader} size="600">
|
||||
<PageNavHeader className={SettingsSectionHeader} size="600">
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="300">
|
||||
|
||||
@@ -25,7 +25,6 @@ import { SettingsRoute } from './SettingsRoute';
|
||||
import { SettingsShallowRouteRenderer } from './SettingsShallowRouteRenderer';
|
||||
import { SettingsSectionPage } from './SettingsSectionPage';
|
||||
import { focusedSettingTile } from './styles.css';
|
||||
import * as settingsCss from './styles.css';
|
||||
import { useOpenSettings } from './useOpenSettings';
|
||||
import { useSettingsFocus } from './useSettingsFocus';
|
||||
|
||||
@@ -423,7 +422,9 @@ describe('SettingsSectionPage', () => {
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Devices').closest('header')).toHaveClass(settingsCss.settingsHeader);
|
||||
expect(screen.getByText('Devices').closest('header')).toHaveClass(
|
||||
pageCss.SettingsSectionHeader
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,57 +1 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, IconButton, Text } from 'folds';
|
||||
import { Page, PageHeader } from '$components/page';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { ArrowLeft, composerIcon, X } from '$components/icons/phosphor';
|
||||
import { settingsHeader, settingsSectionBody } from './styles.css';
|
||||
|
||||
type SettingsSectionPageProps = {
|
||||
title: ReactNode;
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
titleAs?: 'h1' | 'h2' | 'h3' | 'span' | 'div';
|
||||
backLabel?: string;
|
||||
actionLabel?: string;
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export function SettingsSectionPage({
|
||||
title,
|
||||
requestBack,
|
||||
requestClose,
|
||||
titleAs,
|
||||
backLabel,
|
||||
actionLabel,
|
||||
children,
|
||||
}: SettingsSectionPageProps) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const closeLabel = actionLabel ?? 'Close';
|
||||
const showBack = screenSize === ScreenSize.Mobile && requestBack;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader className={settingsHeader}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
{showBack && (
|
||||
<IconButton aria-label={backLabel ?? 'Back'} onClick={requestBack} variant="Surface">
|
||||
{composerIcon(ArrowLeft)}
|
||||
</IconButton>
|
||||
)}
|
||||
<Text size="H4" as={titleAs} truncate>
|
||||
{title}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton aria-label={closeLabel} onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes" className={settingsSectionBody}>
|
||||
{children}
|
||||
</Box>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
export { SettingsSectionPage } from '$components/page';
|
||||
@@ -1,27 +1,9 @@
|
||||
import { globalStyle, style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config } from 'folds';
|
||||
import { messageJumpHighlight } from '$components/message/layout/layout.css';
|
||||
|
||||
export const SequenceCardStyle = style({
|
||||
padding: config.space.S300,
|
||||
});
|
||||
|
||||
export const settingsSectionBody = style({
|
||||
width: '100%',
|
||||
maxWidth: toRem(800),
|
||||
marginInline: 'auto',
|
||||
});
|
||||
|
||||
globalStyle(`${settingsSectionBody} *`, {
|
||||
scrollbarWidth: 'none',
|
||||
});
|
||||
globalStyle(`${settingsSectionBody} *::-webkit-scrollbar`, {
|
||||
display: 'none',
|
||||
});
|
||||
|
||||
export const settingsHeader = style({
|
||||
paddingLeft: config.space.S300,
|
||||
paddingRight: config.space.S200,
|
||||
});
|
||||
|
||||
export const focusedSettingTile = messageJumpHighlight;
|
||||
@@ -5,6 +5,7 @@ import { useAtomValue } from 'jotai';
|
||||
import { Avatar, Box, config, IconButton, MenuItem, Text } from 'folds';
|
||||
import { JoinRule } from '$types/matrix-sdk';
|
||||
import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '$components/page';
|
||||
import { SettingsSectionHeader } from '$components/page/style.css';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { mxcUrlToHttp } from '$utils/matrix';
|
||||
@@ -20,6 +21,7 @@ import { DeveloperTools } from '$features/common-settings/developer-tools';
|
||||
import { Cosmetics } from '$features/common-settings/cosmetics/Cosmetics';
|
||||
import { Appearance } from '$features/common-settings/appearance/Appearance';
|
||||
import { RoomAbbreviations } from '$features/room-settings/abbreviations/RoomAbbreviations';
|
||||
import { SwipeableOverlayWrapper } from '$components/SwipeableOverlayWrapper';
|
||||
import {
|
||||
composerIcon,
|
||||
GearSix,
|
||||
@@ -125,99 +127,115 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps)
|
||||
requestClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<PageRoot
|
||||
nav={
|
||||
screenSize === ScreenSize.Mobile && activePage !== undefined ? undefined : (
|
||||
<PageNav size="300">
|
||||
<PageNavHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Avatar size="200" radii="300">
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={avatarUrl}
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
roomType={room.getType()}
|
||||
size="50"
|
||||
joinRule={joinRuleContent?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
<Text size="H4" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
{screenSize === ScreenSize.Mobile && (
|
||||
<IconButton onClick={requestClose} variant="Background">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<PageNavContent>
|
||||
<div style={{ flexGrow: 1 }}>
|
||||
{menuItems.map((item) => {
|
||||
const active = activePage === item.page;
|
||||
const IconComponent = active && item.activeIcon ? item.activeIcon : item.icon;
|
||||
const handleSwipeBack = () => {
|
||||
if (screenSize !== ScreenSize.Mobile) return;
|
||||
if (activePage !== undefined) {
|
||||
setActivePage(undefined);
|
||||
return;
|
||||
}
|
||||
requestClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
key={item.name}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-pressed={active}
|
||||
before={settingsNavIcon(IconComponent, active)}
|
||||
onClick={() => setActivePage(item.page)}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: active ? config.fontWeight.W600 : undefined,
|
||||
}}
|
||||
size="T300"
|
||||
truncate
|
||||
return (
|
||||
<SwipeableOverlayWrapper direction="right" onClose={handleSwipeBack}>
|
||||
<PageRoot
|
||||
mobileDrawer={false}
|
||||
nav={
|
||||
screenSize === ScreenSize.Mobile && activePage !== undefined ? undefined : (
|
||||
<PageNav size="300">
|
||||
<PageNavHeader className={SettingsSectionHeader} size="600">
|
||||
<Box grow="Yes" gap="200">
|
||||
<Avatar size="200" radii="300">
|
||||
<RoomAvatar
|
||||
roomId={room.roomId}
|
||||
src={avatarUrl}
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
roomType={room.getType()}
|
||||
size="50"
|
||||
joinRule={joinRuleContent?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
<Text size="H4" truncate>
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
{screenSize === ScreenSize.Mobile && (
|
||||
<IconButton onClick={requestClose} variant="Background">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<PageNavContent>
|
||||
<div style={{ flexGrow: 1 }}>
|
||||
{menuItems.map((item) => {
|
||||
const active = activePage === item.page;
|
||||
const IconComponent = active && item.activeIcon ? item.activeIcon : item.icon;
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
key={item.name}
|
||||
variant="Background"
|
||||
radii="400"
|
||||
aria-pressed={active}
|
||||
before={settingsNavIcon(IconComponent, active)}
|
||||
onClick={() => setActivePage(item.page)}
|
||||
>
|
||||
{item.name}
|
||||
</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</PageNavContent>
|
||||
</Box>
|
||||
</PageNav>
|
||||
)
|
||||
}
|
||||
>
|
||||
{activePage === SpaceSettingsPage.GeneralPage && (
|
||||
<General requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.MembersPage && (
|
||||
<Members requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.PermissionsPage && (
|
||||
<Permissions requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.CosmeticsPage && (
|
||||
<Cosmetics requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.EmojisStickersPage && (
|
||||
<EmojisStickers requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.DeveloperToolsPage && (
|
||||
<DeveloperTools requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.AbbreviationsPage && (
|
||||
<RoomAbbreviations isSpace requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.AppearancePage && (
|
||||
<Appearance requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
</PageRoot>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: active ? config.fontWeight.W600 : undefined,
|
||||
}}
|
||||
size="T300"
|
||||
truncate
|
||||
>
|
||||
{item.name}
|
||||
</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</PageNavContent>
|
||||
</Box>
|
||||
</PageNav>
|
||||
)
|
||||
}
|
||||
>
|
||||
{activePage === SpaceSettingsPage.GeneralPage && (
|
||||
<General requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.MembersPage && (
|
||||
<Members requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.PermissionsPage && (
|
||||
<Permissions requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.CosmeticsPage && (
|
||||
<Cosmetics requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.EmojisStickersPage && (
|
||||
<EmojisStickers requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.DeveloperToolsPage && (
|
||||
<DeveloperTools requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.AbbreviationsPage && (
|
||||
<RoomAbbreviations
|
||||
isSpace
|
||||
requestBack={handlePageRequestClose}
|
||||
requestClose={requestClose}
|
||||
/>
|
||||
)}
|
||||
{activePage === SpaceSettingsPage.AppearancePage && (
|
||||
<Appearance requestBack={handlePageRequestClose} requestClose={requestClose} />
|
||||
)}
|
||||
</PageRoot>
|
||||
</SwipeableOverlayWrapper>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Box, IconButton, Scroll, Text } from 'folds';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Scroll, Text } from 'folds';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import {
|
||||
RoomProfile,
|
||||
RoomJoinRules,
|
||||
@@ -15,30 +14,17 @@ import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
|
||||
type GeneralProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function General({ requestClose }: GeneralProps) {
|
||||
export function General({ requestBack, requestClose }: GeneralProps) {
|
||||
const room = useRoom();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
const creators = useRoomCreators(room);
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
General
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="General" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -62,6 +48,6 @@ export function General({ requestClose }: GeneralProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, IconButton, Scroll, Text } from 'folds';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { Box, Scroll } from 'folds';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
|
||||
import { PermissionGroups, Powers, PowersEditor } from '$features/common-settings/permissions';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
@@ -14,9 +13,10 @@ import { EventType } from '$types/matrix-sdk';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
|
||||
type PermissionsProps = {
|
||||
requestBack?: () => void;
|
||||
requestClose: () => void;
|
||||
};
|
||||
export function Permissions({ requestClose }: PermissionsProps) {
|
||||
export function Permissions({ requestBack, requestClose }: PermissionsProps) {
|
||||
const mx = useMatrixClient();
|
||||
const room = useRoom();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
@@ -39,21 +39,7 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
<Box grow="Yes" gap="200">
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Text size="H3" truncate>
|
||||
Permissions
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={requestClose} variant="Surface">
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<SettingsSectionPage title="Permissions" requestBack={requestBack} requestClose={requestClose}>
|
||||
<Box grow="Yes">
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
@@ -72,6 +58,6 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</SettingsSectionPage>
|
||||
);
|
||||
}
|
||||
@@ -121,4 +121,3 @@ export interface UploadWriteChunkParams {
|
||||
chunk: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ import {
|
||||
SETTINGS_PATH,
|
||||
NAVIGATE_PATH,
|
||||
PROFILE_PATH,
|
||||
CREATE_ROOM_PATH,
|
||||
BUG_REPORT_PATH,
|
||||
BOOKMARKS_PATH_SEGMENT,
|
||||
} from './paths';
|
||||
import {
|
||||
@@ -124,6 +126,14 @@ import { UserQuickToolsProvider } from '$components/UserQuickToolsProvider';
|
||||
import { Navigate } from './client/navigate';
|
||||
import { ProfileMobile } from './client/profile';
|
||||
|
||||
// Lazy-loaded: mobile full-screen pages for flows that are modals on desktop.
|
||||
const CreateRoomPage = lazy(() =>
|
||||
import('./client/create-room').then((m) => ({ default: m.CreateRoomPage }))
|
||||
);
|
||||
const BugReportPage = lazy(() =>
|
||||
import('./client/bug-report').then((m) => ({ default: m.BugReportPage }))
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns true if there is at least one stored session.
|
||||
* Reads localStorage directly — safe to call outside React (in route loaders).
|
||||
@@ -428,6 +438,22 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
/>
|
||||
</Route>
|
||||
<Route path={CREATE_PATH} element={<Create />} />
|
||||
<Route
|
||||
path={CREATE_ROOM_PATH}
|
||||
element={
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<CreateRoomPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={BUG_REPORT_PATH}
|
||||
element={
|
||||
<Suspense fallback={<SplashScreen>{null}</SplashScreen>}>
|
||||
<BugReportPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route path={NAVIGATE_PATH} element={<Navigate />} />
|
||||
<Route path={PROFILE_PATH} element={<ProfileMobile />} />
|
||||
<Route
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { Box, Scroll, toRem, Text, color, config } from 'folds';
|
||||
import { SquaresFour, sizedIcon } from '$components/icons/phosphor';
|
||||
import {
|
||||
Page,
|
||||
PageContent,
|
||||
PageContentCenter,
|
||||
PageHero,
|
||||
PageHeroSection,
|
||||
PageNav,
|
||||
PageNavHeader,
|
||||
} from '$components/page';
|
||||
import { BugReportForm } from '$features/bug-report';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { SidebarResizer } from '../sidebar/SidebarResizer';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
|
||||
import { UserQuickTools } from '../sidebar/UserQuickTools';
|
||||
|
||||
export function BugReportPage() {
|
||||
const navigate = useNavigate();
|
||||
const navigateBack = () => navigate(-1);
|
||||
|
||||
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
const [oldSidebar] = useSetting(settingsAtom, 'oldSidebar');
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isMobile && (
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: toRem(curWidth),
|
||||
borderRight: 'solid',
|
||||
borderColor: color.SurfaceVariant.ContainerLine,
|
||||
borderWidth: `0 ${config.borderWidth.B300} 0 0`,
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<PageNavHeader size="600">
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText ? (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate align="Center">
|
||||
Report an Issue
|
||||
</Text>
|
||||
</Box>
|
||||
) : (
|
||||
sizedIcon(SquaresFour, '200', { filled: true })
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={50}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
setAnnouncement={setIsResizingSidebar}
|
||||
/>
|
||||
</PageNav>
|
||||
{!oldSidebar && !isMobile && <UserQuickTools width={curWidth + 66} compact={false} />}
|
||||
</Box>
|
||||
)}
|
||||
<Page>
|
||||
<Box grow="Yes" direction="Column" style={{ background: color.Background.Container }}>
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
<PageContentCenter>
|
||||
<PageHeroSection>
|
||||
<Box direction="Column" gap="700">
|
||||
<PageHero
|
||||
icon={sizedIcon(SquaresFour, '600')}
|
||||
title="Report an Issue"
|
||||
subTitle="Report a bug or request a feature."
|
||||
/>
|
||||
<BugReportForm onDone={navigateBack} />
|
||||
</Box>
|
||||
</PageHeroSection>
|
||||
</PageContentCenter>
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './BugReportPage';
|
||||
@@ -0,0 +1,146 @@
|
||||
import { Box, IconButton, Scroll, toRem, Text, color, config } from 'folds';
|
||||
import { SquaresFour, composerIcon, sizedIcon, X } from '$components/icons/phosphor';
|
||||
import {
|
||||
Page,
|
||||
PageContent,
|
||||
PageContentCenter,
|
||||
PageHero,
|
||||
PageHeroSection,
|
||||
PageNav,
|
||||
PageNavHeader,
|
||||
} from '$components/page';
|
||||
import { CreateRoomForm } from '$features/create-room/CreateRoom';
|
||||
import { useRoomNavigate } from '$hooks/useRoomNavigate';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSearchParams, useNavigate } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { SpaceProvider } from '$hooks/useSpace';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { SidebarResizer } from '../sidebar/SidebarResizer';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
|
||||
import { UserQuickTools } from '../sidebar/UserQuickTools';
|
||||
import { CreateRoomType } from '$components/create-room/types';
|
||||
|
||||
export function CreateRoomPage() {
|
||||
const { navigateRoom } = useRoomNavigate();
|
||||
const backNavigate = useNavigate();
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
const spaceIdParam = searchParams.get('spaceId') ?? undefined;
|
||||
const typeParam = searchParams.get('type') ?? undefined;
|
||||
|
||||
// Parse type only for valid CreateRoomType enum values
|
||||
const type: CreateRoomType | undefined =
|
||||
typeParam === CreateRoomType.TextRoom || typeParam === CreateRoomType.VoiceRoom
|
||||
? (typeParam as CreateRoomType)
|
||||
: undefined;
|
||||
|
||||
const allJoinedRooms = useAllJoinedRoomsSet();
|
||||
const getRoom = useGetRoom(allJoinedRooms);
|
||||
const space = spaceIdParam ? getRoom(spaceIdParam) : undefined;
|
||||
|
||||
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const screenSize = useScreenSizeContext();
|
||||
const isMobile = screenSize === ScreenSize.Mobile;
|
||||
const hideText = curWidth <= 80 && !isMobile;
|
||||
const [oldSidebar] = useSetting(settingsAtom, 'oldSidebar');
|
||||
|
||||
const title = type === CreateRoomType.VoiceRoom ? 'New Voice Room' : 'New Chat Room';
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isMobile && (
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: toRem(curWidth),
|
||||
borderRight: 'solid',
|
||||
borderColor: color.SurfaceVariant.ContainerLine,
|
||||
borderWidth: `0 ${config.borderWidth.B300} 0 0`,
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
<PageNavHeader size="600">
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
{!hideText ? (
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" truncate align="Center">
|
||||
{title}
|
||||
</Text>
|
||||
</Box>
|
||||
) : (
|
||||
sizedIcon(SquaresFour, '200', { filled: true })
|
||||
)}
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={50}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
setAnnouncement={setIsResizingSidebar}
|
||||
/>
|
||||
</PageNav>
|
||||
{!oldSidebar && !isMobile && <UserQuickTools width={curWidth + 66} compact={false} />}
|
||||
</Box>
|
||||
)}
|
||||
<Page>
|
||||
<Box grow="Yes">
|
||||
{isMobile && (
|
||||
<PageNav>
|
||||
<PageNavHeader size="600">
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" align="Center" truncate style={{ width: '100%' }}>
|
||||
{title}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton
|
||||
aria-label="Close create room"
|
||||
onClick={() => backNavigate(-1)}
|
||||
variant="Background"
|
||||
>
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
</PageNav>
|
||||
)}
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
<PageContentCenter>
|
||||
<PageHeroSection>
|
||||
<Box direction="Column" gap="700">
|
||||
<PageHero
|
||||
icon={sizedIcon(SquaresFour, '600')}
|
||||
title={title}
|
||||
subTitle="Create a new room."
|
||||
/>
|
||||
<SpaceProvider value={space ?? null}>
|
||||
<CreateRoomForm space={space} onCreate={navigateRoom} defaultType={type} />
|
||||
</SpaceProvider>
|
||||
</Box>
|
||||
</PageHeroSection>
|
||||
</PageContentCenter>
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Page>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './CreateRoomPage';
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, Scroll, toRem, Text, color, config } from 'folds';
|
||||
import { SquaresFour, sizedIcon } from '$components/icons/phosphor';
|
||||
import { Box, IconButton, Scroll, toRem, Text, color, config } from 'folds';
|
||||
import { SquaresFour, composerIcon, sizedIcon, X } from '$components/icons/phosphor';
|
||||
import {
|
||||
Page,
|
||||
PageContent,
|
||||
@@ -12,7 +12,11 @@ import {
|
||||
import { CreateSpaceForm } from '$features/create-space';
|
||||
import { useRoomNavigate } from '$hooks/useRoomNavigate';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { SpaceProvider } from '$hooks/useSpace';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { SidebarResizer } from '../sidebar/SidebarResizer';
|
||||
@@ -22,6 +26,13 @@ import { UserQuickTools } from '../sidebar/UserQuickTools';
|
||||
|
||||
export function Create() {
|
||||
const { navigateSpace } = useRoomNavigate();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const spaceId = searchParams.get('spaceId') ?? undefined;
|
||||
|
||||
const allJoinedRooms = useAllJoinedRoomsSet();
|
||||
const getRoom = useGetRoom(allJoinedRooms);
|
||||
const space = spaceId ? getRoom(spaceId) : undefined;
|
||||
|
||||
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
@@ -77,7 +88,30 @@ export function Create() {
|
||||
</Box>
|
||||
)}
|
||||
<Page>
|
||||
<Box grow="Yes">
|
||||
<Box grow="Yes" direction="Column" style={{ background: color.Background.Container }}>
|
||||
{isMobile && (
|
||||
<PageNav>
|
||||
<PageNavHeader size="600">
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
<Box grow="Yes">
|
||||
<Text size="H4" align="Center" truncate style={{ width: '100%' }}>
|
||||
Create Space
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton
|
||||
size="300"
|
||||
radii="300"
|
||||
aria-label="Close create space"
|
||||
onClick={() => navigate(-1)}
|
||||
>
|
||||
{composerIcon(X)}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavHeader>
|
||||
</PageNav>
|
||||
)}
|
||||
<Scroll hideTrack visibility="Hover">
|
||||
<PageContent>
|
||||
<PageContentCenter>
|
||||
@@ -88,7 +122,9 @@ export function Create() {
|
||||
title="Create Space"
|
||||
subTitle="Build a space for your community."
|
||||
/>
|
||||
<CreateSpaceForm onCreate={navigateSpace} />
|
||||
<SpaceProvider value={space ?? null}>
|
||||
<CreateSpaceForm space={space} onCreate={navigateSpace} />
|
||||
</SpaceProvider>
|
||||
</Box>
|
||||
</PageHeroSection>
|
||||
</PageContentCenter>
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
menuIcon,
|
||||
PencilSimple,
|
||||
PushPinSlash,
|
||||
ShareNetwork,
|
||||
UserPlus,
|
||||
X,
|
||||
} from '$components/icons/phosphor';
|
||||
@@ -88,6 +89,7 @@ import { useRoomsUnread } from '$state/hooks/unread';
|
||||
import { roomToUnreadAtom } from '$state/room/roomToUnread';
|
||||
import { markAsRead } from '$utils/notifications';
|
||||
import { copyToClipboard } from '$utils/dom';
|
||||
import { shareText } from '$utils/share';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { getMatrixToRoom } from '$plugins/matrix-to';
|
||||
import { getViaServers } from '$plugins/via-servers';
|
||||
@@ -145,6 +147,13 @@ const SpaceMenu = forwardRef<HTMLDivElement, SpaceMenuProps>(
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleShareLink = () => {
|
||||
const roomIdOrAlias = getCanonicalAliasOrRoomId(mx, room.roomId);
|
||||
const viaServers = isRoomAlias(roomIdOrAlias) ? undefined : getViaServers(room);
|
||||
shareText(getMatrixToRoom(roomIdOrAlias, viaServers)).catch(() => {});
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleInvite = () => {
|
||||
setInvitePrompt(true);
|
||||
};
|
||||
@@ -206,6 +215,11 @@ const SpaceMenu = forwardRef<HTMLDivElement, SpaceMenuProps>(
|
||||
Copy Link
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleShareLink} size="300" after={menuIcon(ShareNetwork)} radii="300">
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Share Link
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleRoomSettings} size="300" after={menuIcon(GearSix)} radii="300">
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Space Settings
|
||||
|
||||
@@ -60,6 +60,7 @@ import {
|
||||
Lock,
|
||||
MagnifyingGlass,
|
||||
menuIcon,
|
||||
ShareNetwork,
|
||||
SignOut,
|
||||
Terminal,
|
||||
UserPlus,
|
||||
@@ -71,6 +72,7 @@ import { useRoomsUnread } from '$state/hooks/unread';
|
||||
import { UseStateProvider } from '$components/UseStateProvider';
|
||||
import { LeaveSpacePrompt } from '$components/leave-space-prompt';
|
||||
import { copyToClipboard } from '$utils/dom';
|
||||
import { shareText } from '$utils/share';
|
||||
import { useClosedNavCategoriesAtom } from '$state/hooks/closedNavCategories';
|
||||
import { useStateEvent } from '$hooks/useStateEvent';
|
||||
|
||||
@@ -150,6 +152,13 @@ const SpaceMenu = forwardRef<HTMLDivElement, SpaceMenuProps>(({ room, requestClo
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleShareLink = () => {
|
||||
const roomIdOrAlias = getCanonicalAliasOrRoomId(mx, room.roomId);
|
||||
const viaServers = isRoomAlias(roomIdOrAlias) ? undefined : getViaServers(room);
|
||||
shareText(getMatrixToRoom(roomIdOrAlias, viaServers)).catch(() => {});
|
||||
requestClose();
|
||||
};
|
||||
|
||||
const handleInvite = () => {
|
||||
setInvitePrompt(true);
|
||||
};
|
||||
@@ -210,6 +219,11 @@ const SpaceMenu = forwardRef<HTMLDivElement, SpaceMenuProps>(({ room, requestClo
|
||||
Copy Link
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleShareLink} size="300" after={menuIcon(ShareNetwork)} radii="300">
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Share Link
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={handleRoomSettings} size="300" after={menuIcon(GearSix)} radii="300">
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Space Settings
|
||||
|
||||
@@ -29,6 +29,8 @@ import {
|
||||
SPACE_ROOM_PATH,
|
||||
SPACE_SEARCH_PATH,
|
||||
CREATE_PATH,
|
||||
CREATE_ROOM_PATH,
|
||||
BUG_REPORT_PATH,
|
||||
NAVIGATE_PATH,
|
||||
PROFILE_PATH,
|
||||
INBOX_BOOKMARKS_PATH,
|
||||
@@ -158,6 +160,16 @@ export const getExploreServerPath = (server: string): string => {
|
||||
};
|
||||
|
||||
export const getCreatePath = (): string => CREATE_PATH;
|
||||
export const getCreateSpacePath = (spaceId?: string): string =>
|
||||
spaceId ? withSearchParam(CREATE_PATH, { spaceId }) : CREATE_PATH;
|
||||
export const getCreateRoomPath = (spaceId?: string, type?: string): string => {
|
||||
const params: Record<string, string> = {};
|
||||
if (spaceId) params.spaceId = spaceId;
|
||||
if (type) params.type = type;
|
||||
const keys = Object.keys(params);
|
||||
return keys.length === 0 ? CREATE_ROOM_PATH : withSearchParam(CREATE_ROOM_PATH, params);
|
||||
};
|
||||
export const getBugReportPath = (): string => BUG_REPORT_PATH;
|
||||
export const getNavigatePath = (): string => NAVIGATE_PATH;
|
||||
export const getProfilePath = (): string => PROFILE_PATH;
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ export type ExploreServerPathSearchParams = {
|
||||
export const EXPLORE_SERVER_PATH = `/explore/${SERVER_PATH_SEGMENT}`;
|
||||
|
||||
export const CREATE_PATH = '/create';
|
||||
export const CREATE_ROOM_PATH = '/create-room';
|
||||
export const BUG_REPORT_PATH = '/bug-report';
|
||||
export const NAVIGATE_PATH = '/navigate';
|
||||
export const PROFILE_PATH = '/profile/';
|
||||
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { bugReportOpenAtom } from '$state/bugReportModal';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { getBugReportPath } from '$pages/pathUtils';
|
||||
|
||||
export const useBugReportModalOpen = (): boolean => useAtomValue(bugReportOpenAtom);
|
||||
|
||||
export const useOpenBugReportModal = (): (() => void) => {
|
||||
const setOpen = useSetAtom(bugReportOpenAtom);
|
||||
return useCallback(() => setOpen(true), [setOpen]);
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
|
||||
return useCallback(() => {
|
||||
if (isMobile) {
|
||||
navigate(getBugReportPath());
|
||||
return;
|
||||
}
|
||||
setOpen(true);
|
||||
}, [setOpen, navigate, isMobile]);
|
||||
};
|
||||
|
||||
export const useCloseBugReportModal = (): (() => void) => {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import type { CreateRoomType } from '$components/create-room/types';
|
||||
import type { CreateRoomModalState } from '$state/createRoomModal';
|
||||
import { createRoomModalAtom } from '$state/createRoomModal';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { getCreateRoomPath } from '$pages/pathUtils';
|
||||
|
||||
export const useCreateRoomModalState = (): CreateRoomModalState | undefined => {
|
||||
const data = useAtomValue(createRoomModalAtom);
|
||||
@@ -24,12 +27,18 @@ export const useCloseCreateRoomModal = (): CloseCallback => {
|
||||
type OpenCallback = (space?: string, type?: CreateRoomType) => void;
|
||||
export const useOpenCreateRoomModal = (): OpenCallback => {
|
||||
const setSettings = useSetAtom(createRoomModalAtom);
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
|
||||
|
||||
const open: OpenCallback = useCallback(
|
||||
(spaceId, type) => {
|
||||
if (isMobile) {
|
||||
navigate(getCreateRoomPath(spaceId, type));
|
||||
return;
|
||||
}
|
||||
setSettings({ spaceId, type });
|
||||
},
|
||||
[setSettings]
|
||||
[setSettings, isMobile, navigate]
|
||||
);
|
||||
|
||||
return open;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import type { CreateSpaceModalState } from '$state/createSpaceModal';
|
||||
import { createSpaceModalAtom } from '$state/createSpaceModal';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { getCreateSpacePath } from '$pages/pathUtils';
|
||||
|
||||
export const useCreateSpaceModalState = (): CreateSpaceModalState | undefined => {
|
||||
const data = useAtomValue(createSpaceModalAtom);
|
||||
@@ -20,15 +23,21 @@ export const useCloseCreateSpaceModal = (): CloseCallback => {
|
||||
return close;
|
||||
};
|
||||
|
||||
type OpenCallback = (space?: string) => void;
|
||||
type OpenCallback = (spaceId?: string) => void;
|
||||
export const useOpenCreateSpaceModal = (): OpenCallback => {
|
||||
const setSettings = useSetAtom(createSpaceModalAtom);
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
|
||||
|
||||
const open: OpenCallback = useCallback(
|
||||
(spaceId) => {
|
||||
if (isMobile) {
|
||||
navigate(getCreateSpacePath(spaceId));
|
||||
return;
|
||||
}
|
||||
setSettings({ spaceId });
|
||||
},
|
||||
[setSettings]
|
||||
[setSettings, isMobile, navigate]
|
||||
);
|
||||
|
||||
return open;
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('android edge-to-edge inset contract', () => {
|
||||
expect(cargoToml).toContain(
|
||||
'tauri-plugin-edge-to-edge = { git = "https://github.com/SableClient/tauri-plugin-edge-to-edge.git", rev = "33c6116c27be28c06df5a9d02231ecc5fdeb93c5" }'
|
||||
);
|
||||
expect(tauriLib).toContain('builder = builder.plugin(tauri_plugin_edge_to_edge::init());');
|
||||
expect(tauriLib).toContain('.plugin(tauri_plugin_edge_to_edge::init())');
|
||||
});
|
||||
|
||||
it('keeps MainActivity out of the inset injection path', () => {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { copyToClipboard } from '$utils/dom';
|
||||
|
||||
/**
|
||||
* Shares text via the native share sheet on mobile (Tauri + sharekit),
|
||||
* the Web Share API on web (PWA), or falls back to clipboard copy when no
|
||||
* share API is available. Returns true if the text was shared or copied;
|
||||
* false if the user cancelled the share sheet.
|
||||
*/
|
||||
export async function shareText(text: string): Promise<boolean> {
|
||||
// 1. Tauri mobile: use sharekit plugin
|
||||
try {
|
||||
const { type: osType } = await import('@tauri-apps/plugin-os');
|
||||
if (osType() === 'android' || osType() === 'ios') {
|
||||
const { shareText: sharekitShare } = await import('@choochmeque/tauri-plugin-sharekit-api');
|
||||
await sharekitShare(text);
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// Tauri plugin not available — fall through
|
||||
}
|
||||
|
||||
// 2. Web: try navigator.share if available (PWA context, not Tauri)
|
||||
if (typeof navigator !== 'undefined' && navigator.share) {
|
||||
try {
|
||||
await navigator.share({ text });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fallback: clipboard copy when no share API is available
|
||||
return copyToClipboard(text);
|
||||
}
|
||||
Reference in new issue
Block a user