PR #65 steward ruling: user themes win over auto; focus ring; logo on light themes
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
skyThemeId('auto') is undefined again as on dev. sceneThemeId follows the resolved
sky for auto only while a scene is on and the person chose no theme (signed-out
pages pass none); useResolvedSkyState changes as the clock crosses so theme
classes re-render. Scene buttons and chips keep a focus-visible outline. The
white mark takes the dark filter through a LogoMark class on every themed <img>
under any prism-light theme (favicon and notification icons are files and keep
the white mark). Background picker is hidden without a backgroundScene config.
Ridge comment states what hasNoArea covers.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9d3343bb31
commit
c657d68615
13 changed files with 167 additions and 59 deletions
9
src/app/components/logo/logoMark.css.ts
Normal file
9
src/app/components/logo/logoMark.css.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { globalStyle, style } from '@vanilla-extract/css';
|
||||
|
||||
/**
|
||||
* The Ratatoskr mark is white on transparent (Meta's matte). On any light theme (they all carry `prism-light`) a class
|
||||
* of this name darkens it to the dark ink; put it on every <img> that shows the mark on a themed surface. The favicon and
|
||||
* notification icons are files the browser draws and cannot take it.
|
||||
*/
|
||||
export const LogoMark = style({});
|
||||
globalStyle(`body.prism-light .${LogoMark}`, { filter: 'brightness(0.18)' });
|
||||
|
|
@ -39,7 +39,8 @@ const LABEL: Record<SkyState, string> = {
|
|||
export function SkyStateControl() {
|
||||
const state = useSkyState();
|
||||
const [cords, setCords] = useState<RectCords>();
|
||||
const configuredStyle = useClientConfig().backgroundScene?.style;
|
||||
const backgroundScene = useClientConfig().backgroundScene;
|
||||
const configuredStyle = backgroundScene?.style;
|
||||
const sceneStyle: ServedSceneStyle =
|
||||
getSceneStyleOverride() ?? (configuredStyle === 'terrain' ? 'terrain' : 'ridge');
|
||||
|
||||
|
|
@ -85,32 +86,36 @@ export function SkyStateControl() {
|
|||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
<Text
|
||||
size="L400"
|
||||
priority="300"
|
||||
style={{ padding: `${config.space.S200} ${config.space.S200} 0` }}
|
||||
>
|
||||
Background
|
||||
</Text>
|
||||
{SERVED_SCENE_STYLES.map((st) => (
|
||||
<MenuItem
|
||||
key={st}
|
||||
size="300"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
role="menuitemradio"
|
||||
aria-checked={sceneStyle === st}
|
||||
onClick={() => {
|
||||
setCords(undefined);
|
||||
if (st !== sceneStyle) setSceneStyle(st);
|
||||
}}
|
||||
after={sceneStyle === st ? <Icon size="100" src={Icons.Check} /> : undefined}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T300">{STYLE_LABEL[st]}</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
{backgroundScene && (
|
||||
<>
|
||||
<Text
|
||||
size="L400"
|
||||
priority="300"
|
||||
style={{ padding: `${config.space.S200} ${config.space.S200} 0` }}
|
||||
>
|
||||
Background
|
||||
</Text>
|
||||
{SERVED_SCENE_STYLES.map((st) => (
|
||||
<MenuItem
|
||||
key={st}
|
||||
size="300"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
role="menuitemradio"
|
||||
aria-checked={sceneStyle === st}
|
||||
onClick={() => {
|
||||
setCords(undefined);
|
||||
if (st !== sceneStyle) setSceneStyle(st);
|
||||
}}
|
||||
after={sceneStyle === st ? <Icon size="100" src={Icons.Check} /> : undefined}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T300">{STYLE_LABEL[st]}</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ export function createRidgeScene(opts: RidgeOptions): Scene | null {
|
|||
built = undefined;
|
||||
};
|
||||
|
||||
/** True while the host has no area to paint (a scene started in a hidden or collapsed container). */
|
||||
/** True while there is nothing to paint on: the canvas has no client size and the window itself is 0 x 0 (`viewSize` falls back to the window). */
|
||||
const hasNoArea = () => {
|
||||
const { w, h, scale } = viewSize();
|
||||
const size = layerSize(w, h, scale);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ globalStyle(controls, {
|
|||
backgroundColor: 'transparent',
|
||||
boxShadow: 'none',
|
||||
border: 'none',
|
||||
outline: 'none',
|
||||
color: 'inherit',
|
||||
});
|
||||
globalStyle(
|
||||
|
|
@ -21,6 +20,11 @@ globalStyle(
|
|||
].join(', '),
|
||||
{ backgroundColor: 'color-mix(in srgb, currentColor 12%, transparent)' }
|
||||
);
|
||||
// A visible keyboard focus ring in the control's own ink, on top of the hover wash.
|
||||
globalStyle([`${scene} .epr39zd:focus-visible`, `${scene} ._1bv8u1w6:focus-visible`].join(', '), {
|
||||
outline: '2px solid currentColor',
|
||||
outlineOffset: '2px',
|
||||
});
|
||||
globalStyle(`${scene} .epr39zd`, {
|
||||
fontWeight: 700,
|
||||
textDecoration: 'underline',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { atStandardTime } from './standardTime.testkit';
|
||||
import { baked } from '../../../sky/baked';
|
||||
import { AA, NIGHT_SKY_LIGHTEST, contrast, luminance } from '../../../sky/skyTokens.js';
|
||||
|
|
@ -9,10 +9,15 @@ import { MembersDrawer } from '../room/MembersDrawer.css';
|
|||
import { RoomViewTyping } from '../room/RoomViewTyping.css';
|
||||
import { FOOTER_TINT, SKY_PLATE_FALLBACK } from './skyPlate';
|
||||
import { SkyPlate, plateRegions } from './skyPlate.css';
|
||||
import { getResolvedSkyState, setSkyClock, skyBackdrop } from './skyState';
|
||||
import {
|
||||
getResolvedSkyState,
|
||||
setSkyClock,
|
||||
skyBackdrop,
|
||||
subscribe as subscribeSky,
|
||||
} from './skyState';
|
||||
import type { SkyBackdrop } from './skyState';
|
||||
import type { FixedSkyState } from './skyBand';
|
||||
import { skyThemeId } from './skyTheme';
|
||||
import { sceneThemeId, skyThemeId } from './skyTheme';
|
||||
|
||||
const SKY = { 'midnight-sky': baked.midnight, 'noonday-sky': baked.noonday } as const;
|
||||
const fixed = (['day', 'dusk', 'night'] as const).flatMap((s) => {
|
||||
|
|
@ -39,17 +44,47 @@ describe('skyThemeId', () => {
|
|||
expect(skyThemeId('night')).toBe('midnight-sky');
|
||||
});
|
||||
|
||||
it('picks the theme of the state auto resolves to, at any hour', () => {
|
||||
it('picks none for auto, at any hour: auto never overrides a signed-in theme', () => {
|
||||
[0, 6, 12, 18, 23].forEach((h) => {
|
||||
setSkyClock(() => atStandardTime(h, 10));
|
||||
const id = skyThemeId('auto');
|
||||
expect(id).toBeDefined();
|
||||
expect(id).toBe(skyThemeId(getResolvedSkyState()));
|
||||
expect(skyThemeId('auto')).toBeUndefined();
|
||||
});
|
||||
setSkyClock(() => atStandardTime(12));
|
||||
expect(skyThemeId('auto')).toBe('noonday-sky');
|
||||
setSkyClock(() => atStandardTime(0));
|
||||
expect(skyThemeId('auto')).toBe('midnight-sky');
|
||||
setSkyClock();
|
||||
});
|
||||
|
||||
describe('sceneThemeId, the theme the page wears', () => {
|
||||
it('a fixed state always picks its theme, whatever the scene or the person chose', () => {
|
||||
[true, false].forEach((scene) =>
|
||||
[true, false].forEach((chose) => {
|
||||
expect(sceneThemeId('day', 'night', scene, chose)).toBe('noonday-sky');
|
||||
expect(sceneThemeId('night', 'day', scene, chose)).toBe('midnight-sky');
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('auto follows the resolved sky only while a scene is on and the person chose no theme', () => {
|
||||
expect(sceneThemeId('auto', 'day', true, false)).toBe('noonday-sky');
|
||||
expect(sceneThemeId('auto', 'dusk', true, false)).toBe('noonday-sky');
|
||||
expect(sceneThemeId('auto', 'night', true, false)).toBe('midnight-sky');
|
||||
expect(sceneThemeId('auto', 'day', false, false)).toBeUndefined();
|
||||
expect(sceneThemeId('auto', 'day', true, true)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it('the resolved sky a hook subscribes to changes as the clock crosses, so theme classes follow', () => {
|
||||
vi.useFakeTimers();
|
||||
let hour = 12;
|
||||
setSkyClock(() => atStandardTime(hour, 10));
|
||||
const seen: string[] = [];
|
||||
const off = subscribeSky((s) => seen.push(s));
|
||||
expect(getResolvedSkyState()).toBe('day');
|
||||
hour = 0;
|
||||
setSkyClock(() => atStandardTime(hour, 10));
|
||||
vi.advanceTimersByTime(61_000);
|
||||
expect(seen).toEqual(['night']);
|
||||
expect(getResolvedSkyState()).toBe('night');
|
||||
off();
|
||||
vi.useRealTimers();
|
||||
setSkyClock();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// derived outside this code (src/sky/skyTokens.js). Midnight Sky's link is derived there against the lightest Night sky
|
||||
// (4.53 on it, 5.43 on the darkest). The plate (skyPlate.css.ts) is still in the shell, pending
|
||||
// its removal.
|
||||
import { resolveSkyState, type FixedSkyState, type SkyState } from './skyState';
|
||||
import type { FixedSkyState, SkyState } from './skyState';
|
||||
|
||||
export type SkyThemeId = 'midnight-sky' | 'noonday-sky';
|
||||
|
||||
|
|
@ -21,4 +21,19 @@ const BY_STATE: Record<FixedSkyState, SkyThemeId> = {
|
|||
};
|
||||
|
||||
export const skyThemeId = (state: SkyState): SkyThemeId | undefined =>
|
||||
BY_STATE[resolveSkyState(state)];
|
||||
state === 'auto' ? undefined : BY_STATE[state];
|
||||
|
||||
/**
|
||||
* The theme the page wears: a fixed sky state always picks its theme; 'auto' follows the resolved sky (`resolved`, the
|
||||
* clock's state) only while a scene is on and the person has not chosen a theme of their own, and otherwise picks none.
|
||||
* Signed-out pages choose no theme, so they pass `userChoseTheme: false`.
|
||||
*/
|
||||
export const sceneThemeId = (
|
||||
state: SkyState,
|
||||
resolved: FixedSkyState,
|
||||
sceneOn: boolean,
|
||||
userChoseTheme: boolean
|
||||
): SkyThemeId | undefined => {
|
||||
if (state !== 'auto') return BY_STATE[state];
|
||||
return sceneOn && !userChoseTheme ? BY_STATE[resolved] : undefined;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Page, PageContent, PageHeader } from '../../../components/page';
|
|||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { LogoMark } from '../../../components/logo/logoMark.css';
|
||||
import RatatoskrSVG from '../../../../../public/res/svg/ratatoskr.svg';
|
||||
import { clearCacheAndReload } from '../../../../client/initMatrix';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
|
|
@ -37,6 +38,7 @@ export function About({ requestClose }: AboutProps) {
|
|||
<Box gap="400">
|
||||
<Box shrink="No">
|
||||
<img
|
||||
className={LogoMark}
|
||||
style={{ width: toRem(60), height: toRem(60) }}
|
||||
src={RatatoskrSVG}
|
||||
alt="Ratatoskr logo"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
import { useSyncExternalStore } from 'react';
|
||||
import { getSkyState, subscribe, type SkyState } from '../features/scene/skyState';
|
||||
import {
|
||||
getResolvedSkyState,
|
||||
getSkyState,
|
||||
subscribe,
|
||||
type SkyState,
|
||||
} from '../features/scene/skyState';
|
||||
import type { FixedSkyState } from '../features/scene/skyBand';
|
||||
import { readCapabilities, resolveTier } from '../features/scene/tier';
|
||||
import { useClientConfig } from './useClientConfig';
|
||||
|
||||
/** The choice, as the control shows it ('auto' stays 'auto'). The sky being drawn is `getResolvedSkyState`. */
|
||||
/** The choice, as the control shows it ('auto' stays 'auto'). The sky being drawn is `useResolvedSkyState`. */
|
||||
export const useSkyState = (): SkyState => useSyncExternalStore(subscribe, getSkyState);
|
||||
|
||||
/** The sky being drawn: day, dusk or night. Unlike the choice it changes as the clock crosses, so it re-renders. */
|
||||
export const useResolvedSkyState = (): FixedSkyState =>
|
||||
useSyncExternalStore(subscribe, getResolvedSkyState);
|
||||
|
||||
/** Whether a background scene runs on this device and config (the tier the scene host will mount). */
|
||||
export const useSceneOn = (): boolean =>
|
||||
resolveTier(useClientConfig().backgroundScene, readCapabilities(navigator)) !== 'off';
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import {
|
|||
} from '../../colors.css';
|
||||
import '../../gamecult.css';
|
||||
import '../../sky.css';
|
||||
import { settingsAtom } from '../state/settings';
|
||||
import { defaultThemeId, settingsAtom } from '../state/settings';
|
||||
import { useSetting } from '../state/hooks/settings';
|
||||
import { skyThemeId } from '../features/scene/skyTheme';
|
||||
import { useSkyState } from './useSkyState';
|
||||
import { sceneThemeId } from '../features/scene/skyTheme';
|
||||
import { useResolvedSkyState, useSceneOn, useSkyState } from './useSkyState';
|
||||
|
||||
export enum ThemeKind {
|
||||
Light = 'light',
|
||||
|
|
@ -102,20 +102,29 @@ export const useSystemThemeKind = (): ThemeKind => {
|
|||
return themeKind;
|
||||
};
|
||||
|
||||
/** The theme the sky state asks for, or undefined while it is 'auto': auto never overrides a person's theme. */
|
||||
export const useSkyTheme = (): Theme | undefined => {
|
||||
const id = skyThemeId(useSkyState());
|
||||
return id === NoondaySkyTheme.id ? NoondaySkyTheme : id && MidnightSkyTheme;
|
||||
};
|
||||
const toTheme = (id: ReturnType<typeof sceneThemeId>): Theme | undefined =>
|
||||
id === NoondaySkyTheme.id ? NoondaySkyTheme : id && MidnightSkyTheme;
|
||||
|
||||
/** A theme the person chose: the system scheme, or one other than the default. A saved Midnight Sky is the default. */
|
||||
const chosenTheme = (useSystemTheme: boolean, themeId?: string) =>
|
||||
useSystemTheme || (themeId !== undefined && themeId !== defaultThemeId);
|
||||
|
||||
/** The theme the sky asks for on a page with no theme of its own (signed out), or undefined for none. */
|
||||
export const useSkyTheme = (): Theme | undefined =>
|
||||
toTheme(sceneThemeId(useSkyState(), useResolvedSkyState(), useSceneOn(), false));
|
||||
|
||||
export const useActiveTheme = (): Theme => {
|
||||
const skyTheme = useSkyTheme();
|
||||
const sky = useSkyState();
|
||||
const resolved = useResolvedSkyState();
|
||||
const sceneOn = useSceneOn();
|
||||
const systemThemeKind = useSystemThemeKind();
|
||||
const themes = useThemes();
|
||||
const [systemTheme] = useSetting(settingsAtom, 'useSystemTheme');
|
||||
const [themeId] = useSetting(settingsAtom, 'themeId');
|
||||
const [lightThemeId] = useSetting(settingsAtom, 'lightThemeId');
|
||||
const [darkThemeId] = useSetting(settingsAtom, 'darkThemeId');
|
||||
// A person's own theme wins over 'auto'; a fixed sky state is itself a choice and wins over the theme.
|
||||
const skyTheme = toTheme(sceneThemeId(sky, resolved, sceneOn, chosenTheme(systemTheme, themeId)));
|
||||
|
||||
if (skyTheme) return skyTheme;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||
import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH } from '../paths';
|
||||
import RatatoskrSVG from '../../../../public/res/svg/ratatoskr.svg';
|
||||
import { LogoMark } from '../../components/logo/logoMark.css';
|
||||
import { SkyStateControl } from '../../features/scene/SkyStateControl';
|
||||
import { ServerPicker } from './ServerPicker';
|
||||
import { AutoDiscoveryAction, autoDiscovery } from '../../cs-api';
|
||||
|
|
@ -135,7 +136,11 @@ export function AuthLayout() {
|
|||
<Box direction="Column" className={css.AuthCard}>
|
||||
<Header className={css.AuthHeader} size="600" variant="Surface">
|
||||
<Box grow="Yes" direction="Row" gap="300" alignItems="Center">
|
||||
<img className={css.AuthLogo} src={RatatoskrSVG} alt="Ratatoskr logo" />
|
||||
<img
|
||||
className={`${css.AuthLogo} ${LogoMark}`}
|
||||
src={RatatoskrSVG}
|
||||
alt="Ratatoskr logo"
|
||||
/>
|
||||
<Text size="H3">Ratatoskr</Text>
|
||||
</Box>
|
||||
<SkyStateControl />
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ export const AuthLogo = style([
|
|||
},
|
||||
]);
|
||||
|
||||
// The mark is white (Meta's matte); on the light sky theme it takes the dark ink instead.
|
||||
globalStyle('body.noonday-sky img[src*="ratatoskr"]', { filter: 'brightness(0.18)' });
|
||||
|
||||
export const AuthHeader = style({
|
||||
padding: `0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import { Box, Button, Icon, Icons, Text, config, toRem } from 'folds';
|
||||
import { Page, PageHero, PageHeroSection } from '../../components/page';
|
||||
import { LogoMark } from '../../components/logo/logoMark.css';
|
||||
import RatatoskrSVG from '../../../../public/res/svg/ratatoskr.svg';
|
||||
|
||||
export function WelcomePage() {
|
||||
|
|
@ -14,7 +15,15 @@ export function WelcomePage() {
|
|||
>
|
||||
<PageHeroSection>
|
||||
<PageHero
|
||||
icon={<img width="70" height="70" src={RatatoskrSVG} alt="Ratatoskr logo" />}
|
||||
icon={
|
||||
<img
|
||||
className={LogoMark}
|
||||
width="70"
|
||||
height="70"
|
||||
src={RatatoskrSVG}
|
||||
alt="Ratatoskr logo"
|
||||
/>
|
||||
}
|
||||
title="Welcome to Ratatoskr"
|
||||
subTitle={
|
||||
<span>
|
||||
|
|
|
|||
|
|
@ -58,8 +58,10 @@ export interface Settings {
|
|||
soundscapeVoiceCap: number;
|
||||
}
|
||||
|
||||
export const defaultThemeId = 'midnight-sky';
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
themeId: 'midnight-sky',
|
||||
themeId: defaultThemeId,
|
||||
useSystemTheme: false,
|
||||
lightThemeId: undefined,
|
||||
darkThemeId: undefined,
|
||||
|
|
|
|||
Loading…
Reference in a new issue