A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): show instance branding on the sign-in card
Hampus0a86fd3f3692
diff --git a/fluxer_app/src/features/auth/InstanceBranding.ts b/fluxer_app/src/features/auth/InstanceBranding.tsindex 784bfe638..a3551c9c3 100644--- a/fluxer_app/src/features/auth/InstanceBranding.ts+++ b/fluxer_app/src/features/auth/InstanceBranding.ts@@ -1,12 +1,29 @@// SPDX-License-Identifier: AGPL-3.0-or-later+import {PRODUCT_NAME} from '@app/features/app/config/ProductConstants';import type {RuntimeConfigSnapshot} from '@app/features/app/state/RuntimeConfigSnapshot';+import {isOfficialInstanceHost} from '@fluxer/instance_bootstrap/src/OfficialInstance';type BrandingSnapshot = Pick<RuntimeConfigSnapshot,'apiEndpoint' | 'apiPublicEndpoint' | 'mediaEndpoint' | 'staticCdnEndpoint' | 'webAppEndpoint' | 'appPublic'>;+export interface AuthBrandOptions {+ readonly isDocumentInstance: boolean;+ readonly documentHost: string | null;+}++export interface AuthBrand {+ readonly productName: string;+ readonly usesDefaultName: boolean;+ readonly logoCandidates: ReadonlyArray<string>;+ readonly wordmarkUrl: string | null;+ readonly backdropUrl: string | null;+ readonly host: string | null;+ readonly isOfficial: boolean;+}+const ASSET_PROTOCOLS: ReadonlySet<string> = new Set(['https:', 'http:']);export function originOf(value: string | null | undefined): string | null {@@ -79,3 +96,50 @@ export function resolveInstanceProductName(snapshot: BrandingSnapshot | null | uconst name = snapshot?.appPublic?.branding?.product_name?.trim();return name == null || name.length === 0 ? null : name;}++function hostOf(value: string | null | undefined): string | null {+ if (value == null || value.length === 0) {+ return null;+ }+ try {+ const host = new URL(value).host.toLowerCase();+ return host.length === 0 ? null : host;+ } catch {+ return null;+ }+}++export function authBrandHasLogo(brand: AuthBrand): boolean {+ return brand.logoCandidates.length > 0 || brand.usesDefaultName;+}++export function resolveAuthBrand(snapshot: BrandingSnapshot, options: AuthBrandOptions): AuthBrand {+ const branding = snapshot.appPublic.branding;+ const productName = resolveInstanceProductName(snapshot) ?? PRODUCT_NAME;+ const resolveUrl = (candidate: string | null | undefined): string | null => {+ if (!options.isDocumentInstance) {+ return resolveInstanceAssetUrl(snapshot, candidate);+ }+ const trimmed = candidate?.trim();+ return trimmed == null || trimmed.length === 0 ? null : trimmed;+ };+ const logoCandidates: Array<string> = [];+ for (const candidate of [branding.logo_url, branding.icon_url, branding.symbol_url]) {+ const url = resolveUrl(candidate);+ if (url != null && !logoCandidates.includes(url)) {+ logoCandidates.push(url);+ }+ }+ const apiHost = hostOf(snapshot.apiEndpoint);+ const isOfficial = apiHost != null && isOfficialInstanceHost(apiHost);+ const host = isOfficial ? null : ((options.isDocumentInstance ? options.documentHost : null) ?? apiHost);+ return {+ productName,+ usesDefaultName: productName === PRODUCT_NAME,+ logoCandidates,+ wordmarkUrl: resolveUrl(branding.wordmark_url),+ backdropUrl: isOfficial ? null : resolveUrl(branding.sign_in_backdrop_url),+ host,+ isOfficial,+ };+}diff --git a/fluxer_app/src/features/auth/components/AuthBrandPanel.module.css b/fluxer_app/src/features/auth/components/AuthBrandPanel.module.cssnew file mode 100644index 000000000..80e69d70f--- /dev/null+++ b/fluxer_app/src/features/auth/components/AuthBrandPanel.module.css@@ -0,0 +1,133 @@+/* SPDX-License-Identifier: AGPL-3.0-or-later */++.brand {+ box-sizing: border-box;+ display: flex;+ min-width: 0;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ color: var(--text-primary);+ text-align: center;+}++.identity {+ display: flex;+ min-width: 0;+ max-width: 100%;+ align-items: center;+ justify-content: center;+ gap: 0.625rem;+}++.logo {+ display: none;+ width: auto;+ height: 1.75rem;+ max-inline-size: 4rem;+ flex: 0 0 auto;+ object-fit: contain;+}++.textTier .logo,+.card .logo {+ display: block;+}++.wordmark {+ min-width: 0;+ max-inline-size: 14rem;+ overflow-wrap: anywhere;+}++img.wordmark,+svg.wordmark {+ width: auto;+ height: 1.5rem;+ flex: 0 1 auto;+ object-fit: contain;+}++span.wordmark {+ display: block;+ max-block-size: 2.2em;+ overflow: hidden;+ font-size: 1.125rem;+}++.host {+ max-inline-size: 100%;+ margin-block-start: 0.375rem;+ overflow: hidden;+ color: var(--text-tertiary);+ font-size: 0.8125rem;+ line-height: 1.25rem;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.card {+ padding-block: var(--auth-card-padding) 0;+ padding-inline: 3.5rem;+}++.mobile {+ margin-block-end: 2rem;+}++.mobile img.wordmark,+.mobile svg.wordmark {+ height: 2rem;+}++.mobile span.wordmark {+ font-size: 1.5rem;+}++@media (max-width: 640px) {+ .card .host {+ display: none;+ }+}++@media (min-width: 55rem) {+ .split {+ flex: 0 0 18rem;+ padding: 2.5rem 1.5rem;+ border-inline-end: 0.0625rem solid var(--background-modifier-accent);+ }++ .split .identity {+ flex-direction: column;+ gap: 1.5rem;+ }++ .split .logo {+ display: block;+ width: min(13rem, calc(8rem * var(--auth-brand-logo-ratio, 1)));+ height: auto;+ max-inline-size: none;+ aspect-ratio: var(--auth-brand-logo-ratio, 1);+ }++ .split:has(.logo[data-pending]) > * {+ visibility: hidden;+ }++ .split .wordmark {+ max-inline-size: 13rem;+ }++ .split img.wordmark,+ .split svg.wordmark {+ height: 2rem;+ }++ .split span.wordmark {+ font-size: 1.5rem;+ }++ .split .host {+ margin-block-start: 0.75rem;+ }+}diff --git a/fluxer_app/src/features/auth/components/AuthBrandPanel.tsx b/fluxer_app/src/features/auth/components/AuthBrandPanel.tsxnew file mode 100644index 000000000..141cff4df--- /dev/null+++ b/fluxer_app/src/features/auth/components/AuthBrandPanel.tsx@@ -0,0 +1,155 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import styles from '@app/features/auth/components/AuthBrandPanel.module.css';+import type {AuthBrand} from '@app/features/auth/InstanceBranding';+import {FluxerWordmark, type WordmarkBranding} from '@app/features/ui/components/icons/FluxerWordmark';+import {flxElementClassName} from '@app/lib/react';+import FluxerLogoAsset from '@app/media/images/fluxer-logo-color.svg?react';+import type React from 'react';+import {useCallback, useMemo, useState} from 'react';++const LOGO_BOX_PX = 128;+const WORDMARK_TEXT_STYLE: React.CSSProperties = {display: 'block', lineHeight: 1.1};++type AuthBrandLogo = {readonly kind: 'image'; readonly url: string} | {readonly kind: 'bundled'};++export const AuthBrandLayout = Object.freeze({+ CARD: 'card',+ MOBILE: 'mobile',+} as const);++export type AuthBrandLayout = (typeof AuthBrandLayout)[keyof typeof AuthBrandLayout];++interface AuthBrandLogoState {+ readonly logo: AuthBrandLogo | null;+ readonly onLogoError: () => void;+}++function resolveAuthBrandLogo(brand: AuthBrand | null, failedUrls: ReadonlySet<string>): AuthBrandLogo | null {+ if (brand == null) {+ return null;+ }+ for (const url of brand.logoCandidates) {+ if (!failedUrls.has(url)) {+ return {kind: 'image', url};+ }+ }+ return brand.usesDefaultName ? {kind: 'bundled'} : null;+}++export function useAuthBrandLogo(brand: AuthBrand | null): AuthBrandLogoState {+ const [failedUrls, setFailedUrls] = useState<ReadonlySet<string>>(() => new Set());+ const logo = useMemo(() => resolveAuthBrandLogo(brand, failedUrls), [brand, failedUrls]);+ const failingUrl = logo?.kind === 'image' ? logo.url : null;+ const onLogoError = useCallback(() => {+ if (failingUrl == null) {+ return;+ }+ setFailedUrls((current) => new Set(current).add(failingUrl));+ }, [failingUrl]);+ return {logo, onLogoError};+}++interface AuthBrandPanelProps {+ readonly brand: AuthBrand;+ readonly logo: AuthBrandLogo | null;+ readonly onLogoError: () => void;+ readonly layout: AuthBrandLayout;+}++function renderLogo(logo: AuthBrandLogo | null, onLogoError: () => void): React.ReactNode {+ if (logo == null) {+ return null;+ }+ if (logo.kind === 'bundled') {+ return (+ <FluxerLogoAsset+ className={styles.logo}+ width={LOGO_BOX_PX}+ height={LOGO_BOX_PX}+ aria-hidden="true"+ data-flx="auth.components.auth-brand-panel.logo-bundled"+ />+ );+ }+ return (+ <AuthBrandLogoImage+ key={logo.url}+ url={logo.url}+ onError={onLogoError}+ data-flx="auth.components.auth-brand-panel.logo"+ />+ );+}++interface AuthBrandLogoImageProps {+ readonly url: string;+ readonly onError: () => void;+ readonly 'data-flx': string;+}++function AuthBrandLogoImage({url, onError, 'data-flx': dataFlx}: AuthBrandLogoImageProps): React.ReactElement {+ const [ratio, setRatio] = useState<number | null>(null);+ const style = useMemo(() => ({'--auth-brand-logo-ratio': ratio ?? 1}) as React.CSSProperties, [ratio]);+ return (+ <img+ className={styles.logo}+ style={style}+ src={url}+ alt=""+ width={LOGO_BOX_PX}+ height={LOGO_BOX_PX}+ draggable={false}+ decoding="async"+ referrerPolicy="no-referrer"+ onLoad={(event) => {+ const {naturalWidth, naturalHeight} = event.currentTarget;+ setRatio(naturalWidth > 0 && naturalHeight > 0 ? naturalWidth / naturalHeight : 1);+ }}+ onError={onError}+ data-pending={ratio == null ? '' : undefined}+ data-flx={dataFlx}+ />+ );+}++export function AuthBrandPanel({brand, logo, onLogoError, layout}: AuthBrandPanelProps): React.ReactElement {+ const [failedWordmarkUrl, setFailedWordmarkUrl] = useState<string | null>(null);+ const wordmarkUrl = brand.wordmarkUrl === failedWordmarkUrl ? null : brand.wordmarkUrl;+ const wordmarkBranding = useMemo<WordmarkBranding>(+ () => ({productName: brand.productName, wordmarkUrl}),+ [brand.productName, wordmarkUrl],+ );+ const handleWordmarkError = useCallback(() => setFailedWordmarkUrl(brand.wordmarkUrl), [brand.wordmarkUrl]);+ const wordmarkIsText = wordmarkUrl == null && !brand.usesDefaultName;+ return (+ <flx-auth-card-brand+ className={flxElementClassName(+ styles.brand,+ layout === AuthBrandLayout.MOBILE ? styles.mobile : styles.card,+ layout === AuthBrandLayout.CARD && logo != null && styles.split,+ wordmarkIsText && styles.textTier,+ )}+ data-flx="auth.components.auth-brand-panel.brand"+ >+ <flx-auth-card-brand-identity+ className={flxElementClassName(styles.identity)}+ data-flx="auth.components.auth-brand-panel.identity"+ >+ {renderLogo(logo, onLogoError)}+ <FluxerWordmark+ className={styles.wordmark}+ style={WORDMARK_TEXT_STYLE}+ branding={wordmarkBranding}+ onImageError={handleWordmarkError}+ data-flx="auth.components.auth-brand-panel.wordmark"+ />+ </flx-auth-card-brand-identity>+ {brand.host == null ? null : (+ <span className={styles.host} dir="ltr" data-flx="auth.components.auth-brand-panel.host">+ {brand.host}+ </span>+ )}+ </flx-auth-card-brand>+ );+}diff --git a/fluxer_app/src/features/auth/flow/AuthBackground.tsx b/fluxer_app/src/features/auth/flow/AuthBackground.tsxindex 60d2c14f3..41417d04e 100644--- a/fluxer_app/src/features/auth/flow/AuthBackground.tsx+++ b/fluxer_app/src/features/auth/flow/AuthBackground.tsx@@ -3,7 +3,9 @@import styles from '@app/features/app/components/layout/AuthLayout.module.css';import {GuildSplashCardAlignment} from '@fluxer/constants/src/GuildConstants';import type {ValueOf} from '@fluxer/constants/src/ValueOf';+import clsx from 'clsx';import type React from 'react';+import {useState} from 'react';const getSplashObjectPosition = (alignment: ValueOf<typeof GuildSplashCardAlignment>) => {switch (alignment) {@@ -16,18 +18,61 @@ const getSplashObjectPosition = (alignment: ValueOf<typeof GuildSplashCardAlignm}};+export const AuthBackdropScrim = Object.freeze({+ CARD: 'card',+ MOBILE: 'mobile',+} as const);++export type AuthBackdropScrim = (typeof AuthBackdropScrim)[keyof typeof AuthBackdropScrim];+export interface AuthBackgroundProps {splashUrl: string | null;splashDimensions?: {width: number; height: number} | null;- patternImageUrl?: string | null;+ backdropUrl?: string | null;+ backdropScrim?: AuthBackdropScrim;className?: string;splashAlignment?: ValueOf<typeof GuildSplashCardAlignment>;}+interface AuthBackdropProps {+ url: string;+ scrim: AuthBackdropScrim;+}++function AuthBackdrop({url, scrim}: AuthBackdropProps): React.ReactElement | null {+ const [status, setStatus] = useState<'loading' | 'ready' | 'failed'>('loading');+ if (status === 'failed') {+ return null;+ }+ return (+ <div+ className={clsx(styles.backdropLayer, status === 'ready' && styles.backdropLayerReady)}+ data-flx="auth.flow.auth-background.backdrop"+ >+ <img+ className={styles.backdropImage}+ src={url}+ alt=""+ draggable={false}+ decoding="async"+ referrerPolicy="no-referrer"+ onLoad={() => setStatus('ready')}+ onError={() => setStatus('failed')}+ data-flx="auth.flow.auth-background.backdrop-image"+ />+ <div+ className={clsx(styles.backdropScrim, scrim === AuthBackdropScrim.MOBILE && styles.backdropScrimMobile)}+ data-flx="auth.flow.auth-background.backdrop-scrim"+ />+ </div>+ );+}+export const AuthBackground: React.FC<AuthBackgroundProps> = ({splashUrl,splashDimensions,- patternImageUrl,+ backdropUrl = null,+ backdropScrim = AuthBackdropScrim.CARD,className,splashAlignment = GuildSplashCardAlignment.CENTER,}) => {@@ -51,14 +96,16 @@ export const AuthBackground: React.FC<AuthBackgroundProps> = ({</div>);}- if (patternImageUrl != null) {+ if (splashUrl == null && backdropUrl != null) {return (- <div- className={className || styles.patternHost}- style={{backgroundImage: `url(${patternImageUrl})`}}- aria-hidden- data-flx="auth.flow.auth-background.pattern-host"- />+ <div className={clsx(className, styles.operatorBackdrop)} data-flx="auth.flow.auth-background.operator-backdrop">+ <AuthBackdrop+ key={backdropUrl}+ url={backdropUrl}+ scrim={backdropScrim}+ data-flx="auth.flow.auth-background.auth-backdrop"+ />+ </div>);}return null;diff --git a/fluxer_app/src/features/auth/flow/AuthCardContainer.tsx b/fluxer_app/src/features/auth/flow/AuthCardContainer.tsxindex 89c01369b..4ce198855 100644--- a/fluxer_app/src/features/auth/flow/AuthCardContainer.tsx+++ b/fluxer_app/src/features/auth/flow/AuthCardContainer.tsx@@ -15,6 +15,8 @@ interface AuthCardContainerProps {className?: string;cardClassName?: string;contentClassName?: string;+ brandPanel?: ReactNode;+ isSplit?: boolean;}const cardVariantClassNames: Record<AuthCardVariant, string | undefined> = {@@ -22,11 +24,6 @@ const cardVariantClassNames: Record<AuthCardVariant, string | undefined> = {standard: authLayoutStyles.cardStandard,compact: authLayoutStyles.cardCompact,};-const formSideVariantClassNames: Record<AuthCardVariant, string | undefined> = {- default: undefined,- standard: authLayoutStyles.formSideStandard,- compact: authLayoutStyles.formSideCompact,-};function resolveContainerClassName(isFullscreen: boolean, className: string | undefined): string {if (isFullscreen) {@@ -39,22 +36,26 @@ function resolveSurfaceClassName(isFullscreen: boolean,variant: AuthCardVariant,cardClassName: string | undefined,+ isBranded: boolean,+ isSplit: boolean,): string {if (isFullscreen) {return authLayoutStyles.fullscreenPassthrough;}- return clsx(authLayoutStyles.card, cardVariantClassNames[variant], cardClassName);+ return clsx(+ authLayoutStyles.card,+ cardVariantClassNames[variant],+ isBranded && authLayoutStyles.cardBranded,+ isBranded && isSplit && authLayoutStyles.cardSplit,+ cardClassName,+ );}-function resolveFormSideClassName(- isFullscreen: boolean,- variant: AuthCardVariant,- contentClassName: string | undefined,-): string {+function resolveFormSideClassName(isFullscreen: boolean, contentClassName: string | undefined): string {if (isFullscreen) {return authLayoutStyles.fullscreenPassthrough;}- return clsx(authLayoutStyles.formSide, formSideVariantClassNames[variant], contentClassName);+ return clsx(authLayoutStyles.formSide, contentClassName);}function renderCardContents(children: ReactNode, isInert: boolean): ReactNode {@@ -79,19 +80,25 @@ export function AuthCardContainer({className,cardClassName,contentClassName,+ brandPanel,+ isSplit = false,}: AuthCardContainerProps) {const isFullscreen = presentation === AuthLayoutContentMode.FULL;+ const isBranded = brandPanel != null && !isFullscreen;return (<flx-auth-cardclassName={flxElementClassName(resolveContainerClassName(isFullscreen, className))}data-flx="auth.flow.auth-card-container.div"><flx-auth-card-surface- className={flxElementClassName(resolveSurfaceClassName(isFullscreen, variant, cardClassName))}+ className={flxElementClassName(+ resolveSurfaceClassName(isFullscreen, variant, cardClassName, isBranded, isSplit),+ )}data-flx="auth.flow.auth-card-container.div--2">+ {isBranded ? brandPanel : null}<flx-auth-card-form-side- className={flxElementClassName(resolveFormSideClassName(isFullscreen, variant, contentClassName))}+ className={flxElementClassName(resolveFormSideClassName(isFullscreen, contentClassName))}data-flx="auth.flow.auth-card-container.div--4">{renderCardContents(children, isInert)}diff --git a/fluxer_app/src/features/auth/flow/AuthRouteLoadError.tsx b/fluxer_app/src/features/auth/flow/AuthRouteLoadError.tsxindex 5fc4d4798..8c0e61118 100644--- a/fluxer_app/src/features/auth/flow/AuthRouteLoadError.tsx+++ b/fluxer_app/src/features/auth/flow/AuthRouteLoadError.tsx@@ -1,6 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-or-later-import RuntimeConfig from '@app/features/app/state/RuntimeConfig';+import {getActiveInstanceProductName} from '@app/features/app/state/ActiveInstanceProductName';import styles from '@app/features/auth/flow/AuthPageStyles.module.css';import type {LoadableErrorProps} from '@app/features/platform/components/loadable/LoadableComponent';import {Button} from '@app/features/ui/button/Button';@@ -15,7 +15,9 @@ export function AuthRouteLoadError({retry}: LoadableErrorProps): React.JSX.Eleme<Trans>Could not load this page</Trans></div><div className={styles.errorText} data-flx="auth.flow.auth-route-load-error.text">- <Trans>Try again, or refresh {ph({productName: RuntimeConfig.productName})} if the problem continues.</Trans>+ <Trans>+ Try again, or refresh {ph({productName: getActiveInstanceProductName()})} if the problem continues.+ </Trans></div><div className={styles.disabledActions} data-flx="auth.flow.auth-route-load-error.actions"><Button onClick={retry} fitContainer data-flx="auth.flow.auth-route-load-error.retry">diff --git a/fluxer_app/src/features/auth/flow/AuthRuntimeTargetBoundary.tsx b/fluxer_app/src/features/auth/flow/AuthRuntimeTargetBoundary.tsxindex b06d0ac6e..84a3fce1b 100644--- a/fluxer_app/src/features/auth/flow/AuthRuntimeTargetBoundary.tsx+++ b/fluxer_app/src/features/auth/flow/AuthRuntimeTargetBoundary.tsx@@ -1,11 +1,21 @@// SPDX-License-Identifier: AGPL-3.0-or-laterimport InstanceSnapshotStore, {type RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';import {AuthRouteLoadError} from '@app/features/auth/flow/AuthRouteLoadError';import {AuthShellLoadingState} from '@app/features/auth/flow/AuthShellLoadingState';-import {AuthRuntimeTarget, AuthRuntimeTargetProvider} from '@app/features/auth/state/AuthRuntimeTarget';+import {useAuthLayoutContext} from '@app/features/auth/state/AuthLayoutContext';+import {+ AuthRuntimeTarget,+ AuthRuntimeTargetProvider,+ useAuthRuntimeTarget,+} from '@app/features/auth/state/AuthRuntimeTarget';+import {Logger} from '@app/features/platform/utils/AppLogger';import {getElectronAPI, isDesktop} from '@app/features/ui/utils/NativeUtils';-import {type ReactNode, useCallback, useEffect, useReducer, useState} from 'react';+import {observer} from 'mobx-react-lite';+import {type ReactNode, useCallback, useEffect, useLayoutEffect, useReducer, useState} from 'react';++const logger = new Logger('AuthRuntimeTargetBoundary');const AuthRuntimeResolutionStatus = Object.freeze({LOADING: 'loading',@@ -147,6 +157,13 @@ function browserAuthDocumentOrigin(): string {async function resolveBrowserAuthRuntime(signal: AbortSignal): Promise<RuntimeConfigSnapshot> {const resolution = await InstanceSnapshotStore.resolve({input: browserAuthDocumentOrigin(), signal});+ if (RuntimeConfig.getSnapshotOrNull() === null) {+ try {+ RuntimeConfig.applySnapshot(resolution.snapshot);+ } catch (error) {+ logger.warn('Failed to activate the instance this page belongs to:', error);+ }+ }return resolution.snapshot;}@@ -171,6 +188,10 @@ export async function warmAuthRuntimeTarget(signal: AbortSignal): Promise<Runtimreturn runtime;}+export async function readyBrowserAuthRuntime(signal: AbortSignal): Promise<RuntimeConfigSnapshot> {+ return readWarmBrowserAuthRuntime()?.runtime ?? (await resolveBrowserAuthRuntime(signal));+}+function readWarmDesktopAuthRuntime(): {readonly runtime: RuntimeConfigSnapshot | null} | null {return readWarmAuthRuntime(true);}@@ -183,6 +204,16 @@ function readWarmBrowserAuthRuntime(): {readonly runtime: RuntimeConfigSnapshot}return {runtime: warm.runtime};}+const AuthBrandSnapshotReporter = observer(function AuthBrandSnapshotReporter() {+ const {snapshot} = useAuthRuntimeTarget();+ const {setBrandSnapshot} = useAuthLayoutContext();+ useLayoutEffect(() => {+ setBrandSnapshot(snapshot);+ }, [setBrandSnapshot, snapshot]);+ useLayoutEffect(() => () => setBrandSnapshot(null), [setBrandSnapshot]);+ return null;+});+function ResolvedDesktopAuthRuntimeTargetBoundary({snapshot,children,@@ -196,6 +227,7 @@ function ResolvedDesktopAuthRuntimeTargetBoundary({target={target}data-flx="auth.flow.auth-runtime-target-boundary.resolved-desktop-auth-runtime-target-boundary.auth-runtime-target-provider">+ <AuthBrandSnapshotReporter data-flx="auth.flow.auth-runtime-target-boundary.auth-brand-snapshot-reporter" />{children}</AuthRuntimeTargetProvider>);@@ -208,12 +240,13 @@ function ResolvedBrowserAuthRuntimeTargetBoundary({readonly snapshot: RuntimeConfigSnapshot;readonly children: ReactNode;}) {- const [target] = useState(() => AuthRuntimeTarget.forBrowserDocument(snapshot));+ const [target] = useState(() => AuthRuntimeTarget.forFixedInstance(snapshot));return (<AuthRuntimeTargetProvidertarget={target}data-flx="auth.flow.auth-runtime-target-boundary.resolved-browser-auth-runtime-target-boundary.auth-runtime-target-provider">+ <AuthBrandSnapshotReporter data-flx="auth.flow.auth-runtime-target-boundary.auth-brand-snapshot-reporter" />{children}</AuthRuntimeTargetProvider>);diff --git a/fluxer_app/src/features/auth/flow/AuthShellLoadingState.tsx b/fluxer_app/src/features/auth/flow/AuthShellLoadingState.tsxindex c3283f260..4b3c6aa9f 100644--- a/fluxer_app/src/features/auth/flow/AuthShellLoadingState.tsx+++ b/fluxer_app/src/features/auth/flow/AuthShellLoadingState.tsx@@ -1,14 +1,19 @@// SPDX-License-Identifier: AGPL-3.0-or-later+import {resolveLayoutAuthBrand} from '@app/features/app/components/layout/AuthShell';import {welcomeTextForLocale} from '@app/features/app/components/setup/SetupWizardWelcomeRotation';import {AuthShellHintKind,type AuthShellPlaceholder,+ BRAND_ROW_CARD_PX,+ BRAND_ROW_MOBILE_PX,readAuthShellPlaceholderEnvironment,resolveAuthShellPlaceholder,resolveAuthShellRowCount,} from '@app/features/app/components/skeleton/AuthShellHint';+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';import {AuthLoadingState} from '@app/features/auth/flow/AuthLoadingState';+import {authBrandHasLogo} from '@app/features/auth/InstanceBranding';import {AuthLayoutContentMode, useAuthLayoutContext} from '@app/features/auth/state/AuthLayoutContext';import {useLocation} from '@app/features/platform/components/router/RouterReact';import {getRemScaleForDocument} from '@app/features/theme/layout/RemFromPx';@@ -34,7 +39,12 @@ function remFromPx(px: number): string {function resolveModel(pathname: string): AuthShellLoadingModel {const mobile = isMobileExperienceEnabled();- const placeholder = resolveAuthShellPlaceholder(pathname, readAuthShellPlaceholderEnvironment(mobile));+ const environment = readAuthShellPlaceholderEnvironment(mobile);+ const brand = resolveLayoutAuthBrand(RuntimeConfig.getSnapshotOrNull());+ const placeholder = resolveAuthShellPlaceholder(+ pathname,+ brand == null ? environment : {...environment, narrowBrand: !authBrandHasLogo(brand)},+ );return {mobile,placeholder,@@ -87,8 +97,8 @@ export function AuthShellLoadingState(): JSX.Element {);}const height = model.mobile- ? remFromPx(placeholder.heightPx)- : `calc(${remFromPx(placeholder.heightPx)} - ${CARD_CHROME})`;+ ? remFromPx(placeholder.heightPx - BRAND_ROW_MOBILE_PX)+ : `calc(${remFromPx(placeholder.heightPx - (placeholder.split ? 0 : BRAND_ROW_CARD_PX))} - ${CARD_CHROME})`;return (<divclassName="fluxer-boot-auth-load"diff --git a/fluxer_app/src/features/auth/hooks/useAuthBackground.ts b/fluxer_app/src/features/auth/hooks/useAuthBackground.tsindex 77af62a48..83467a6ee 100644--- a/fluxer_app/src/features/auth/hooks/useAuthBackground.ts+++ b/fluxer_app/src/features/auth/hooks/useAuthBackground.ts@@ -8,32 +8,10 @@ interface ImageDimensions {height: number;}-interface PatternImageLoaderResult {- patternReady: boolean;-}-interface SplashImageLoaderResult {dimensions: ImageDimensions | null;}-interface AuthBackgroundResult {- patternReady: boolean;- splashDimensions: ImageDimensions | null;-}--export function usePatternImageLoader(patternUrl: string): PatternImageLoaderResult {- const [patternReady, setPatternReady] = useState(() => ImageCacheUtils.hasImage(patternUrl));- useEffect(() => {- if (ImageCacheUtils.hasImage(patternUrl)) {- setPatternReady(true);- return;- }- setPatternReady(false);- return ImageCacheUtils.loadImage(patternUrl, () => setPatternReady(true));- }, [patternUrl]);- return {patternReady};-}-export function useSplashImageLoader(imageUrl: string | null): SplashImageLoaderResult {const [dimensions, setDimensions] = useState<ImageDimensions | null>(() => ImageCacheUtils.getImageSize(imageUrl) ?? null,@@ -54,12 +32,3 @@ export function useSplashImageLoader(imageUrl: string | null): SplashImageLoader}, [imageUrl]);return {dimensions};}--export function useAuthBackground(splashUrl: string | null, patternUrl: string): AuthBackgroundResult {- const {patternReady} = usePatternImageLoader(patternUrl);- const {dimensions: splashDimensions} = useSplashImageLoader(splashUrl);- return {- patternReady,- splashDimensions,- };-}diff --git a/fluxer_app/src/features/auth/state/AuthLayoutContext.ts b/fluxer_app/src/features/auth/state/AuthLayoutContext.tsindex 5ea4e77cf..42fcb6371 100644--- a/fluxer_app/src/features/auth/state/AuthLayoutContext.ts+++ b/fluxer_app/src/features/auth/state/AuthLayoutContext.ts@@ -1,5 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-or-later+import type {RuntimeConfigSnapshot} from '@app/features/app/state/RuntimeConfigSnapshot';import type {GuildSplashCardAlignmentValue} from '@fluxer/constants/src/GuildConstants';import React, {useContext} from 'react';@@ -20,6 +21,7 @@ export type AuthLayoutContentMode = (typeof AuthLayoutContentMode)[keyof typeofexport interface AuthLayoutContextType {setSplashUrl: (url: string | null) => void;+ setBrandSnapshot: (snapshot: RuntimeConfigSnapshot | null) => void;setCardVariant: React.Dispatch<React.SetStateAction<AuthCardVariant>>;setContentMode: React.Dispatch<React.SetStateAction<AuthLayoutContentMode>>;setSplashCardAlignment: React.Dispatch<React.SetStateAction<GuildSplashCardAlignmentValue>>;diff --git a/fluxer_app/src/features/auth/state/AuthRuntimeTarget.tsx b/fluxer_app/src/features/auth/state/AuthRuntimeTarget.tsxindex a14ce94c7..5903f1f43 100644--- a/fluxer_app/src/features/auth/state/AuthRuntimeTarget.tsx+++ b/fluxer_app/src/features/auth/state/AuthRuntimeTarget.tsx@@ -18,7 +18,7 @@ type AuthRuntimeTargetPolicy =readonly initialSnapshot: RuntimeConfigSnapshot | null;}| {- readonly kind: 'browser-document';+ readonly kind: 'fixed-instance';readonly snapshot: RuntimeConfigSnapshot;readonly instanceKey: string;};@@ -47,9 +47,9 @@ export class AuthRuntimeTarget {return new AuthRuntimeTarget({kind: 'instance-selection', initialSnapshot: snapshot});}- static forBrowserDocument(snapshot: RuntimeConfigSnapshot): AuthRuntimeTarget {+ static forFixedInstance(snapshot: RuntimeConfigSnapshot): AuthRuntimeTarget {return new AuthRuntimeTarget({- kind: 'browser-document',+ kind: 'fixed-instance',snapshot,instanceKey: requireAuthRuntimeInstanceKey(snapshot),});@@ -57,14 +57,18 @@ export class AuthRuntimeTarget {select(snapshot: RuntimeConfigSnapshot): void {const instanceKey = requireAuthRuntimeInstanceKey(snapshot);- if (this.policy.kind === 'browser-document' && instanceKey !== this.policy.instanceKey) {+ if (this.policy.kind === 'fixed-instance' && instanceKey !== this.policy.instanceKey) {throw new Error(- `Browser authentication cannot target instance "${instanceKey}" from document instance "${this.policy.instanceKey}"`,+ `Authentication fixed to instance "${this.policy.instanceKey}" cannot target instance "${instanceKey}"`,);}this.snapshot = snapshot;}+ get canChangeInstance(): boolean {+ return this.policy.kind === 'instance-selection';+ }+reset(): void {this.snapshot = this.initialSnapshot;}diff --git a/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.module.css b/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.module.cssindex 95f10618d..35770541d 100644--- a/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.module.css+++ b/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.module.css@@ -3,9 +3,9 @@.previewModal {position: fixed;top: 0;- right: 0;+ inset-inline-end: 0;bottom: 0;- left: 0;+ inset-inline-start: 0;width: 100% !important;height: 100% !important;max-width: 100% !important;@@ -15,7 +15,7 @@border: none !important;border-radius: 0 !important;box-shadow: none !important;- background: var(--brand-primary);+ background: #080616;display: flex;flex-direction: column;overflow: hidden;@@ -60,11 +60,10 @@}.previewContent {- position: relative;+ composes: spaceBackground from '@app/features/ui/space_background/SpaceBackground.module.css';flex: 1 1 auto;display: flex;overflow: hidden;- background-color: var(--brand-primary);min-height: 0;}diff --git a/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.tsx b/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.tsxindex 5f75b66c5..084a6f7c2 100644--- a/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.tsx+++ b/fluxer_app/src/features/invite/components/modals/InvitePagePreviewModal.tsx@@ -8,7 +8,7 @@ import {AuthCardContainer} from '@app/features/auth/flow/AuthCardContainer';import authPageStyles from '@app/features/auth/flow/AuthPageStyles.module.css';import {PreviewGuildInviteHeader} from '@app/features/auth/flow/InviteHeader';import {MockMinimalRegisterForm} from '@app/features/auth/flow/MockMinimalRegisterForm';-import {useAuthBackground} from '@app/features/auth/hooks/useAuthBackground';+import {useSplashImageLoader} from '@app/features/auth/hooks/useAuthBackground';import Guilds from '@app/features/guild/state/Guilds';import styles from '@app/features/invite/components/modals/InvitePagePreviewModal.module.css';import GuildMembers from '@app/features/member/state/GuildMembers';@@ -18,7 +18,6 @@ import {CardAlignmentControls} from '@app/features/ui/card_alignment_controls/Caimport * as ModalCommands from '@app/features/ui/commands/ModalCommands';import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';import Window from '@app/features/window/state/Window';-import foodPatternUrl from '@app/media/images/i-like-food.svg';import type {GuildSplashCardAlignmentValue} from '@fluxer/constants/src/GuildConstants';import {GuildSplashCardAlignment} from '@fluxer/constants/src/GuildConstants';import {msg} from '@lingui/core/macro';@@ -61,8 +60,7 @@ export const InvitePagePreviewModal: React.FC<InvitePagePreviewModalProps> = obs}return null;}, [previewSplashUrl, guild?.id, guild?.splash]);- const {patternReady, splashDimensions} = useAuthBackground(splashUrl, foodPatternUrl);- const shouldShowSplash = Boolean(splashUrl && splashDimensions);+ const {dimensions: splashDimensions} = useSplashImageLoader(splashUrl);const handleClose = useCallback(() => {ModalCommands.pop();}, []);@@ -120,10 +118,9 @@ export const InvitePagePreviewModal: React.FC<InvitePagePreviewModalProps> = obs</div><div className={styles.previewContent} data-flx="invite.invite-page-preview-modal.preview-content"><AuthBackground- className={clsx(styles.background, !shouldShowSplash && authLayoutStyles.patternHost)}+ className={styles.background}splashUrl={splashUrl}splashDimensions={splashDimensions}- patternImageUrl={patternReady ? foodPatternUrl : null}splashAlignment={splashAlignment}data-flx="invite.invite-page-preview-modal.background"/>