Move EventTile to shared components - #4c (#34697)
* Add missing placement state contract for root and line * Add editing, information and failure state * Add bubble placement from state * Add media and sticker line styling * Added reply chain styling * Add interactive stories for states and separate test confgis for baseline screenshots * Use shared components instead of mocks where available * Added more relevant slot content data * Add missing states and use presentation context * Add state styling * Fix irc layout dom ordering * Rearrange styling and add screenshots * Removed stale screenshots * Fix Sonar issue * Add missing layout rule styling and replace legacy application CSS variables * Updated snapshots * Minor changes to styling for bubble container and border radius defaults
@@ -63,7 +63,7 @@ exports[`MessagePanel should handle lots of membership events quickly 1`] = `
|
||||
</div>
|
||||
</li>
|
||||
<div
|
||||
class="_container_sq5fu_8 mx_EventTileBubble mx_HistoryTile"
|
||||
class="_container_sicoi_8 mx_EventTileBubble mx_HistoryTile"
|
||||
>
|
||||
<svg
|
||||
fill="currentColor"
|
||||
@@ -77,7 +77,7 @@ exports[`MessagePanel should handle lots of membership events quickly 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
<div
|
||||
class="_title_sq5fu_34"
|
||||
class="_title_sicoi_32"
|
||||
>
|
||||
You can't see earlier messages
|
||||
</div>
|
||||
|
||||
@@ -154,7 +154,7 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
|
||||
class="mx_NewRoomIntro"
|
||||
>
|
||||
<div
|
||||
class="_container_sq5fu_8 mx_EventTileBubble mx_cryptoEvent"
|
||||
class="_container_sicoi_8 mx_EventTileBubble mx_cryptoEvent"
|
||||
>
|
||||
<svg
|
||||
color="var(--cpd-color-icon-critical-primary)"
|
||||
@@ -169,12 +169,12 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
|
||||
/>
|
||||
</svg>
|
||||
<div
|
||||
class="_title_sq5fu_34"
|
||||
class="_title_sicoi_32"
|
||||
>
|
||||
End-to-end encryption isn't enabled
|
||||
</div>
|
||||
<div
|
||||
class="_subtitle_sq5fu_35"
|
||||
class="_subtitle_sicoi_33"
|
||||
>
|
||||
<span>
|
||||
|
||||
@@ -351,7 +351,7 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
|
||||
class="mx_NewRoomIntro"
|
||||
>
|
||||
<div
|
||||
class="_container_sq5fu_8 mx_EventTileBubble mx_cryptoEvent"
|
||||
class="_container_sicoi_8 mx_EventTileBubble mx_cryptoEvent"
|
||||
>
|
||||
<svg
|
||||
color="var(--cpd-color-icon-critical-primary)"
|
||||
@@ -366,12 +366,12 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
|
||||
/>
|
||||
</svg>
|
||||
<div
|
||||
class="_title_sq5fu_34"
|
||||
class="_title_sicoi_32"
|
||||
>
|
||||
End-to-end encryption isn't enabled
|
||||
</div>
|
||||
<div
|
||||
class="_subtitle_sq5fu_35"
|
||||
class="_subtitle_sicoi_33"
|
||||
>
|
||||
<span>
|
||||
|
||||
@@ -754,7 +754,7 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
|
||||
style="height: 400px;"
|
||||
>
|
||||
<div
|
||||
class="_container_sq5fu_8 mx_EventTileBubble mx_cryptoEvent _content_ufv8a_8"
|
||||
class="_container_sicoi_8 mx_EventTileBubble mx_cryptoEvent _content_ufv8a_8"
|
||||
>
|
||||
<svg
|
||||
data-state="supported"
|
||||
@@ -769,12 +769,12 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
|
||||
/>
|
||||
</svg>
|
||||
<div
|
||||
class="_title_sq5fu_34"
|
||||
class="_title_sicoi_32"
|
||||
>
|
||||
Encryption enabled
|
||||
</div>
|
||||
<div
|
||||
class="_subtitle_sq5fu_35"
|
||||
class="_subtitle_sicoi_33"
|
||||
>
|
||||
Messages in this chat will be end-to-end encrypted.
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
exports[`<RoomPredecessorTile /> Renders as expected 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="_container_sq5fu_8 mx_EventTileBubble mx_CreateEvent"
|
||||
class="_container_sicoi_8 mx_EventTileBubble mx_CreateEvent"
|
||||
>
|
||||
<svg
|
||||
fill="currentColor"
|
||||
@@ -17,12 +17,12 @@ exports[`<RoomPredecessorTile /> Renders as expected 1`] = `
|
||||
/>
|
||||
</svg>
|
||||
<div
|
||||
class="_title_sq5fu_34"
|
||||
class="_title_sicoi_32"
|
||||
>
|
||||
This room is a continuation of another conversation.
|
||||
</div>
|
||||
<div
|
||||
class="_subtitle_sq5fu_35"
|
||||
class="_subtitle_sicoi_33"
|
||||
>
|
||||
<a
|
||||
href="https://matrix.to/#/old_room_id/$tombstone_event_id"
|
||||
|
||||
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 41 KiB |
@@ -9,9 +9,7 @@
|
||||
background-color: var(--cpd-color-bg-subtle-secondary);
|
||||
padding: var(--cpd-space-3x);
|
||||
border-radius: 8px;
|
||||
/* Reserve space for external timestamps, but also cap the width */
|
||||
/* Legacy variable: --MessageTimestamp-width: 46px; /* 8 + 30 (avatar) + 8 */
|
||||
/* max-width: min(calc(100% - 2 * var(--MessageTimestamp-width)), 600px); */
|
||||
/* Reserve space for timestamps, but also cap the width. */
|
||||
max-width: min(calc(100% - 2 * 46px), 600px);
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
--event-tile-group-line-spacing-block-start: 1px;
|
||||
--event-tile-group-line-spacing-block-end: 3px;
|
||||
--event-tile-group-line-height: 22px;
|
||||
--event-tile-group-timestamp-width: 46px;
|
||||
|
||||
/* IRC geometry. */
|
||||
--event-tile-irc-line-height: 18px;
|
||||
@@ -19,11 +20,19 @@
|
||||
--event-tile-irc-icon-width: 14px;
|
||||
--event-tile-irc-timestamp-width: 48px;
|
||||
--event-tile-irc-right-padding: 5px;
|
||||
--event-tile-irc-info-offset: calc(
|
||||
var(--event-tile-irc-name-width) + var(--event-tile-irc-icon-width) + var(--event-tile-irc-right-padding)
|
||||
);
|
||||
|
||||
/* Bubble geometry. */
|
||||
--event-tile-bubble-corner-radius: 12px;
|
||||
--event-tile-bubble-gap: 5px;
|
||||
--event-tile-bubble-gutter: 11px;
|
||||
--event-tile-bubble-line-max-width: 70%;
|
||||
--event-tile-bubble-line-margin-inline-start: -9px;
|
||||
--event-tile-bubble-line-margin-inline-end: -12px;
|
||||
--event-tile-bubble-margin-inline-start: 49px;
|
||||
--event-tile-bubble-margin-inline-end: 60px;
|
||||
--event-tile-bubble-other-background: var(--cpd-color-gray-300, #e9edf2);
|
||||
--event-tile-bubble-self-background: var(--cpd-color-green-300, #d8f5ed);
|
||||
|
||||
@@ -37,7 +46,6 @@
|
||||
--event-tile-state-selected-background: var(--cpd-color-bg-subtle-secondary, #e9edf2);
|
||||
--event-tile-state-marker-width: 4px;
|
||||
--event-tile-state-marker-color: var(--cpd-color-bg-action-primary-rest, #0dbd8b);
|
||||
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
max-width: 100%;
|
||||
@@ -47,6 +55,10 @@
|
||||
&.stateContinuation {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
&.stateEditing .slotTimestamp {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
@@ -54,6 +66,25 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.root.stateInfo {
|
||||
font-size: var(--cpd-font-size-body-sm, 0.8125rem);
|
||||
color: var(--cpd-color-text-secondary, #737d86);
|
||||
}
|
||||
|
||||
.root.stateContextual {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.root.statePreviewClamped .slotBody,
|
||||
.root.statePreviewClamped .slotBody > * {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* Slot wrappers are the public styling boundary. The supplied content may be
|
||||
a component, fragment, or multiple elements and does not need to forward
|
||||
layout props. */
|
||||
@@ -77,6 +108,19 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.slotNotificationRoomLabel {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.slotFooter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-2x, 8px);
|
||||
}
|
||||
|
||||
/* Shared structural containers. */
|
||||
.senderDetails {
|
||||
display: flex;
|
||||
@@ -117,7 +161,8 @@
|
||||
}
|
||||
|
||||
&.stateSelected .line,
|
||||
&.stateEditing .line {
|
||||
&.stateEditing .line,
|
||||
&.stateActionBarFocused .line {
|
||||
background-color: var(--event-tile-state-selected-background);
|
||||
}
|
||||
|
||||
@@ -163,7 +208,7 @@
|
||||
.slotTimestamp {
|
||||
position: absolute;
|
||||
inset-inline-start: 0;
|
||||
width: var(--MessageTimestamp-width, 46px);
|
||||
width: var(--event-tile-group-timestamp-width);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -181,7 +226,19 @@
|
||||
|
||||
.slotReplyChain {
|
||||
margin-inline-start: 0;
|
||||
margin-bottom: var(--cpd-space-2x, 8px);
|
||||
margin-inline-end: 10px;
|
||||
}
|
||||
|
||||
.line,
|
||||
.slotReplyChain {
|
||||
position: relative;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* Reply-chain spacing belongs to the group shell; nested reply content
|
||||
remains application-owned. */
|
||||
&.stateHasReply .slotReplyChain {
|
||||
margin-block-end: var(--cpd-space-2x, 8px);
|
||||
}
|
||||
|
||||
.slotFooter {
|
||||
@@ -199,9 +256,127 @@
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Informational events use a smaller metadata row while retaining the
|
||||
normal group slot order. */
|
||||
&.stateInfo {
|
||||
padding-top: 0;
|
||||
|
||||
.slotAvatar,
|
||||
.slotPadlock {
|
||||
line-height: 1;
|
||||
margin-block: 3px 2px;
|
||||
}
|
||||
|
||||
.slotAvatar {
|
||||
inset-block-start: auto;
|
||||
inset-inline-start: var(--event-tile-group-gutter);
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.line {
|
||||
padding-block: 3px 2px;
|
||||
padding-inline-start: calc(var(--event-tile-group-gutter) + 20px);
|
||||
}
|
||||
|
||||
.slotTimestamp,
|
||||
.slotPadlock {
|
||||
inset-block-start: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.stateContinuation .line {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* The legacy bubble-container grid is a group-layout shell. The action
|
||||
bar remains intentionally inside the full-width line in this view, so
|
||||
its line-local absolute placement is owned by .slotActionBar. */
|
||||
&.stateBubbleContainer {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 100px;
|
||||
|
||||
.line {
|
||||
grid-column: 1 / 3;
|
||||
margin-inline-end: 0;
|
||||
padding: 0;
|
||||
padding-inline-start: var(--event-tile-group-gutter);
|
||||
}
|
||||
|
||||
> .slotReceipt {
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
.slotActionBar {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
&:hover .line {
|
||||
background: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
&.densityCompact {
|
||||
padding-top: var(--cpd-space-1x, 4px);
|
||||
|
||||
.line {
|
||||
padding-block: 0;
|
||||
}
|
||||
|
||||
.slotAvatar {
|
||||
inset-block-start: var(--cpd-space-0-5x, 2px);
|
||||
}
|
||||
|
||||
.slotPadlock {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.slotSender {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&.stateInfo {
|
||||
padding-top: 0;
|
||||
font-size: 13px;
|
||||
|
||||
.slotAvatar,
|
||||
.slotPadlock {
|
||||
inset-block-start: 0;
|
||||
margin-block: 0;
|
||||
}
|
||||
|
||||
.line {
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
&.stateEmote {
|
||||
padding-top: var(--cpd-space-2x, 8px);
|
||||
|
||||
.slotAvatar {
|
||||
inset-block-start: var(--cpd-space-0-5x, 2px);
|
||||
}
|
||||
|
||||
.line {
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
&.stateContinuation .line {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.stateContinuation {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.slotReplyChain {
|
||||
margin-block-end: var(--cpd-space-1x, 4px);
|
||||
}
|
||||
|
||||
.slotReceipt {
|
||||
inset-block-start: -2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* IRC layout. */
|
||||
@@ -221,7 +396,8 @@
|
||||
}
|
||||
|
||||
&.stateSelected .line,
|
||||
&.stateEditing .line {
|
||||
&.stateEditing .line,
|
||||
&.stateActionBarFocused .line {
|
||||
background-color: var(--event-tile-state-selected-background);
|
||||
}
|
||||
|
||||
@@ -292,29 +468,93 @@
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
padding-block: 1px;
|
||||
position: relative;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.slotReplyChain {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.slotBody,
|
||||
.slotPadlock {
|
||||
padding-block: 1px;
|
||||
}
|
||||
|
||||
.slotReceipt {
|
||||
order: 5;
|
||||
position: relative;
|
||||
inset-block-start: -0.3rem;
|
||||
}
|
||||
|
||||
.slotFooter {
|
||||
margin-block: var(--cpd-space-1-5x, 6px);
|
||||
}
|
||||
|
||||
&.stateBubbleContainer {
|
||||
align-items: center;
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
&.stateEmote .slotAvatar {
|
||||
margin-inline-start: calc(
|
||||
var(--event-tile-irc-name-width) + var(--event-tile-irc-icon-width) + var(--event-tile-irc-right-padding)
|
||||
);
|
||||
}
|
||||
|
||||
&.stateContinuation .line {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
&.stateInfo {
|
||||
padding-top: 0;
|
||||
|
||||
.slotAvatar {
|
||||
inset-block-start: 0;
|
||||
inset-inline-start: var(--event-tile-irc-info-offset);
|
||||
margin-inline-end: var(--event-tile-irc-right-padding);
|
||||
transform: translateY(-50%);
|
||||
margin-block-start: -2px;
|
||||
padding-block: 1px;
|
||||
}
|
||||
|
||||
.slotPadlock {
|
||||
inset-block-start: 0;
|
||||
}
|
||||
|
||||
.line {
|
||||
margin-inline-start: var(--event-tile-irc-info-offset);
|
||||
line-height: 12px;
|
||||
|
||||
.slotBody {
|
||||
width: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Bubble layout. */
|
||||
.root.layoutBubble {
|
||||
max-width: unset;
|
||||
margin-inline: var(--EventTile_bubble-margin-inline-start, 49px) var(--EventTile_bubble-margin-inline-end, 60px);
|
||||
margin-inline: var(--event-tile-bubble-margin-inline-start) var(--event-tile-bubble-margin-inline-end);
|
||||
padding-top: 0;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
inset: -1px calc(-1 * var(--EventTile_bubble-margin-inline-end, 60px)) -1px
|
||||
calc(-1 * var(--EventTile_bubble-margin-inline-start, 49px));
|
||||
inset: -1px calc(-1 * var(--event-tile-bubble-margin-inline-end)) -1px
|
||||
calc(-1 * var(--event-tile-bubble-margin-inline-start));
|
||||
border-radius: 4px;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -327,15 +567,47 @@
|
||||
width: fit-content;
|
||||
max-width: 70%;
|
||||
margin-block: 0;
|
||||
margin-inline: -9px -12px;
|
||||
margin-inline: var(--event-tile-bubble-line-margin-inline-start) var(--event-tile-bubble-line-margin-inline-end);
|
||||
border-radius: var(--event-tile-bubble-corner-radius) var(--event-tile-bubble-corner-radius) 0 0;
|
||||
line-height: 18px;
|
||||
position: relative;
|
||||
padding: calc(var(--event-tile-bubble-gutter) - 1px);
|
||||
padding-inline-end: 60px;
|
||||
background: var(--event-tile-bubble-other-background);
|
||||
border-end-end-radius: var(--event-tile-bubble-corner-radius);
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
inset-block-end: 0;
|
||||
inset-inline-end: 0;
|
||||
max-width: 80px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
/* Media bodies provide their own appearance and dimensions. The shell
|
||||
removes message padding while retaining the normal bubble width. */
|
||||
.lineMedia {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
max-width: var(--event-tile-bubble-line-max-width);
|
||||
}
|
||||
|
||||
.lineMedia.lineImage .slotTimestamp {
|
||||
border-radius: 8px;
|
||||
background-color: rgb(0 0 0 / 60%);
|
||||
color: #fff;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
/* Stickers are un-bubbled content, so their timestamp sits immediately
|
||||
after the line instead of over its lower-right corner. */
|
||||
.lineSticker .slotTimestamp {
|
||||
inset-inline-start: 100%;
|
||||
inset-inline-end: auto;
|
||||
}
|
||||
|
||||
.slotAvatar {
|
||||
position: absolute;
|
||||
z-index: 9;
|
||||
@@ -351,14 +623,10 @@
|
||||
box-shadow: 0 0 0 3px var(--cpd-color-bg-canvas-default, #fff);
|
||||
}
|
||||
|
||||
.slotSender,
|
||||
.line {
|
||||
.slotSender {
|
||||
width: fit-content;
|
||||
max-width: 70%;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.slotSender {
|
||||
position: relative;
|
||||
inset-block-start: -2px;
|
||||
inset-inline-start: 2px;
|
||||
@@ -366,14 +634,6 @@
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
inset-block-end: 0;
|
||||
inset-inline-end: 0;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
> .slotReceipt {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
@@ -398,7 +658,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-block: var(--cpd-space-1-5x, 6px);
|
||||
margin-inline: -9px -12px;
|
||||
margin-inline: var(--event-tile-bubble-line-margin-inline-start) var(--event-tile-bubble-line-margin-inline-end);
|
||||
}
|
||||
|
||||
.slotThreadInfo {
|
||||
@@ -411,6 +671,12 @@
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* Reply-chain spacing belongs to the bubble shell; nested reply content
|
||||
remains application-owned. */
|
||||
&.stateHasReply .slotReplyChain {
|
||||
margin-block-end: var(--cpd-space-2x, 8px);
|
||||
}
|
||||
|
||||
/* Own-event modifiers. */
|
||||
&.stateOwnEvent .slotSender {
|
||||
display: none;
|
||||
@@ -423,6 +689,16 @@
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
&.stateOwnEvent .lineMedia {
|
||||
margin-block: 0;
|
||||
margin-inline: 0 var(--event-tile-bubble-line-margin-inline-end);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&.stateOwnEvent .lineSticker {
|
||||
margin-inline-end: 32px;
|
||||
}
|
||||
|
||||
&.stateOwnEvent .slotAvatar {
|
||||
inset-block-start: -19px;
|
||||
inset-inline-start: auto;
|
||||
@@ -510,6 +786,160 @@
|
||||
border-end-start-radius: 0;
|
||||
border-end-end-radius: var(--event-tile-bubble-corner-radius);
|
||||
}
|
||||
|
||||
/* Bubble-column events without a normal message bubble keep their column
|
||||
placement but do not paint the bubble background. */
|
||||
&.stateNoBubble .line {
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
&.stateNoBubble .lineEmote {
|
||||
padding-inline-end: 60px;
|
||||
font-style: italic;
|
||||
|
||||
.slotBody {
|
||||
padding-block: 4px;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
inset-block: auto;
|
||||
align-self: center;
|
||||
font-style: normal;
|
||||
}
|
||||
}
|
||||
|
||||
/* Events without sender details use the same avatar placement as an own
|
||||
message whose sender row is hidden. */
|
||||
&.stateNoSender .slotAvatar {
|
||||
inset-block-start: -19px;
|
||||
}
|
||||
|
||||
/* Hidden/bubble-container events are full-width shell rows. Their content
|
||||
remains application-owned; only the wrapper placement is changed here. */
|
||||
&.stateBubbleContainer,
|
||||
&.stateLeftAlignedBubble {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding-block: 5px;
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.slotAvatar {
|
||||
position: static;
|
||||
order: -1;
|
||||
display: inline-flex;
|
||||
margin-inline-end: var(--event-tile-bubble-gap);
|
||||
}
|
||||
|
||||
.slotPadlock {
|
||||
margin-inline-start: 0;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
inset-block: auto;
|
||||
inset-inline: -77px auto;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* These events span the space between the two bubble columns. */
|
||||
&.stateAlignedBetweenBubbles {
|
||||
margin-inline-start: calc(
|
||||
var(--event-tile-bubble-margin-inline-start) + var(--event-tile-bubble-line-margin-inline-start)
|
||||
);
|
||||
margin-inline-end: calc(
|
||||
var(--event-tile-bubble-margin-inline-end) + var(--event-tile-bubble-line-margin-inline-end)
|
||||
);
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Informational bubble rows are metadata rows, not message bubbles. */
|
||||
&.stateInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding-block: 5px;
|
||||
|
||||
.slotAvatar {
|
||||
position: static;
|
||||
order: -1;
|
||||
display: inline-flex;
|
||||
margin-inline-end: var(--event-tile-bubble-gap);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.line {
|
||||
min-width: 100%;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
inset-block: auto;
|
||||
inset-inline: -77px auto;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.slotPadlock {
|
||||
margin-inline-start: 0;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* UTD events have a shell-owned two-row grid. The decryption body keeps
|
||||
its application-owned appearance and only receives its grid area here. */
|
||||
&.stateEncryptionFailure {
|
||||
&:hover::before {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.line {
|
||||
display: grid;
|
||||
grid-template:
|
||||
"reply reply" auto
|
||||
"shield body" auto
|
||||
/ auto 1fr;
|
||||
}
|
||||
|
||||
.slotPadlock {
|
||||
grid-area: shield;
|
||||
margin-block: auto;
|
||||
}
|
||||
|
||||
.slotBody {
|
||||
grid-area: body;
|
||||
}
|
||||
|
||||
.slotReplyChain {
|
||||
grid-area: reply;
|
||||
}
|
||||
|
||||
&.stateInfo .line {
|
||||
gap: 0 9px;
|
||||
align-items: center;
|
||||
grid-template:
|
||||
"shield source" auto
|
||||
/ auto 1fr;
|
||||
}
|
||||
|
||||
&.stateInfo .slotBody {
|
||||
grid-area: source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ThreadView adds a narrower group timeline around EventTile. */
|
||||
@@ -556,10 +986,59 @@
|
||||
margin-inline-end: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&.stateInfo {
|
||||
.senderDetails .slotAvatar {
|
||||
position: absolute;
|
||||
inset-block-start: 50%;
|
||||
transform: translateY(-50%);
|
||||
margin-block-start: -2px;
|
||||
margin-block-end: 0;
|
||||
}
|
||||
|
||||
.line {
|
||||
padding-inline-start: 0;
|
||||
line-height: 12px;
|
||||
|
||||
.slotBody {
|
||||
width: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
&.layoutGroup,
|
||||
&.layoutIrc {
|
||||
padding-top: 0;
|
||||
|
||||
.senderDetails .slotAvatar {
|
||||
inset-inline-start: calc(var(--event-tile-irc-timestamp-width) + 14px - 4px);
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
inset-block-start: 2px;
|
||||
}
|
||||
|
||||
.line .slotBody {
|
||||
margin-inline-start: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
&.layoutBubble {
|
||||
.senderDetails .slotAvatar {
|
||||
inset-inline-start: 0;
|
||||
}
|
||||
|
||||
.line .slotBody {
|
||||
margin-inline-start: calc(56px + 14px + 6px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ThreadsList layout. */
|
||||
.root.shapeThreadsList {
|
||||
/* Preview-shaped layouts. */
|
||||
.root.shapeThreadsList,
|
||||
.root.shapeNotification {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
@@ -645,90 +1124,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Notification layout. */
|
||||
.root.shapeNotification {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
align-items: center;
|
||||
margin-block: 13px;
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--cpd-color-bg-subtle-primary, #f0f1f2);
|
||||
/* ThreadsList-only action-bar behavior. */
|
||||
.root.shapeThreadsList {
|
||||
.slotActionBar {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: auto -8px -13px 56px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
&:last-child::after {
|
||||
content: unset;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
width: calc(100% - var(--event-tile-preview-offset));
|
||||
margin-inline-start: var(--event-tile-preview-offset);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slotSender {
|
||||
/* In preview tiles the sender is a metadata-row profile, not the
|
||||
group-layout sender above the event line. */
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
max-width: 100%;
|
||||
min-height: 0;
|
||||
margin-inline-start: 0;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.slotAvatar {
|
||||
position: absolute;
|
||||
inset: 8px auto auto 8px;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding-inline-start: var(--event-tile-preview-offset);
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.slotThreadInfo {
|
||||
/* The preview is inside the padded line in these modes; it does not use
|
||||
the group-layout thread-summary gutter. */
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
|
||||
.slotTimestamp {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
margin-inline-start: auto;
|
||||
align-self: flex-start;
|
||||
position: initial;
|
||||
inset: auto;
|
||||
width: unset;
|
||||
text-align: initial;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&.layoutGroup:hover .line {
|
||||
background-color: inherit;
|
||||
box-shadow: none;
|
||||
&:hover .slotActionBar,
|
||||
&:focus-within .slotActionBar,
|
||||
&.stateActionBarFocused .slotActionBar {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
* Copyright 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
|
||||
import layoutMeta from "./EventTileView.stories";
|
||||
|
||||
const {
|
||||
bubbleGlobals,
|
||||
EventTileViewStory,
|
||||
eventTileStoryDefaults,
|
||||
groupGlobals,
|
||||
ircGlobals,
|
||||
StoryDecryptionFailureBody,
|
||||
StoryDecryptionFailurePadlock,
|
||||
StoryEditedBody,
|
||||
StoryEmoteBody,
|
||||
StoryHighlightedBody,
|
||||
StoryInformationalBody,
|
||||
StoryLinkedTimestamp,
|
||||
StoryMediaBody,
|
||||
StoryReplyChain,
|
||||
StoryStickerBody,
|
||||
} = layoutMeta.storyHelpers;
|
||||
|
||||
const meta = {
|
||||
title: "Timeline/EventTileView/States",
|
||||
component: EventTileViewStory,
|
||||
tags: ["autodocs"],
|
||||
render: (args) => <EventTileViewStory {...args} />,
|
||||
argTypes: {
|
||||
shape: { table: { disable: true } },
|
||||
classNames: { table: { disable: true } },
|
||||
state: { table: { disable: true } },
|
||||
line: { table: { disable: true } },
|
||||
roomMessages: { table: { disable: true } },
|
||||
slots: { table: { category: "Slots" } },
|
||||
},
|
||||
args: {
|
||||
shape: "Room",
|
||||
state: {},
|
||||
...eventTileStoryDefaults,
|
||||
},
|
||||
} satisfies Meta<typeof EventTileViewStory>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
const interactiveTags = ["skip-test", "!snapshot"];
|
||||
const visualTags = ["!dev", "!autodocs", "snapshot"];
|
||||
|
||||
const minimalRoomSlots = {
|
||||
body: eventTileStoryDefaults.slots.body,
|
||||
};
|
||||
|
||||
const threadStateSlots = {
|
||||
sender: eventTileStoryDefaults.slots.sender,
|
||||
avatar: eventTileStoryDefaults.slots.avatar,
|
||||
body: eventTileStoryDefaults.slots.body,
|
||||
timestamp: <StoryLinkedTimestamp />,
|
||||
};
|
||||
|
||||
const searchStateSlots = {
|
||||
sender: eventTileStoryDefaults.slots.sender,
|
||||
avatar: eventTileStoryDefaults.slots.avatar,
|
||||
body: eventTileStoryDefaults.slots.body,
|
||||
timestamp: <StoryLinkedTimestamp />,
|
||||
};
|
||||
|
||||
export const Highlighted: Story = {
|
||||
tags: interactiveTags,
|
||||
args: { shape: "Thread", state: { highlighted: true }, slots: threadStateSlots },
|
||||
};
|
||||
|
||||
export const HighlightedSearch: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Search",
|
||||
state: { highlighted: true },
|
||||
slots: { ...searchStateSlots, body: <StoryHighlightedBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const Selected: Story = {
|
||||
tags: interactiveTags,
|
||||
args: { shape: "Thread", state: { selected: true }, slots: threadStateSlots },
|
||||
};
|
||||
|
||||
export const SelectedRoom: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "alice",
|
||||
state: { selected: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const Informational: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { info: true, hasReply: false },
|
||||
slots: { body: <StoryInformationalBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const EncryptionFailure: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "alice",
|
||||
state: { encryptionFailure: true, hasReply: false },
|
||||
slots: {
|
||||
body: <StoryDecryptionFailureBody />,
|
||||
padlock: <StoryDecryptionFailurePadlock />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const ReplyChain: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "alice",
|
||||
state: { hasReply: true },
|
||||
slots: { ...minimalRoomSlots, replyChain: <StoryReplyChain /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const BubbleContainer: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { bubbleContainer: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const LeftAlignedBubble: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { leftAlignedBubble: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const AlignedBetweenBubbles: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { alignedBetweenBubbles: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const NoBubble: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { noBubble: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const NoSender: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { noSender: true, hasReply: false },
|
||||
slots: minimalRoomSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const Editing: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
state: { editing: true, hasReply: false },
|
||||
slots: { ...minimalRoomSlots, body: <StoryEditedBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const Emote: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
line: { emote: true },
|
||||
state: { emote: true, noBubble: true, hasReply: false },
|
||||
slots: { ...minimalRoomSlots, body: <StoryEmoteBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const Media: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "bob",
|
||||
line: { media: true },
|
||||
state: { hasReply: false },
|
||||
slots: { ...minimalRoomSlots, body: <StoryMediaBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const Sticker: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Room",
|
||||
roomMessages: "alice",
|
||||
line: { sticker: true },
|
||||
state: { hasReply: false },
|
||||
slots: { ...minimalRoomSlots, body: <StoryStickerBody /> },
|
||||
},
|
||||
};
|
||||
|
||||
export const HighlightedGroup: Story = {
|
||||
name: "Highlighted - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Highlighted.args,
|
||||
};
|
||||
|
||||
export const SelectedGroup: Story = {
|
||||
name: "Selected - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Selected.args,
|
||||
};
|
||||
|
||||
export const HighlightedSearchGroup: Story = {
|
||||
name: "Highlighted search - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: HighlightedSearch.args,
|
||||
};
|
||||
|
||||
export const SelectedRoomGroup: Story = {
|
||||
name: "Selected room - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: SelectedRoom.args,
|
||||
};
|
||||
|
||||
export const InformationalBubble: Story = {
|
||||
name: "Informational - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Informational.args,
|
||||
};
|
||||
|
||||
export const InformationalGroup: Story = {
|
||||
name: "Informational - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Informational.args,
|
||||
};
|
||||
|
||||
export const InformationalIrc: Story = {
|
||||
name: "Informational - IRC - Default",
|
||||
tags: visualTags,
|
||||
globals: ircGlobals,
|
||||
args: Informational.args,
|
||||
};
|
||||
|
||||
export const EncryptionFailureBubble: Story = {
|
||||
name: "Encryption failure - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: EncryptionFailure.args,
|
||||
};
|
||||
|
||||
export const EncryptionFailureGroup: Story = {
|
||||
name: "Encryption failure - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: EncryptionFailure.args,
|
||||
};
|
||||
|
||||
export const ReplyChainBubble: Story = {
|
||||
name: "Reply chain - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: ReplyChain.args,
|
||||
};
|
||||
|
||||
export const ReplyChainGroup: Story = {
|
||||
name: "Reply chain - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: ReplyChain.args,
|
||||
};
|
||||
|
||||
export const BubbleContainerBubble: Story = {
|
||||
name: "Bubble container - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: BubbleContainer.args,
|
||||
};
|
||||
|
||||
export const BubbleContainerGroup: Story = {
|
||||
name: "Bubble container - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: BubbleContainer.args,
|
||||
};
|
||||
|
||||
export const BubbleContainerIrc: Story = {
|
||||
name: "Bubble container - IRC - Default",
|
||||
tags: visualTags,
|
||||
globals: ircGlobals,
|
||||
args: BubbleContainer.args,
|
||||
};
|
||||
|
||||
export const LeftAlignedBubbleVisual: Story = {
|
||||
name: "Left-aligned bubble - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: LeftAlignedBubble.args,
|
||||
};
|
||||
|
||||
export const AlignedBetweenBubblesVisual: Story = {
|
||||
name: "Aligned between bubbles - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: AlignedBetweenBubbles.args,
|
||||
};
|
||||
|
||||
export const NoBubbleVisual: Story = {
|
||||
name: "No bubble - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: NoBubble.args,
|
||||
};
|
||||
|
||||
export const NoSenderVisual: Story = {
|
||||
name: "No sender - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: NoSender.args,
|
||||
};
|
||||
|
||||
export const EditingBubble: Story = {
|
||||
name: "Editing - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Editing.args,
|
||||
};
|
||||
|
||||
export const EditingGroup: Story = {
|
||||
name: "Editing - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Editing.args,
|
||||
};
|
||||
|
||||
export const EditingIrc: Story = {
|
||||
name: "Editing - IRC - Default",
|
||||
tags: visualTags,
|
||||
globals: ircGlobals,
|
||||
args: Editing.args,
|
||||
};
|
||||
|
||||
export const EmoteBubble: Story = {
|
||||
name: "Emote - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Emote.args,
|
||||
};
|
||||
|
||||
export const EmoteIrc: Story = {
|
||||
name: "Emote - IRC - Default",
|
||||
tags: visualTags,
|
||||
globals: ircGlobals,
|
||||
args: Emote.args,
|
||||
};
|
||||
|
||||
export const MediaBubble: Story = {
|
||||
name: "Media - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Media.args,
|
||||
};
|
||||
|
||||
export const StickerBubble: Story = {
|
||||
name: "Sticker - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Sticker.args,
|
||||
};
|
||||
@@ -108,6 +108,19 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.searchThreadInfo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-2x, 8px);
|
||||
color: var(--cpd-color-text-secondary, #626a73);
|
||||
font: var(--cpd-font-body-sm-regular);
|
||||
}
|
||||
|
||||
.searchThreadInfo svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
/* Match the application IRC profile treatment without adding application
|
||||
selectors to the shared EventTileView stylesheet. */
|
||||
.ircSender {
|
||||
@@ -139,15 +152,6 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.notificationDot {
|
||||
display: block;
|
||||
flex: 0 0 8px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--cpd-color-icon-success-primary, #0d9f6e);
|
||||
}
|
||||
|
||||
.receiptAvatar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -217,6 +221,12 @@
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.stickerBody {
|
||||
padding: 0;
|
||||
font-size: 72px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.replyChain {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
@@ -237,6 +247,12 @@
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.pinnedFooter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-2x, 8px);
|
||||
}
|
||||
|
||||
.storyEventTile.storyOwnEvent.storyLayoutBubble .storyReactions {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ import { Avatar } from "@vector-im/compound-web";
|
||||
import { ThreadsIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
|
||||
import { useMockedViewModel } from "../../../../core/viewmodel";
|
||||
import { useEventPresentation } from "../../EventPresentation";
|
||||
import { useEventPresentation, type EventLayout } from "../../EventPresentation";
|
||||
import { withViewDocs } from "../../../../../.storybook/withViewDocs";
|
||||
import {
|
||||
NotificationBadgeView,
|
||||
type NotificationBadgeViewSnapshot,
|
||||
} from "../../../../notifications/NotificationBadgeView";
|
||||
import { EventTileView, type EventTileViewProps } from "./index";
|
||||
import { E2ePadlock, E2ePadlockIcon } from "./E2ePadlock";
|
||||
import { DisambiguatedProfileView } from "./DisambiguatedProfile";
|
||||
@@ -23,12 +27,30 @@ import { MessageTimestampView } from "../timestamp/MessageTimestampView";
|
||||
import { ReactionsRowView } from "../reactions/ReactionsRow";
|
||||
import { ReactionsRowButtonView } from "../reactions/ReactionsRowButton";
|
||||
import { type ReactionsRowButtonTooltipViewModel } from "../reactions/ReactionsRowButtonTooltip";
|
||||
import { ImageBodyView, ImageBodyViewState, type ImageBodyViewSnapshot } from "../body/MImageBodyView";
|
||||
import {
|
||||
FileBodyView,
|
||||
FileBodyViewInfoIcon,
|
||||
FileBodyViewState,
|
||||
type FileBodyViewSnapshot,
|
||||
} from "../body/MFileBodyView";
|
||||
import {
|
||||
DecryptionFailureBodyView,
|
||||
DecryptionFailureReason,
|
||||
type DecryptionFailureBodyViewSnapshot,
|
||||
} from "../body/DecryptionFailureBodyView";
|
||||
import { EventContentBodyView, type EventContentBodyViewSnapshot } from "../body/EventContentBodyView";
|
||||
import { TextualBodyView, TextualBodyViewKind, type TextualBodyViewSnapshot } from "../body/TextualBodyView";
|
||||
import {
|
||||
ThreadSummaryView,
|
||||
ThreadMessagePreviewView,
|
||||
type ThreadMessagePreviewViewSnapshot,
|
||||
} from "./ThreadSummary/ThreadSummaryView";
|
||||
import { EventPreviewView, type EventPreviewViewSnapshot } from "./EventPreviewView";
|
||||
import { PinnedMessageBadge } from "./PinnedMessageBadge";
|
||||
import { TextualEventView, type TextualEventViewSnapshot } from "./TextualEventView";
|
||||
import styles from "./EventTileView.stories.module.css";
|
||||
import storyMediaSrc from "../../../../../static/image-body/install-spinner.png";
|
||||
|
||||
type StoryBoundary = HTMLElement;
|
||||
const eventTileSlotTestIdPrefix = "event-tile-slot-";
|
||||
@@ -138,7 +160,7 @@ const StorySender = ({
|
||||
|
||||
const createStorySender = (
|
||||
isOwnEvent: boolean,
|
||||
layout: EventTileViewProps["root"]["layout"],
|
||||
layout: EventLayout,
|
||||
showSenderAndAvatar: boolean,
|
||||
): React.ReactElement | undefined => {
|
||||
if (!showSenderAndAvatar) return undefined;
|
||||
@@ -151,49 +173,214 @@ const createStorySender = (
|
||||
|
||||
const createStoryAvatar = (
|
||||
isOwnEvent: boolean,
|
||||
layout: EventTileViewProps["root"]["layout"],
|
||||
layout: EventLayout,
|
||||
showSenderAndAvatar: boolean,
|
||||
sizeOverride?: string,
|
||||
): React.ReactElement | undefined => {
|
||||
if (!showSenderAndAvatar) return undefined;
|
||||
|
||||
const label = isOwnEvent ? "A" : "B";
|
||||
const size = layout === "irc" ? "14px" : "30px";
|
||||
const size = sizeOverride ?? (layout === "irc" ? "14px" : "30px");
|
||||
return <StoryAvatar label={label} size={size} />;
|
||||
};
|
||||
|
||||
const StoryTimestamp = ({
|
||||
className,
|
||||
visible = true,
|
||||
linked = false,
|
||||
}: {
|
||||
className?: string;
|
||||
visible?: boolean;
|
||||
linked?: boolean;
|
||||
}): React.ReactElement | null => {
|
||||
const vm = useMockedViewModel(
|
||||
{ ts: "12:34", tsSentAt: "Tuesday, 4 August 2026 at 12:34", inhibitTooltip: true },
|
||||
{},
|
||||
{
|
||||
ts: "12:34",
|
||||
tsSentAt: "Tuesday, 4 August 2026 at 12:34",
|
||||
inhibitTooltip: true,
|
||||
href: linked ? "https://example.org/event-tile-story" : undefined,
|
||||
},
|
||||
linked ? { onClick: fn(), onContextMenu: fn() } : {},
|
||||
);
|
||||
return visible ? <MessageTimestampView vm={vm} className={className} /> : null;
|
||||
};
|
||||
const StoryBody = (): React.ReactElement => (
|
||||
<div className={styles.body}>
|
||||
<div>Here is a realistic event tile body with enough text to show the available width.</div>
|
||||
<div>This second line makes wrapping and vertical rhythm visible in Storybook.</div>
|
||||
</div>
|
||||
);
|
||||
const StoryLinkedTimestamp = (): React.ReactElement => <StoryTimestamp linked />;
|
||||
const StoryBody = (): React.ReactElement => {
|
||||
const contentSnapshot: EventContentBodyViewSnapshot = {
|
||||
body: [
|
||||
<div key="first-line">
|
||||
Here is a realistic event tile body with enough text to show the available width.
|
||||
</div>,
|
||||
<div key="second-line">This second line makes wrapping and vertical rhythm visible in Storybook.</div>,
|
||||
],
|
||||
className: styles.body,
|
||||
};
|
||||
const contentVm = useMockedViewModel(contentSnapshot, {});
|
||||
const bodySnapshot: TextualBodyViewSnapshot = { kind: TextualBodyViewKind.TEXT };
|
||||
const bodyVm = useMockedViewModel(bodySnapshot, {});
|
||||
|
||||
return <TextualBodyView vm={bodyVm} body={<EventContentBodyView vm={contentVm} as="div" />} />;
|
||||
};
|
||||
const StoryPreviewBody = (): React.ReactElement => {
|
||||
const snapshot: EventPreviewViewSnapshot = {
|
||||
isVisible: true,
|
||||
previewContent: "Can you review the draft?",
|
||||
previewTooltip: "Can you review the draft?",
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <EventPreviewView vm={vm} />;
|
||||
};
|
||||
const StorySearchBody = (): React.ReactElement => {
|
||||
const contentSnapshot: EventContentBodyViewSnapshot = {
|
||||
body: [
|
||||
<div key="first-line">
|
||||
Can you review the <mark>draft</mark> before the meeting?
|
||||
</div>,
|
||||
<div key="second-line">The highlighted term represents the matching search result.</div>,
|
||||
],
|
||||
className: styles.body,
|
||||
};
|
||||
const contentVm = useMockedViewModel(contentSnapshot, {});
|
||||
const bodyVm = useMockedViewModel({ kind: TextualBodyViewKind.TEXT } satisfies TextualBodyViewSnapshot, {});
|
||||
return <TextualBodyView vm={bodyVm} body={<EventContentBodyView vm={contentVm} as="div" />} />;
|
||||
};
|
||||
const StoryFileBody = (): React.ReactElement => {
|
||||
const snapshot: FileBodyViewSnapshot = {
|
||||
state: FileBodyViewState.UNENCRYPTED,
|
||||
showInfo: true,
|
||||
infoLabel: "spec.pdf",
|
||||
infoTooltip: "spec.pdf (22 KB)",
|
||||
infoIcon: FileBodyViewInfoIcon.ATTACHMENT,
|
||||
infoHref: "https://example.org/spec.pdf",
|
||||
showDownload: true,
|
||||
downloadLabel: "Download file",
|
||||
downloadTitle: "Download spec.pdf",
|
||||
downloadHref: "https://example.org/download/spec.pdf",
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <FileBodyView vm={vm} />;
|
||||
};
|
||||
const StoryInformationalBody = (): React.ReactElement => {
|
||||
const snapshot: TextualEventViewSnapshot = {
|
||||
content: (
|
||||
<>
|
||||
<div>Alex changed the room name to Example room.</div>
|
||||
<div>This informational event demonstrates the shared textual event styling.</div>
|
||||
</>
|
||||
),
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <TextualEventView vm={vm} />;
|
||||
};
|
||||
const StoryHighlightedBody = (): React.ReactElement => {
|
||||
const contentSnapshot: EventContentBodyViewSnapshot = {
|
||||
body: "Message with a highlighted word.",
|
||||
formattedBody: 'Message with a <span class="mx_EventTile_searchHighlight">highlighted</span> word.',
|
||||
className: styles.body,
|
||||
};
|
||||
const contentVm = useMockedViewModel(contentSnapshot, {});
|
||||
const bodyVm = useMockedViewModel({ kind: TextualBodyViewKind.TEXT }, {});
|
||||
|
||||
return <TextualBodyView vm={bodyVm} body={<EventContentBodyView vm={contentVm} as="div" />} />;
|
||||
};
|
||||
const StoryEditedBody = (): React.ReactElement => {
|
||||
const contentSnapshot: EventContentBodyViewSnapshot = {
|
||||
body: "This message is currently being edited.",
|
||||
className: styles.body,
|
||||
};
|
||||
const contentVm = useMockedViewModel(contentSnapshot, {});
|
||||
const bodyVm = useMockedViewModel(
|
||||
{
|
||||
kind: TextualBodyViewKind.TEXT,
|
||||
showEditedMarker: true,
|
||||
editedMarkerText: "(edited)",
|
||||
editedMarkerAriaLabel: "Edited",
|
||||
editedMarkerTooltip: "This message was edited",
|
||||
},
|
||||
{ onEditedMarkerClick: fn() },
|
||||
);
|
||||
|
||||
return <TextualBodyView vm={bodyVm} body={<EventContentBodyView vm={contentVm} as="div" />} />;
|
||||
};
|
||||
const StoryEmoteBody = (): React.ReactElement => {
|
||||
const contentSnapshot: EventContentBodyViewSnapshot = {
|
||||
body: "waves hello to the room",
|
||||
className: styles.body,
|
||||
};
|
||||
const contentVm = useMockedViewModel(contentSnapshot, {});
|
||||
const bodyVm = useMockedViewModel(
|
||||
{ kind: TextualBodyViewKind.EMOTE, emoteSenderName: "Bob" },
|
||||
{ onEmoteSenderClick: fn() },
|
||||
);
|
||||
|
||||
return <TextualBodyView vm={bodyVm} body={<EventContentBodyView vm={contentVm} as="div" />} />;
|
||||
};
|
||||
const StoryReplyChain = (): React.ReactElement => (
|
||||
<blockquote className={styles.replyChain}>
|
||||
<span className={styles.replyAuthor}>Taylor Example</span>
|
||||
<span>Earlier message quoted in this reply.</span>
|
||||
</blockquote>
|
||||
);
|
||||
const StoryActionBar = (): React.ReactElement | null => {
|
||||
const StoryMediaBody = (): React.ReactElement => {
|
||||
const snapshot: ImageBodyViewSnapshot = {
|
||||
state: ImageBodyViewState.READY,
|
||||
alt: "Example media",
|
||||
src: storyMediaSrc,
|
||||
thumbnailSrc: storyMediaSrc,
|
||||
maxWidth: 320,
|
||||
maxHeight: 180,
|
||||
aspectRatio: "16 / 9",
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <ImageBodyView vm={vm} />;
|
||||
};
|
||||
const StoryStickerBody = (): React.ReactElement => {
|
||||
const snapshot: ImageBodyViewSnapshot = {
|
||||
state: ImageBodyViewState.READY,
|
||||
alt: "Example sticker",
|
||||
src: storyMediaSrc,
|
||||
thumbnailSrc: storyMediaSrc,
|
||||
maxWidth: 240,
|
||||
maxHeight: 240,
|
||||
aspectRatio: "1 / 1",
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <ImageBodyView vm={vm} />;
|
||||
};
|
||||
const StoryDecryptionFailureBody = (): React.ReactElement => {
|
||||
const snapshot: DecryptionFailureBodyViewSnapshot = {
|
||||
decryptionFailureReason: DecryptionFailureReason.UNABLE_TO_DECRYPT,
|
||||
isLocalDeviceVerified: true,
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <DecryptionFailureBodyView vm={vm} />;
|
||||
};
|
||||
const StoryDecryptionFailurePadlock = (): React.ReactElement => (
|
||||
<E2ePadlock icon={E2ePadlockIcon.DecryptionFailure} title="Unable to decrypt" />
|
||||
);
|
||||
const StoryNotificationBadge = (): React.ReactElement => {
|
||||
const snapshot: NotificationBadgeViewSnapshot = {
|
||||
shouldRender: true,
|
||||
isVisible: true,
|
||||
isNotification: true,
|
||||
isHighlight: false,
|
||||
isKnocked: false,
|
||||
badgeType: "dot",
|
||||
symbol: null,
|
||||
isClickable: false,
|
||||
showUnsentTooltip: false,
|
||||
};
|
||||
const vm = useMockedViewModel(snapshot, {});
|
||||
return <NotificationBadgeView vm={vm} />;
|
||||
};
|
||||
const StoryActionBar = ({ isPinned = false }: { isPinned?: boolean } = {}): React.ReactElement | null => {
|
||||
const vm = useMockedViewModel(
|
||||
{
|
||||
actions: [ActionBarAction.React, ActionBarAction.Reply, ActionBarAction.Options],
|
||||
presentation: "icon" as const,
|
||||
isDownloadEncrypted: false,
|
||||
isDownloadLoading: false,
|
||||
isPinned: false,
|
||||
isPinned,
|
||||
isQuoteExpanded: false,
|
||||
isThreadReplyAllowed: true,
|
||||
},
|
||||
@@ -201,6 +388,22 @@ const StoryActionBar = (): React.ReactElement | null => {
|
||||
);
|
||||
return <ActionBarView vm={vm} />;
|
||||
};
|
||||
const StoryPinnedActionBar = (): React.ReactElement => <StoryActionBar isPinned />;
|
||||
const StoryThreadListActionBar = (): React.ReactElement => {
|
||||
const vm = useMockedViewModel(
|
||||
{
|
||||
actions: [ActionBarAction.ViewInRoom, ActionBarAction.CopyLink],
|
||||
presentation: "icon" as const,
|
||||
isDownloadEncrypted: false,
|
||||
isDownloadLoading: false,
|
||||
isPinned: false,
|
||||
isQuoteExpanded: false,
|
||||
isThreadReplyAllowed: false,
|
||||
},
|
||||
{ onViewInRoomClick: fn(), onCopyLinkClick: fn() },
|
||||
);
|
||||
return <ActionBarView vm={vm} />;
|
||||
};
|
||||
|
||||
const useStoryReactionTooltipVm = (caption: string): ReactionsRowButtonTooltipViewModel =>
|
||||
useMockedViewModel({ formattedSenders: "Alice Example and Bob Example", caption }, {});
|
||||
@@ -243,6 +446,12 @@ const StoryFooter = (): React.ReactElement => {
|
||||
</ReactionsRowView>
|
||||
);
|
||||
};
|
||||
const StoryPinnedFooter = (): React.ReactElement => (
|
||||
<div className={styles.pinnedFooter}>
|
||||
<PinnedMessageBadge />
|
||||
<StoryFooter />
|
||||
</div>
|
||||
);
|
||||
const storyThreadPreview: ThreadMessagePreviewViewSnapshot = {
|
||||
isVisible: true,
|
||||
avatar: {
|
||||
@@ -275,7 +484,7 @@ const StoryThreadInfo = (): React.ReactElement => {
|
||||
|
||||
/** The ThreadsList view uses the compact inline replies preview, not ThreadSummaryView. */
|
||||
const StoryThreadListInfo = (): React.ReactElement => {
|
||||
const previewVm = useMockedViewModel(storyThreadPreview, {});
|
||||
const previewVm = useMockedViewModel({ ...storyThreadPreview, showDisplayName: false }, {});
|
||||
|
||||
return (
|
||||
<div className={styles.threadListInfo}>
|
||||
@@ -285,6 +494,12 @@ const StoryThreadListInfo = (): React.ReactElement => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
const StorySearchThreadInfo = (): React.ReactElement => (
|
||||
<a className={styles.searchThreadInfo} href="https://example.org/event-tile-story/thread">
|
||||
<ThreadsIcon />
|
||||
View in thread
|
||||
</a>
|
||||
);
|
||||
const StoryReceipt = (): React.ReactElement => (
|
||||
<span className={styles.receipt}>
|
||||
<span className={styles.readReceiptGroup}>
|
||||
@@ -330,9 +545,8 @@ const baseRoot: EventTileViewProps["root"] = {
|
||||
scrollToken: "event-tile-story",
|
||||
permalink: "https://example.org/event-tile-story",
|
||||
eventId: "$event-tile-story",
|
||||
layout: "group",
|
||||
shape: "Room",
|
||||
state: { isOwnEvent: false, hasReply: true },
|
||||
state: { isOwnEvent: false, hasReply: false },
|
||||
};
|
||||
|
||||
const roomSlots: EventTileViewProps["slots"] = {
|
||||
@@ -341,7 +555,6 @@ const roomSlots: EventTileViewProps["slots"] = {
|
||||
body: <StoryBody />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
padlock: <StoryPadlock />,
|
||||
replyChain: <StoryReplyChain />,
|
||||
actionBar: <StoryActionBar />,
|
||||
footer: <StoryFooter />,
|
||||
threadInfo: <StoryThreadInfo />,
|
||||
@@ -349,19 +562,38 @@ const roomSlots: EventTileViewProps["slots"] = {
|
||||
contextMenu: <StoryContextMenu />,
|
||||
};
|
||||
|
||||
/** Slots for the default Room-like shapes without a context menu fixture. */
|
||||
const defaultShapeSlots: EventTileViewProps["slots"] = {
|
||||
sender: <StorySender />,
|
||||
avatar: <StoryAvatar />,
|
||||
body: <StoryBody />,
|
||||
timestamp: <StoryLinkedTimestamp />,
|
||||
padlock: <StoryPadlock />,
|
||||
actionBar: <StoryActionBar />,
|
||||
footer: <StoryFooter />,
|
||||
threadInfo: <StoryThreadInfo />,
|
||||
receipt: <StoryReceipt />,
|
||||
};
|
||||
|
||||
const threadSlots: EventTileViewProps["slots"] = {
|
||||
...defaultShapeSlots,
|
||||
avatar: <StoryAvatar size="32px" />,
|
||||
threadInfo: undefined,
|
||||
};
|
||||
|
||||
type EventTileStoryProps = Omit<EventTileViewProps, "root"> & {
|
||||
shape: EventTileViewProps["root"]["shape"];
|
||||
state?: Partial<EventTileViewProps["root"]["state"]>;
|
||||
roomMessages?: "boundaries" | "alice";
|
||||
roomMessages?: "boundaries" | "alice" | "bob";
|
||||
};
|
||||
|
||||
const createStoryTimestamp = (
|
||||
layout: EventTileViewProps["root"]["layout"],
|
||||
layout: EventLayout,
|
||||
isLast: boolean,
|
||||
showActionBar: boolean,
|
||||
): React.ReactElement | undefined => {
|
||||
const showTimestamp = layout === "irc" || isLast || showActionBar;
|
||||
return showTimestamp ? <StoryTimestamp visible={showTimestamp} /> : undefined;
|
||||
return showTimestamp ? <StoryTimestamp visible={showTimestamp} linked /> : undefined;
|
||||
};
|
||||
|
||||
const createRoomStorySlots = ({
|
||||
@@ -439,8 +671,12 @@ function EventTileViewStoryContent({
|
||||
const showActionBar = interaction.hovered || interaction.focused;
|
||||
const timestamp = createStoryTimestamp(layout, isLast, showActionBar);
|
||||
const showSenderAndAvatar = layout === "irc" || !tileState.continuation;
|
||||
const sender = createStorySender(isOwnEvent, layout, showSenderAndAvatar);
|
||||
const avatar = createStoryAvatar(isOwnEvent, layout, showSenderAndAvatar);
|
||||
const sender = createStorySender(
|
||||
isOwnEvent,
|
||||
layout,
|
||||
showSenderAndAvatar && !tileState.noSender && !tileState.info,
|
||||
);
|
||||
const avatar = createStoryAvatar(isOwnEvent, layout, showSenderAndAvatar, tileState.info ? "14px" : undefined);
|
||||
const slots =
|
||||
shape === "Room"
|
||||
? createRoomStorySlots({
|
||||
@@ -474,7 +710,6 @@ function EventTileViewStoryContent({
|
||||
id: `${baseRoot.id}-${suffix}`,
|
||||
scrollToken: `${baseRoot.scrollToken}-${suffix}`,
|
||||
eventId: `${baseRoot.eventId}-${suffix}`,
|
||||
layout,
|
||||
shape,
|
||||
state: {
|
||||
...baseRoot.state,
|
||||
@@ -509,6 +744,10 @@ function EventTileViewStoryContent({
|
||||
return renderTile(true, "alice-single", { continuation: false, lastInSection: true }, true);
|
||||
}
|
||||
|
||||
if (roomMessages === "bob") {
|
||||
return renderTile(false, "bob-single", { continuation: false, lastInSection: true }, true);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{renderTile(false, "bob-first", { continuation: false, lastInSection: false })}
|
||||
@@ -543,20 +782,43 @@ const eventTileStoryDefaults = {
|
||||
slots: roomSlots,
|
||||
};
|
||||
|
||||
const groupGlobals = { eventLayout: "group", eventDensity: "default" } as const;
|
||||
const bubbleGlobals = {
|
||||
eventLayout: "bubble",
|
||||
eventDensity: "default",
|
||||
} as const;
|
||||
const ircGlobals = { eventLayout: "irc", eventDensity: "default" } as const;
|
||||
const compactGroupGlobals = { eventLayout: "group", eventDensity: "compact" } as const;
|
||||
|
||||
const storyHelpers = {
|
||||
EventTileViewStory,
|
||||
eventTileStoryDefaults,
|
||||
bubbleGlobals,
|
||||
groupGlobals,
|
||||
ircGlobals,
|
||||
compactGroupGlobals,
|
||||
StoryDecryptionFailureBody,
|
||||
StoryDecryptionFailurePadlock,
|
||||
StoryEditedBody,
|
||||
StoryEmoteBody,
|
||||
StoryHighlightedBody,
|
||||
StoryInformationalBody,
|
||||
StoryLinkedTimestamp,
|
||||
StoryMediaBody,
|
||||
StoryReplyChain,
|
||||
StoryStickerBody,
|
||||
};
|
||||
|
||||
const meta = {
|
||||
title: "Timeline/EventTileView",
|
||||
title: "Timeline/EventTileView/Shapes",
|
||||
component: EventTileViewStory,
|
||||
tags: ["autodocs"],
|
||||
render: (args) => <EventTileViewStory {...args} />,
|
||||
argTypes: {
|
||||
shape: {
|
||||
control: "select",
|
||||
options: ["Room", "Thread", "ThreadsList", "File", "Notification", "Search", "Pinned"],
|
||||
table: { disable: true },
|
||||
},
|
||||
classNames: { table: { disable: true } },
|
||||
state: {
|
||||
control: "object",
|
||||
},
|
||||
onMouseEnter: { table: { disable: true } },
|
||||
onMouseLeave: { table: { disable: true } },
|
||||
onFocus: { table: { disable: true } },
|
||||
@@ -570,88 +832,167 @@ const meta = {
|
||||
},
|
||||
args: {
|
||||
shape: "Room",
|
||||
state: {},
|
||||
...eventTileStoryDefaults,
|
||||
},
|
||||
} satisfies Meta<typeof EventTileViewStory>;
|
||||
storyHelpers,
|
||||
} satisfies Meta<typeof EventTileViewStory> & { storyHelpers: typeof storyHelpers };
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Room: Story = {};
|
||||
const interactiveTags = ["skip-test", "!snapshot"];
|
||||
const visualTags = ["!dev", "!autodocs", "snapshot"];
|
||||
|
||||
export const Room: Story = { tags: interactiveTags };
|
||||
|
||||
export const ThreadsList: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "ThreadsList",
|
||||
slots: {
|
||||
sender: <StorySender />,
|
||||
avatar: <StoryAvatar />,
|
||||
body: <StoryBody />,
|
||||
avatar: <StoryAvatar size="32px" />,
|
||||
body: <StoryPreviewBody />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
notificationBadge: <span className={styles.notificationDot} aria-hidden="true" />,
|
||||
notificationBadge: <StoryNotificationBadge />,
|
||||
threadInfo: <StoryThreadListInfo />,
|
||||
actionBar: <StoryActionBar />,
|
||||
actionBar: <StoryThreadListActionBar />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Thread: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Thread",
|
||||
slots: threadSlots,
|
||||
},
|
||||
};
|
||||
|
||||
export const Notification: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Notification",
|
||||
slots: {
|
||||
sender: <StorySender />,
|
||||
body: <StoryBody />,
|
||||
body: <StoryPreviewBody />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
roomAvatar: <StoryAvatar room size="28px" />,
|
||||
notificationRoomLabel: <span className={styles.roomLabel}>in Example room</span>,
|
||||
notificationBadge: <span className={styles.notificationDot} aria-hidden="true" />,
|
||||
notificationRoomLabel: (
|
||||
<span className={styles.roomLabel}>
|
||||
{" in "}
|
||||
<strong>Example room</strong>
|
||||
</span>
|
||||
),
|
||||
notificationBadge: <StoryNotificationBadge />,
|
||||
threadInfo: <StoryThreadListInfo />,
|
||||
receipt: <StoryReceipt />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const File: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "File",
|
||||
slots: {
|
||||
sender: <StorySender />,
|
||||
avatar: <StoryAvatar />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
body: <StoryBody />,
|
||||
contextMenu: <StoryContextMenu />,
|
||||
avatar: <StoryAvatar size="20px" />,
|
||||
timestamp: <StoryLinkedTimestamp />,
|
||||
body: <StoryFileBody />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Highlighted: Story = {
|
||||
export const Search: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Thread",
|
||||
state: { highlighted: true },
|
||||
shape: "Search",
|
||||
slots: {
|
||||
sender: <StorySender />,
|
||||
avatar: <StoryAvatar />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
body: <StoryBody />,
|
||||
...defaultShapeSlots,
|
||||
body: <StorySearchBody />,
|
||||
threadInfo: <StorySearchThreadInfo />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Selected: Story = {
|
||||
export const Pinned: Story = {
|
||||
tags: interactiveTags,
|
||||
args: {
|
||||
shape: "Thread",
|
||||
state: { selected: true },
|
||||
shape: "Pinned",
|
||||
slots: {
|
||||
sender: <StorySender />,
|
||||
avatar: <StoryAvatar />,
|
||||
timestamp: <StoryTimestamp />,
|
||||
body: <StoryBody />,
|
||||
...defaultShapeSlots,
|
||||
actionBar: <StoryPinnedActionBar />,
|
||||
footer: <StoryPinnedFooter />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const RoomGroupDefault: Story = {
|
||||
name: "Room - Group - Default",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Room.args,
|
||||
};
|
||||
|
||||
export const RoomGroupCompact: Story = {
|
||||
name: "Room - Group - Compact",
|
||||
tags: visualTags,
|
||||
globals: compactGroupGlobals,
|
||||
args: Room.args,
|
||||
};
|
||||
|
||||
export const RoomBubbleDefault: Story = {
|
||||
name: "Room - Bubble - Default",
|
||||
tags: visualTags,
|
||||
globals: bubbleGlobals,
|
||||
args: Room.args,
|
||||
};
|
||||
|
||||
export const RoomIrcDefault: Story = {
|
||||
name: "Room - IRC - Default",
|
||||
tags: visualTags,
|
||||
globals: ircGlobals,
|
||||
args: Room.args,
|
||||
};
|
||||
|
||||
export const ThreadsListGroup: Story = {
|
||||
name: "Threads list - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: ThreadsList.args,
|
||||
};
|
||||
|
||||
export const ThreadGroup: Story = {
|
||||
name: "Thread - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Thread.args,
|
||||
};
|
||||
|
||||
export const NotificationGroup: Story = {
|
||||
name: "Notification - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Notification.args,
|
||||
};
|
||||
|
||||
export const FileGroup: Story = {
|
||||
name: "File - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: File.args,
|
||||
};
|
||||
|
||||
export const SearchGroup: Story = {
|
||||
name: "Search - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Search.args,
|
||||
};
|
||||
|
||||
export const PinnedGroup: Story = {
|
||||
name: "Pinned - Group",
|
||||
tags: visualTags,
|
||||
globals: groupGlobals,
|
||||
args: Pinned.args,
|
||||
};
|
||||
|
||||
@@ -9,7 +9,14 @@ import React, { createRef } from "react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { fireEvent, render } from "@test-utils";
|
||||
import { EventTileView, type EventTileViewClassNames, type EventTileViewProps } from "./index";
|
||||
import type { EventLayout } from "../../EventPresentation";
|
||||
import {
|
||||
EventTileView,
|
||||
type EventTileViewClassNames,
|
||||
type EventTileViewLine,
|
||||
type EventTileViewProps,
|
||||
type EventTileViewRootState,
|
||||
} from "./index";
|
||||
import styles from "./EventTileView.module.css";
|
||||
|
||||
const renderState: EventTileViewProps["root"] = {
|
||||
@@ -18,7 +25,6 @@ const renderState: EventTileViewProps["root"] = {
|
||||
scrollToken: "event-1",
|
||||
permalink: "https://example.org/event-1",
|
||||
eventId: "$event-1",
|
||||
layout: "group",
|
||||
shape: "Room",
|
||||
state: {
|
||||
isOwnEvent: true,
|
||||
@@ -120,6 +126,107 @@ function createStylingContractSlots(): EventTileViewProps["slots"] {
|
||||
};
|
||||
}
|
||||
|
||||
const rootStateMatrix = [
|
||||
{ name: "informational", state: { info: true }, hook: "stateInfo" },
|
||||
{ name: "bubble container", state: { bubbleContainer: true }, hook: "stateBubbleContainer" },
|
||||
{ name: "left-aligned bubble", state: { leftAlignedBubble: true }, hook: "stateLeftAlignedBubble" },
|
||||
{ name: "aligned between bubbles", state: { alignedBetweenBubbles: true }, hook: "stateAlignedBetweenBubbles" },
|
||||
{ name: "no bubble", state: { noBubble: true }, hook: "stateNoBubble" },
|
||||
{ name: "no sender", state: { noSender: true }, hook: "stateNoSender" },
|
||||
{ name: "encryption failure", state: { encryptionFailure: true }, hook: "stateEncryptionFailure" },
|
||||
{ name: "emote", state: { emote: true }, hook: "stateEmote" },
|
||||
{ name: "reply chain", state: { hasReply: true }, hook: "stateHasReply" },
|
||||
{ name: "editing", state: { editing: true }, hook: "stateEditing" },
|
||||
{ name: "continuation", state: { continuation: true }, hook: "stateContinuation" },
|
||||
{ name: "contextual", state: { contextual: true }, hook: "stateContextual" },
|
||||
{ name: "action bar focused", state: { actionBarFocused: true }, hook: "stateActionBarFocused" },
|
||||
{ name: "preview clamped", state: { previewClamped: true }, hook: "statePreviewClamped" },
|
||||
] satisfies ReadonlyArray<{
|
||||
name: string;
|
||||
state: Partial<EventTileViewRootState>;
|
||||
hook: keyof typeof styles;
|
||||
}>;
|
||||
|
||||
const lineStateMatrix = [
|
||||
{ name: "media", state: { media: true }, hook: "lineMedia" },
|
||||
{ name: "image", state: { image: true }, hook: "lineImage" },
|
||||
{ name: "sticker", state: { sticker: true }, hook: "lineSticker" },
|
||||
{ name: "emote", state: { emote: true }, hook: "lineEmote" },
|
||||
] satisfies ReadonlyArray<{
|
||||
name: string;
|
||||
state: EventTileViewLine;
|
||||
hook: keyof typeof styles;
|
||||
}>;
|
||||
|
||||
const groupLineSlotOrder = [
|
||||
"event-tile-slot-contextMenu",
|
||||
"event-tile-slot-timestamp",
|
||||
"event-tile-slot-padlock",
|
||||
"event-tile-slot-replyChain",
|
||||
"event-tile-slot-body",
|
||||
"event-tile-slot-actionBar",
|
||||
];
|
||||
|
||||
const groupRootSlotOrder = [
|
||||
"event-tile-slot-sender",
|
||||
"event-tile-slot-avatar",
|
||||
"event-line-1",
|
||||
"event-tile-slot-footer",
|
||||
"event-tile-slot-threadInfo",
|
||||
"event-tile-slot-receipt",
|
||||
];
|
||||
|
||||
const ircLineSlotOrder = [
|
||||
"event-tile-slot-contextMenu",
|
||||
"event-tile-slot-replyChain",
|
||||
"event-tile-slot-body",
|
||||
"event-tile-slot-actionBar",
|
||||
"event-tile-slot-footer",
|
||||
"event-tile-slot-threadInfo",
|
||||
];
|
||||
|
||||
const ircRootSlotOrder = [
|
||||
"event-tile-slot-timestamp",
|
||||
"event-tile-slot-padlock",
|
||||
"event-tile-slot-avatar",
|
||||
"event-tile-slot-sender",
|
||||
"event-line-1",
|
||||
"event-tile-slot-receipt",
|
||||
];
|
||||
|
||||
const shellPlacementMatrix = [
|
||||
{ name: "informational", rootState: { info: true }, lineState: {}, layout: "group" },
|
||||
{ name: "bubble container in group layout", rootState: { bubbleContainer: true }, lineState: {}, layout: "group" },
|
||||
{
|
||||
name: "bubble container in bubble layout",
|
||||
rootState: { bubbleContainer: true },
|
||||
lineState: {},
|
||||
layout: "bubble",
|
||||
},
|
||||
{ name: "bubble container in IRC layout", rootState: { bubbleContainer: true }, lineState: {}, layout: "irc" },
|
||||
{ name: "left-aligned bubble", rootState: { leftAlignedBubble: true }, lineState: {}, layout: "bubble" },
|
||||
{ name: "aligned between bubbles", rootState: { alignedBetweenBubbles: true }, lineState: {}, layout: "bubble" },
|
||||
{ name: "no bubble", rootState: { noBubble: true }, lineState: {}, layout: "bubble" },
|
||||
{ name: "no sender", rootState: { noSender: true }, lineState: {}, layout: "bubble" },
|
||||
{
|
||||
name: "encryption failure with reply",
|
||||
rootState: { encryptionFailure: true, hasReply: true },
|
||||
lineState: {},
|
||||
layout: "bubble",
|
||||
},
|
||||
{ name: "editing continuation", rootState: { editing: true, continuation: true }, lineState: {}, layout: "bubble" },
|
||||
{ name: "media line", rootState: {}, lineState: { media: true }, layout: "group" },
|
||||
{ name: "sticker line", rootState: {}, lineState: { sticker: true }, layout: "bubble" },
|
||||
{ name: "emote line", rootState: {}, lineState: { emote: true }, layout: "bubble" },
|
||||
{ name: "other-event bubble alignment", rootState: {}, lineState: {}, layout: "bubble", isOwnEvent: false },
|
||||
] satisfies ReadonlyArray<{
|
||||
name: string;
|
||||
rootState: Partial<EventTileViewRootState>;
|
||||
lineState: EventTileViewLine;
|
||||
layout: EventLayout;
|
||||
isOwnEvent?: boolean;
|
||||
}>;
|
||||
|
||||
describe("EventTileView", () => {
|
||||
it("renders the common root and line structure", () => {
|
||||
const { container, getByTestId } = render(<EventTileView {...createProps()} />);
|
||||
@@ -168,6 +275,79 @@ describe("EventTileView", () => {
|
||||
expect(root).toHaveClass(styles.stateLastInSection);
|
||||
});
|
||||
|
||||
it.each(rootStateMatrix)("maps the $name root state to its semantic shell hook", ({ state, hook }) => {
|
||||
const { container } = render(
|
||||
<EventTileView
|
||||
{...createProps({
|
||||
root: {
|
||||
...renderState,
|
||||
state: { ...renderState.state, ...state },
|
||||
},
|
||||
})}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.firstElementChild).toHaveClass(styles[hook]);
|
||||
});
|
||||
|
||||
it("maps presentation density to a shell hook instead of event state", () => {
|
||||
const { container } = render(<EventTileView {...createProps()} />, {
|
||||
presentation: { layout: "group", density: "compact" },
|
||||
});
|
||||
|
||||
expect(container.firstElementChild).toHaveClass(styles.densityCompact);
|
||||
expect(container.firstElementChild).not.toHaveClass("stateCompact");
|
||||
});
|
||||
|
||||
it.each(lineStateMatrix)("maps the $name line state to its semantic shell hook", ({ state, hook }) => {
|
||||
const { getByTestId } = render(
|
||||
<EventTileView {...createProps({ line: state, slots: createStylingContractSlots() })} />,
|
||||
);
|
||||
|
||||
expect(getByTestId("styling-contract-body").closest(`.${styles.line}`)).toHaveClass(styles[hook]);
|
||||
});
|
||||
|
||||
it.each(shellPlacementMatrix)(
|
||||
"keeps $name slots contained and ordered by the shell",
|
||||
({ rootState, lineState, layout, isOwnEvent = renderState.state.isOwnEvent }) => {
|
||||
const { container } = render(
|
||||
<EventTileView
|
||||
{...createProps({
|
||||
root: {
|
||||
...renderState,
|
||||
state: { ...renderState.state, ...rootState, isOwnEvent },
|
||||
},
|
||||
line: lineState,
|
||||
slots: createStylingContractSlots(),
|
||||
})}
|
||||
/>,
|
||||
{ presentation: { layout } },
|
||||
);
|
||||
const root = container.firstElementChild;
|
||||
const line = root?.querySelector(`#${renderState.id}`);
|
||||
|
||||
if (!root || !line) {
|
||||
throw new Error("Expected EventTile root and line to be present");
|
||||
}
|
||||
|
||||
const lineSlotOrder = layout === "irc" ? ircLineSlotOrder : groupLineSlotOrder;
|
||||
const rootSlotOrder = layout === "irc" ? ircRootSlotOrder : groupRootSlotOrder;
|
||||
|
||||
expect(Array.from(line.children).map((child) => child.getAttribute("data-testid"))).toEqual(lineSlotOrder);
|
||||
expect(Array.from(root.children).map((child) => child.getAttribute("data-testid") ?? child.id)).toEqual(
|
||||
rootSlotOrder,
|
||||
);
|
||||
|
||||
const containedLineSlots =
|
||||
layout === "irc"
|
||||
? ["contextMenu", "replyChain", "body", "actionBar", "footer", "threadInfo"]
|
||||
: ["contextMenu", "timestamp", "padlock", "replyChain", "body", "actionBar"];
|
||||
for (const slotName of containedLineSlots) {
|
||||
expect(root.querySelector(`[data-testid="event-tile-slot-${slotName}"]`)?.parentElement).toBe(line);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves the application styling contract across rendering modes", () => {
|
||||
const group = render(
|
||||
<EventTileView
|
||||
@@ -254,7 +434,7 @@ describe("EventTileView", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("renders the thread layout in the original slot order", () => {
|
||||
it.each(["group", "bubble"] as const)("renders the %s thread layout in the original slot order", (layout) => {
|
||||
const { container, getByTestId } = render(
|
||||
<EventTileView
|
||||
{...createProps({
|
||||
@@ -277,6 +457,7 @@ describe("EventTileView", () => {
|
||||
},
|
||||
})}
|
||||
/>,
|
||||
{ presentation: { layout } },
|
||||
);
|
||||
const root = container.firstElementChild!;
|
||||
const senderDetails = getByTestId("avatar").parentElement?.parentElement;
|
||||
@@ -294,6 +475,14 @@ describe("EventTileView", () => {
|
||||
expect(line).toContainElement(getByTestId("timestamp"));
|
||||
expect(line).toContainElement(getByTestId("receipt"));
|
||||
expect(getByTestId("footer").parentElement?.parentElement).toBe(root);
|
||||
|
||||
expect(Array.from(line.children).map((child) => child.getAttribute("data-testid"))).toEqual([
|
||||
"event-tile-slot-replyChain",
|
||||
"event-tile-slot-body",
|
||||
"event-tile-slot-actionBar",
|
||||
"event-tile-slot-timestamp",
|
||||
"event-tile-slot-receipt",
|
||||
]);
|
||||
});
|
||||
|
||||
it.each(["Notification", "ThreadsList"] as const)("renders the %s preview layout", (shape) => {
|
||||
@@ -421,7 +610,7 @@ describe("EventTileView", () => {
|
||||
const { container, getByTestId } = render(
|
||||
<EventTileView
|
||||
{...createProps({
|
||||
root: { ...renderState, layout },
|
||||
root: renderState,
|
||||
slots: {
|
||||
sender: <span data-testid="sender">Sender</span>,
|
||||
avatar: <span data-testid="avatar">Avatar</span>,
|
||||
@@ -437,6 +626,7 @@ describe("EventTileView", () => {
|
||||
},
|
||||
})}
|
||||
/>,
|
||||
{ presentation: { layout } },
|
||||
);
|
||||
const root = container.firstElementChild!;
|
||||
const line = getByTestId("body").parentElement?.parentElement;
|
||||
@@ -450,13 +640,12 @@ describe("EventTileView", () => {
|
||||
expect(line).toContainElement(getByTestId("reply-chain"));
|
||||
expect(line).toContainElement(getByTestId("action-bar"));
|
||||
|
||||
const expectedRootSlotOrder = layout === "irc" ? ircRootSlotOrder : groupRootSlotOrder;
|
||||
expect(Array.from(root.children).map((child) => child.getAttribute("data-testid") ?? child.id)).toEqual(
|
||||
expectedRootSlotOrder,
|
||||
);
|
||||
|
||||
if (layout === "irc") {
|
||||
expect(root.children[0]).toContainElement(getByTestId("padlock"));
|
||||
expect(root.children[1]).toContainElement(getByTestId("timestamp"));
|
||||
expect(root.children[2]).toContainElement(getByTestId("avatar"));
|
||||
expect(root.children[3]).toContainElement(getByTestId("sender"));
|
||||
expect(root.children[4]).toBe(line);
|
||||
expect(root.children[5]).toContainElement(getByTestId("receipt"));
|
||||
expect(getByTestId("padlock").parentElement?.parentElement).toBe(root);
|
||||
expect(getByTestId("footer").parentElement?.parentElement).toBe(line);
|
||||
expect(getByTestId("thread-info").parentElement?.parentElement).toBe(line);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import React, { type JSX } from "react";
|
||||
import classNames from "classnames";
|
||||
|
||||
import { useEventPresentation } from "../../EventPresentation";
|
||||
import type { EventTileViewClassNames, EventTileViewProps, EventTileViewSlots } from "./EventTileView.types";
|
||||
import styles from "./EventTileView.module.css";
|
||||
|
||||
@@ -22,6 +23,7 @@ type EventTileSlotName = keyof EventTileViewSlots;
|
||||
*/
|
||||
export function EventTileView({
|
||||
root,
|
||||
line: lineState,
|
||||
slots,
|
||||
classNames: classNameOverrides,
|
||||
refs,
|
||||
@@ -35,6 +37,7 @@ export function EventTileView({
|
||||
onPermalinkContextMenu,
|
||||
}: Readonly<EventTileViewProps>): JSX.Element {
|
||||
const Root = root.as ?? "li";
|
||||
const { layout, density } = useEventPresentation();
|
||||
|
||||
const renderSlot = (slotName: EventTileSlotName, content: React.ReactNode = slots[slotName]): React.ReactNode => {
|
||||
if (content === null || content === undefined || typeof content === "boolean") return null;
|
||||
@@ -72,6 +75,13 @@ export function EventTileView({
|
||||
const renderSlots = (...slotNames: EventTileSlotName[]): React.ReactNode =>
|
||||
slotNames.map((slotName) => renderSlot(slotName));
|
||||
|
||||
const lineClassName = classNames(styles.line, classNameOverrides?.line, {
|
||||
[styles.lineMedia]: lineState?.media,
|
||||
[styles.lineSticker]: lineState?.sticker,
|
||||
[styles.lineEmote]: lineState?.emote,
|
||||
[styles.lineImage]: lineState?.image,
|
||||
});
|
||||
|
||||
const renderRoot = (
|
||||
children: React.ReactNode,
|
||||
rootClickHandler: React.MouseEventHandler<HTMLElement> | undefined,
|
||||
@@ -81,14 +91,27 @@ export function EventTileView({
|
||||
ref={refs?.root}
|
||||
className={classNames(styles.root, classNameOverrides?.root, {
|
||||
[styles.stateOwnEvent]: root.state.isOwnEvent,
|
||||
[styles.stateInfo]: root.state?.info,
|
||||
[styles.stateBubbleContainer]: root.state?.bubbleContainer,
|
||||
[styles.stateLeftAlignedBubble]: root.state?.leftAlignedBubble,
|
||||
[styles.stateAlignedBetweenBubbles]: root.state?.alignedBetweenBubbles,
|
||||
[styles.stateNoBubble]: root.state?.noBubble,
|
||||
[styles.stateNoSender]: root.state?.noSender,
|
||||
[styles.stateEncryptionFailure]: root.state?.encryptionFailure,
|
||||
[styles.stateEmote]: root.state?.emote,
|
||||
[styles.stateHasReply]: root.state?.hasReply,
|
||||
[styles.stateHighlighted]: root.state?.highlighted,
|
||||
[styles.stateSelected]: root.state?.selected,
|
||||
[styles.stateEditing]: root.state?.editing,
|
||||
[styles.stateContinuation]: root.state?.continuation,
|
||||
[styles.stateLastInSection]: root.state?.lastInSection,
|
||||
[styles.layoutGroup]: root.layout === "group",
|
||||
[styles.layoutBubble]: root.layout === "bubble",
|
||||
[styles.layoutIrc]: root.layout === "irc",
|
||||
[styles.stateContextual]: root.state?.contextual,
|
||||
[styles.stateActionBarFocused]: root.state?.actionBarFocused,
|
||||
[styles.statePreviewClamped]: root.state?.previewClamped,
|
||||
[styles.densityCompact]: density === "compact",
|
||||
[styles.layoutGroup]: layout === "group",
|
||||
[styles.layoutBubble]: layout === "bubble",
|
||||
[styles.layoutIrc]: layout === "irc",
|
||||
[styles.shapeThread]: root.shape === "Thread",
|
||||
[styles.shapeThreadsList]: root.shape === "ThreadsList",
|
||||
[styles.shapeFile]: root.shape === "File",
|
||||
@@ -116,11 +139,7 @@ export function EventTileView({
|
||||
<div className={classNames(styles.senderDetails, classNameOverrides?.senderDetails)}>
|
||||
{renderSlots("avatar", "sender")}
|
||||
</div>
|
||||
<div
|
||||
id={root.id}
|
||||
className={classNames(styles.line, classNameOverrides?.line)}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
<div id={root.id} className={lineClassName} onContextMenu={onContextMenu}>
|
||||
{renderSlots("contextMenu", "replyChain", "body", "actionBar", "timestamp", "receipt")}
|
||||
</div>
|
||||
{renderSlot("footer")}
|
||||
@@ -137,7 +156,7 @@ export function EventTileView({
|
||||
{renderSlots("sender", "notificationRoomLabel", "timestamp", "notificationBadge")}
|
||||
</div>
|
||||
{slots.roomAvatar ? renderSlot("roomAvatar") : renderSlot("avatar")}
|
||||
<div className={classNames(styles.line, classNameOverrides?.line)} id={root.id}>
|
||||
<div className={lineClassName} id={root.id}>
|
||||
{renderSlots("body", "threadInfo")}
|
||||
</div>
|
||||
{renderSlot("receipt")}
|
||||
@@ -155,7 +174,7 @@ export function EventTileView({
|
||||
{renderSlots("sender", "notificationRoomLabel", "timestamp", "notificationBadge")}
|
||||
</div>
|
||||
{renderSlot("avatar")}
|
||||
<div className={classNames(styles.line, classNameOverrides?.line)} id={root.id}>
|
||||
<div className={lineClassName} id={root.id}>
|
||||
{renderSlots("body", "threadInfo")}
|
||||
</div>
|
||||
{renderSlot("actionBar")}
|
||||
@@ -182,11 +201,7 @@ export function EventTileView({
|
||||
{renderSlots("avatar", "sender", "timestamp")}
|
||||
</div>
|
||||
</a>
|
||||
<div
|
||||
id={root.id}
|
||||
className={classNames(styles.line, classNameOverrides?.line)}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
<div id={root.id} className={lineClassName} onContextMenu={onContextMenu}>
|
||||
{renderSlots("contextMenu", "body")}
|
||||
</div>
|
||||
</>,
|
||||
@@ -197,15 +212,11 @@ export function EventTileView({
|
||||
// Default shape: Pinned, Room, Search
|
||||
|
||||
// IRC layout: the leading metadata slots precede the line content.
|
||||
if (root.layout === "irc") {
|
||||
if (layout === "irc") {
|
||||
return renderRoot(
|
||||
<>
|
||||
{renderSlots("padlock", "timestamp", "avatar", "sender")}
|
||||
<div
|
||||
id={root.id}
|
||||
className={classNames(styles.line, classNameOverrides?.line)}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
{renderSlots("timestamp", "padlock", "avatar", "sender")}
|
||||
<div id={root.id} className={lineClassName} onContextMenu={onContextMenu}>
|
||||
{renderSlots("contextMenu", "replyChain", "body", "actionBar", "footer", "threadInfo")}
|
||||
</div>
|
||||
{renderSlot("receipt")}
|
||||
@@ -219,11 +230,7 @@ export function EventTileView({
|
||||
return renderRoot(
|
||||
<>
|
||||
{renderSlots("sender", "avatar")}
|
||||
<div
|
||||
id={root.id}
|
||||
className={classNames(styles.line, classNameOverrides?.line)}
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
<div id={root.id} className={lineClassName} onContextMenu={onContextMenu}>
|
||||
{renderSlots("contextMenu", "timestamp", "padlock", "replyChain", "body", "actionBar")}
|
||||
</div>
|
||||
{renderSlots("footer", "threadInfo", "receipt")}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import type React from "react";
|
||||
|
||||
import type { EventLayout } from "../../EventPresentation/EventPresentation.types";
|
||||
|
||||
/** Timeline rendering modes supported by the EventTile shell. */
|
||||
export type EventTileRenderingMode = "Room" | "Thread" | "ThreadsList" | "File" | "Notification" | "Search" | "Pinned";
|
||||
|
||||
@@ -18,6 +16,22 @@ export interface EventTileViewRootState {
|
||||
isOwnEvent: boolean;
|
||||
/** Whether EventTile renders a reply chain. */
|
||||
hasReply: boolean;
|
||||
/** Whether the event is an informational timeline item. */
|
||||
info?: boolean;
|
||||
/** Whether the event uses the bubble container shell. */
|
||||
bubbleContainer?: boolean;
|
||||
/** Whether the bubble is aligned to the left. */
|
||||
leftAlignedBubble?: boolean;
|
||||
/** Whether the event is aligned between bubble columns. */
|
||||
alignedBetweenBubbles?: boolean;
|
||||
/** Whether bubble styling is suppressed for this event. */
|
||||
noBubble?: boolean;
|
||||
/** Whether sender details are hidden. */
|
||||
noSender?: boolean;
|
||||
/** Whether the event failed decryption. */
|
||||
encryptionFailure?: boolean;
|
||||
/** Whether the event body is an emote. */
|
||||
emote?: boolean;
|
||||
/** Whether the event is highlighted by search or navigation. */
|
||||
highlighted?: boolean;
|
||||
/** Whether the event is selected. */
|
||||
@@ -28,6 +42,24 @@ export interface EventTileViewRootState {
|
||||
continuation?: boolean;
|
||||
/** Whether this is the last event in a section. */
|
||||
lastInSection?: boolean;
|
||||
/** Whether the tile is a contextual search result. */
|
||||
contextual?: boolean;
|
||||
/** Whether the action bar currently has focus. */
|
||||
actionBarFocused?: boolean;
|
||||
/** Whether the body should be clamped to a preview. */
|
||||
previewClamped?: boolean;
|
||||
}
|
||||
|
||||
/** Semantic state consumed by EventTileView for the event line. */
|
||||
export interface EventTileViewLine {
|
||||
/** Whether the event body is likely to render media content. */
|
||||
media?: boolean;
|
||||
/** Whether the event is a sticker. */
|
||||
sticker?: boolean;
|
||||
/** Whether the event body is an emote. */
|
||||
emote?: boolean;
|
||||
/** Whether the event body is an image. */
|
||||
image?: boolean;
|
||||
}
|
||||
|
||||
/** Complete root state consumed by EventTileView. */
|
||||
@@ -44,8 +76,6 @@ export interface EventTileViewRoot {
|
||||
permalink?: string;
|
||||
/** Optional event identifier exposed through `data-event-id`. */
|
||||
eventId?: string;
|
||||
/** Configured tile layout. */
|
||||
layout: EventLayout;
|
||||
/** Timeline rendering mode. */
|
||||
shape: EventTileRenderingMode;
|
||||
/** Conditional state classes and styling state. */
|
||||
@@ -136,6 +166,8 @@ export interface EventTileViewHandlers {
|
||||
export interface EventTileViewProps extends EventTileViewHandlers {
|
||||
/** Pure root render state. */
|
||||
root: EventTileViewRoot;
|
||||
/** Optional semantic state for the event line. */
|
||||
line?: EventTileViewLine;
|
||||
/** Optional application CSS class overrides for shell-owned elements. */
|
||||
classNames?: EventTileViewClassNames;
|
||||
/** Render-ready children supplied by the application layer. Each slot is rendered inside a named shell boundary. */
|
||||
|
||||
@@ -10,6 +10,7 @@ export type {
|
||||
EventTileViewClassNames,
|
||||
EventTileRenderingMode,
|
||||
EventTileViewHandlers,
|
||||
EventTileViewLine,
|
||||
EventTileViewProps,
|
||||
EventTileViewRefs,
|
||||
EventTileViewRoot,
|
||||
|
||||