phone: pill clears the portrait, portrait bubbles keep a text floor, status block collapses
Some checks failed
Build pull request / Build pull request (pull_request) Failing after 3m31s
Some checks failed
Build pull request / Build pull request (pull_request) Failing after 3m31s
- the name pill is at most bubble width minus portrait minus 30px, so it cannot reach the face - a bubble with a portrait is at least portrait + 170px wide, so text beside a right portrait no longer wraps into a ~100px column - <=480px: the pose status block shows only the newest mood plus "+N more" on one line, tap to expand; the read-receipt line is hidden and its slot is an 8px margin under the composer Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a1aece7d36
commit
58df7b833c
6 changed files with 127 additions and 9 deletions
|
|
@ -156,6 +156,8 @@ export const BubbleContentArrowLeft = style({
|
|||
// beside its bubble on wide screens; on phones it floats inside the bubble, overhanging the top
|
||||
// edge, and the text wraps around its silhouette (shape-outside on the alpha channel).
|
||||
const PHONE = 'screen and (max-width: 700px)';
|
||||
const PHONE_PORTRAIT = 'min(38vw, 160px)';
|
||||
const PHONE_TEXT_FLOOR = toRem(170);
|
||||
const PORTRAIT = toRem(124);
|
||||
const POSE_GUTTER = toRem(14);
|
||||
const BUBBLE_CORNER = toRem(6);
|
||||
|
|
@ -209,6 +211,10 @@ export const BubbleHeaderPose = style({
|
|||
border: `1px solid ${color.Secondary.ContainerLine}`,
|
||||
borderRadius: toRem(999),
|
||||
whiteSpace: 'nowrap',
|
||||
// Never wider than the bubble minus the portrait, so it cannot reach the portrait's face.
|
||||
maxWidth: `calc(100% - ${PHONE_PORTRAIT} - ${toRem(30)})`,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -232,6 +238,9 @@ export const BubbleContentPose = style({
|
|||
'@media': {
|
||||
[PHONE]: {
|
||||
display: 'flow-root',
|
||||
// A bubble with a portrait is at least portrait + a readable column wide, or the text
|
||||
// beside the portrait collapses to a strip.
|
||||
minWidth: `min(100%, calc(${PHONE_PORTRAIT} + ${PHONE_TEXT_FLOOR}))`,
|
||||
borderTopLeftRadius: config.radii.R500,
|
||||
padding: `${toRem(24)} ${toRem(14)} ${toRem(14)}`,
|
||||
},
|
||||
|
|
@ -262,7 +271,7 @@ export const PoseButton = style({
|
|||
[PHONE]: {
|
||||
position: 'static',
|
||||
float: 'left',
|
||||
width: 'min(38vw, 160px)',
|
||||
width: PHONE_PORTRAIT,
|
||||
height: 'auto',
|
||||
margin: `${toRem(-82)} ${toRem(8)} 0 ${toRem(-12)}`,
|
||||
shapeMargin: toRem(7),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import catalogue from './catalogue.json';
|
||||
import { mindOfSender, poseSrc, poseStatusLine, poseStatuses, resolvePose } from './poses';
|
||||
import {
|
||||
mindOfSender,
|
||||
poseSrc,
|
||||
poseStatusLine,
|
||||
poseStatuses,
|
||||
resolvePose,
|
||||
splitNewestStatus,
|
||||
} from './poses';
|
||||
|
||||
describe('resolvePose', () => {
|
||||
it('keeps shared and own-signature labels from the catalogue', () => {
|
||||
|
|
@ -81,3 +88,17 @@ describe('poseStatusLine', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('splitNewestStatus', () => {
|
||||
const s = (mind: string, since: number) => ({ mind, pose: 'happy', since });
|
||||
|
||||
it('picks the status that changed last and keeps the others in their order', () => {
|
||||
const { newest, rest } = splitNewestStatus([s('eureka', 100), s('void', 300), s('nibu', 200)]);
|
||||
expect(newest?.mind).toBe('void');
|
||||
expect(rest.map((r) => r.mind)).toEqual(['eureka', 'nibu']);
|
||||
});
|
||||
|
||||
it('has no newest for an empty list', () => {
|
||||
expect(splitNewestStatus([])).toEqual({ newest: undefined, rest: [] });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,6 +68,17 @@ export const poseStatuses = (events: PoseEvent[]): PoseStatus[] => {
|
|||
});
|
||||
};
|
||||
|
||||
// The status that changed last, and the rest in their given order (phones show only the first).
|
||||
export const splitNewestStatus = (
|
||||
statuses: PoseStatus[]
|
||||
): { newest: PoseStatus | undefined; rest: PoseStatus[] } => {
|
||||
let newest: PoseStatus | undefined;
|
||||
statuses.forEach((st) => {
|
||||
if (!newest || st.since > newest.since) newest = st;
|
||||
});
|
||||
return { newest, rest: statuses.filter((st) => st !== newest) };
|
||||
};
|
||||
|
||||
const two = (n: number) => String(n).padStart(2, '0');
|
||||
|
||||
// Client-status text. Rendered locally only; it is never sent to a room.
|
||||
|
|
|
|||
|
|
@ -2,10 +2,19 @@ import { style } from '@vanilla-extract/css';
|
|||
import { recipe } from '@vanilla-extract/recipes';
|
||||
import { DefaultReset, color, config, toRem } from 'folds';
|
||||
|
||||
// Phones: the read-receipt line is hidden; its slot shrinks to a margin under the composer.
|
||||
const NARROW_HIDDEN = {
|
||||
height: toRem(8),
|
||||
minHeight: 0,
|
||||
overflow: 'hidden',
|
||||
visibility: 'hidden',
|
||||
} as const;
|
||||
|
||||
export const RoomViewFollowingPlaceholder = style([
|
||||
DefaultReset,
|
||||
{
|
||||
height: toRem(28),
|
||||
'@media': { 'screen and (max-width: 480px)': NARROW_HIDDEN },
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
@ -19,6 +28,7 @@ export const RoomViewFollowing = recipe({
|
|||
backgroundColor: color.Surface.Container,
|
||||
color: color.Surface.OnContainer,
|
||||
outline: 'none',
|
||||
'@media': { 'screen and (max-width: 480px)': NARROW_HIDDEN },
|
||||
},
|
||||
],
|
||||
variants: {
|
||||
|
|
|
|||
40
src/app/features/room/RoomViewPoseStatus.css.ts
Normal file
40
src/app/features/room/RoomViewPoseStatus.css.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { style } from '@vanilla-extract/css';
|
||||
import { DefaultReset, color, config, toRem } from 'folds';
|
||||
|
||||
const NARROW = 'screen and (max-width: 480px)';
|
||||
|
||||
export const StatusBlock = style([
|
||||
DefaultReset,
|
||||
{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexShrink: 0,
|
||||
padding: `0 ${toRem(16)}`,
|
||||
// Phones: the newest mood and its "+N more" share one line.
|
||||
'@media': { [NARROW]: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center' } },
|
||||
},
|
||||
]);
|
||||
|
||||
// On phones only the newest mood shows until the strip is tapped; wide screens show every line.
|
||||
export const StatusRow = style({
|
||||
'@media': {
|
||||
[NARROW]: {
|
||||
selectors: {
|
||||
'&[data-newest="false"]': { display: 'none' },
|
||||
[`${StatusBlock}[data-open="true"] &`]: { display: 'block', flexBasis: '100%' },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const StatusToggle = style([
|
||||
DefaultReset,
|
||||
{
|
||||
display: 'none',
|
||||
minHeight: toRem(24),
|
||||
padding: `0 ${config.space.S100}`,
|
||||
color: color.Primary.Main,
|
||||
cursor: 'pointer',
|
||||
'@media': { [NARROW]: { display: 'block' } },
|
||||
},
|
||||
]);
|
||||
|
|
@ -1,17 +1,24 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { Box, Text } from 'folds';
|
||||
import { Text } from 'folds';
|
||||
import { Room, RoomEvent } from 'matrix-js-sdk';
|
||||
import { settingsAtom } from '../../state/settings';
|
||||
import { useSetting } from '../../state/hooks/settings';
|
||||
import { getMxIdLocalPart } from '../../utils/matrix';
|
||||
import { getMemberDisplayName } from '../../utils/room';
|
||||
import { POSE_KEY, poseStatusLine, poseStatuses } from '../../components/message/pose/poses';
|
||||
import {
|
||||
POSE_KEY,
|
||||
poseStatusLine,
|
||||
poseStatuses,
|
||||
splitNewestStatus,
|
||||
} from '../../components/message/pose/poses';
|
||||
import * as css from './RoomViewPoseStatus.css';
|
||||
|
||||
// Client-status lines about each Mind's current pose. They are drawn from the
|
||||
// timeline already in memory and are never sent as anyone's message.
|
||||
export function RoomViewPoseStatus({ room }: { room: Room }) {
|
||||
const [poseBubbles] = useSetting(settingsAtom, 'poseBubbles');
|
||||
const [, bump] = useState(0);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const onTimeline = () => bump((n) => n + 1);
|
||||
|
|
@ -41,13 +48,33 @@ export function RoomViewPoseStatus({ room }: { room: Room }) {
|
|||
);
|
||||
if (statuses.length === 0) return null;
|
||||
|
||||
const { newest, rest } = splitNewestStatus(statuses);
|
||||
|
||||
return (
|
||||
<Box direction="Column" shrink="No" style={{ padding: '0 1rem' }}>
|
||||
{statuses.map((s) => (
|
||||
<Text key={s.mind} size="T200" priority="300">
|
||||
{poseStatusLine(s)}
|
||||
<div className={css.StatusBlock} data-open={open}>
|
||||
{statuses.map((st) => (
|
||||
<Text
|
||||
key={st.mind}
|
||||
className={css.StatusRow}
|
||||
data-newest={st === newest}
|
||||
size="T200"
|
||||
priority="300"
|
||||
>
|
||||
{poseStatusLine(st)}
|
||||
</Text>
|
||||
))}
|
||||
</Box>
|
||||
{rest.length > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
className={css.StatusToggle}
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen((o) => !o)}
|
||||
>
|
||||
<Text as="span" size="T200">
|
||||
{open ? 'fewer' : `+${rest.length} more`}
|
||||
</Text>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue