Message Pinning: rework the message pinning list in the right panel (#12825)

* Fix pinning event loading after restart

* Update deps

* Replace pinned event list

* Add a dialog to confirm to unpin all messages

* Use `EmptyState` when there is no pinned messages

* Rework `PinnedEventTile` tests

* Add comments and refactor `PinnedMessageCard`

* Rework `PinnedMessageCard` tests

* Add tests for `UnpinAllDialog`

* Add e2e tests for pinned messages

* Replace 3px custom gap by 4px gap

* Use string interpolation for `Pin` action.

* Update playright sceenshot for empty state
This commit is contained in:
Florian Duros 2024-08-16 14:16:06 +02:00 committed by GitHub
parent 88cf643cbd
commit 6f3dc30693
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 2099 additions and 507 deletions

View file

@ -0,0 +1,38 @@
/*
* Copyright 2024 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.mx_UnpinAllDialog {
/* 396 is coming from figma and we remove the left and right paddings of the dialog */
width: calc(396px - (var(--cpd-space-10x) * 2));
padding-bottom: var(--cpd-space-2x);
.mx_UnpinAllDialog_title {
/* Override the default heading style */
font: var(--cpd-font-heading-sm-semibold) !important;
margin-bottom: var(--cpd-space-3x);
}
.mx_UnpinAllDialog_buttons {
display: flex;
flex-direction: column;
gap: var(--cpd-space-4x);
margin: var(--cpd-space-8x) var(--cpd-space-2x) 0 var(--cpd-space-2x);
button {
width: 100%;
}
}
}

View file

@ -15,50 +15,40 @@ limitations under the License.
*/
.mx_PinnedMessagesCard {
.mx_PinnedMessagesCard_empty_wrapper {
--unpin-height: 76px;
.mx_PinnedMessagesCard_wrapper {
display: flex;
height: 100%;
flex-direction: column;
padding: var(--cpd-space-4x);
gap: var(--cpd-space-6x);
overflow-y: auto;
.mx_PinnedMessagesCard_empty {
height: max-content;
text-align: center;
margin: auto 40px;
.mx_PinnedMessagesCard_MessageActionBar {
pointer-events: none;
width: max-content;
margin: 0 auto;
/* Cancel the default values for non-interactivity */
position: unset;
visibility: visible;
cursor: unset;
&::before {
content: unset;
}
.mx_MessageActionBar_optionsButton {
background: var(--MessageActionBar-item-hover-background);
border-radius: var(--MessageActionBar-item-hover-borderRadius);
z-index: var(--MessageActionBar-item-hover-zIndex);
color: var(--cpd-color-icon-primary);
}
}
.mx_PinnedMessagesCard_empty_header {
color: $primary-content;
margin-block: $spacing-24 $spacing-20;
}
> span {
font-size: $font-12px;
line-height: $font-15px;
color: $secondary-content;
}
.mx_PinnedMessagesCard_Separator {
min-height: 1px;
/* Override default compound value */
margin-block: 0;
}
}
.mx_PinnedMessagesCard_wrapper_unpin_all {
/* Remove the unpin all button height and the top and bottom padding */
height: calc(100% - var(--unpin-height) - calc(var(--cpd-space-4x) * 2));
}
.mx_PinnedMessagesCard_unpin {
/* Make it float at the bottom of the unpin panel */
position: absolute;
bottom: 0;
width: 100%;
height: var(--unpin-height);
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 4px 24px 0 rgba(27, 29, 34, 0.1);
background: var(--cpd-color-bg-canvas-default);
}
.mx_EventTile_body {
word-break: break-word;
}

View file

@ -15,95 +15,27 @@ limitations under the License.
*/
.mx_PinnedEventTile {
min-height: 40px;
width: 100%;
padding: 0 4px 12px;
display: flex;
gap: var(--cpd-space-4x);
align-items: flex-start;
display: grid;
grid-template-areas:
"avatar name remove"
"content content content"
"footer footer footer";
grid-template-rows: max-content auto max-content;
grid-template-columns: 24px auto 24px;
grid-row-gap: 12px;
grid-column-gap: 8px;
.mx_PinnedEventTile_wrapper {
display: flex;
flex-direction: column;
gap: var(--cpd-space-1x);
width: 100%;
& + .mx_PinnedEventTile {
padding: 12px 4px;
border-top: 1px solid $menu-border-color;
}
.mx_PinnedEventTile_top {
display: flex;
gap: var(--cpd-space-1x);
justify-content: space-between;
align-items: center;
.mx_PinnedEventTile_senderAvatar,
.mx_PinnedEventTile_sender,
.mx_PinnedEventTile_unpinButton,
.mx_PinnedEventTile_message,
.mx_PinnedEventTile_footer {
min-width: 0; /* Prevent a grid blowout */
}
.mx_PinnedEventTile_senderAvatar {
grid-area: avatar;
}
.mx_PinnedEventTile_sender {
grid-area: name;
font-weight: var(--cpd-font-weight-semibold);
font-size: $font-15px;
line-height: $font-24px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.mx_PinnedEventTile_unpinButton {
visibility: hidden;
grid-area: remove;
position: relative;
width: 24px;
height: 24px;
border-radius: 8px;
&:hover {
background-color: $roomheader-addroom-bg-color;
}
&::before {
content: "";
position: absolute;
height: inherit;
width: inherit;
background: $secondary-content;
mask-position: center;
mask-size: 8px;
mask-repeat: no-repeat;
mask-image: url("$(res)/img/image-view/close.svg");
}
}
.mx_PinnedEventTile_message {
grid-area: content;
}
.mx_PinnedEventTile_footer {
grid-area: footer;
font-size: $font-10px;
line-height: 12px;
.mx_PinnedEventTile_timestamp {
color: $secondary-content;
display: unset;
width: unset; /* Cancel the default width value */
}
.mx_AccessibleButton_kind_link {
margin-left: 12px;
}
}
&:hover {
.mx_PinnedEventTile_unpinButton {
visibility: visible;
.mx_PinnedEventTile_sender {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
}
}