Ratatoskr/src/app/features/room/RoomTrainingLine.tsx
Void 06d530d061 Phone: light ink for the training notice over the dark ridge (day, dusk)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 18:26:01 +00:00

33 lines
1.1 KiB
TypeScript

import { Text, color, config } from 'folds';
import { Room } from 'matrix-js-sdk';
import React from 'react';
import { useStateEvent } from '../../hooks/useStateEvent';
import { useClientConfig } from '../../hooks/useClientConfig';
import { useSkyInk } from '../../hooks/useTheme';
import { noticeInk } from '../scene/skyInk';
import {
ROOM_NOTICE_EVENT_TYPE,
parseRoomNotice,
roomTrainingLine,
} from '../../utils/trainingNotice';
// The room's notice state event decides the line; no event, or a malformed one, no line. The
// collector reads the version from the same event, so nothing is stored in the browser.
export function RoomTrainingLine({ room }: { room: Room }) {
const event = useStateEvent(room, ROOM_NOTICE_EVENT_TYPE);
const { previewDemo } = useClientConfig();
const skyInk = useSkyInk();
const line = roomTrainingLine(parseRoomNotice(event?.getContent()), previewDemo);
if (!line) return null;
return (
<Text
size="T200"
style={{
padding: `${config.space.S100} 0`,
color: (skyInk && noticeInk(skyInk)) ?? color.SurfaceVariant.OnContainer,
}}
>
{line}
</Text>
);
}