Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_row: Refine action-button layout to better scale.

Karl Stolley38c6b82022e8
diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css
index 069afc023ed..8f160643caa 100644
--- a/web/styles/app_variables.css
+++ b/web/styles/app_variables.css
@@ -399,9 +399,12 @@
--message-box-markdown-aligned-vertical-space: var(
--markdown-interelement-space-px
);
- /* 22px matches to the width of the padded icon. */
- --message-box-icon-width: 22px;
- --message-box-icon-height: 25px;
+ /* 22px matches to the width of the padded icon.
+ 22px at 16px/1em
+ */
+ --message-box-icon-width: 1.375em;
+ /* 25px at 16px/1em */
+ --message-box-icon-height: 1.6667em;
--message-box-height-senderless-single-line-message: calc(
var(--base-line-height-unitless) * var(--base-font-size-px) +
calc(var(--markdown-interelement-space-px) * 2)
diff --git a/web/styles/message_row.css b/web/styles/message_row.css
index 76c91adf3e8..3b763ed9d3b 100644
--- a/web/styles/message_row.css
+++ b/web/styles/message_row.css
@@ -136,18 +136,6 @@
8px minmax(var(--message-box-timestamp-column-width), max-content);
}
- .message_controls {
- grid-area: controls;
-
- @media (width < $sm_min), ((width >= $md_min) and (width < $mc_min)) {
- /* This is intended to target the first message_controls child
- when there are 3 displayed. */
- .message_control_button:nth-last-child(3) {
- display: none;
- }
- }
- }
-
.message_edit_notice {
grid-area: edited;
}
@@ -420,8 +408,28 @@
}
.message_controls {
+ grid-area: controls;
+ /* Let the controls occupy the entire height
+ of the row; inner flexboxes handle the
+ centering of the icons. */
+ align-self: stretch;
+ /* But to better set the height to the typical
+ sender-row line height for better centering
+ in all contexts. */
+ height: var(--message-box-sender-line-height);
display: flex;
- align-items: baseline;
+ /* The flexbox here matches the height set above. */
+ align-items: stretch;
+ /* Ensure square icons for better centering. */
+ line-height: 1;
+
+ @media (width < $sm_min), ((width >= $md_min) and (width < $mc_min)) {
+ /* This is intended to target the first message_controls child
+ when there are 3 displayed. */
+ .message_control_button:nth-last-child(3) {
+ display: none;
+ }
+ }
/* This is a bit tricky; we need to reserve space for the message
controls even when the message isn't hovered, so that hover
@@ -433,18 +441,31 @@
visibility: hidden;
transition: none 0.2s ease;
transition-property: opacity, visibility;
- width: var(--message-box-icon-width);
- height: var(--message-box-icon-height);
- text-align: center;
+ /* Allow buttons to grow to fill the available space,
+ in concord with the column calculated for the
+ .messagebox-content grid. */
+ flex: 1 0 0;
+ /* Set the height to 100% to effectively flex open
+ on the vertical axis. */
+ height: 100%;
+ /* Control buttons are their own flex containers,
+ to more gracefully center the icons. */
+ display: flex;
+ place-items: center center;
color: var(--color-message-action-visible);
+ .emoji-message-control-button-container {
+ /* This button has an extra div for Tippy purposes,
+ so it becomes its own flex container. */
+ display: flex;
+ }
+
& .message-controls-icon {
- vertical-align: middle;
- /* TODO: Math for these values, possibly with variables.
- In short, the icon body is 16px square; the current
+ /* The icon body is 16px square at 16px/1em; the clickable
area for the icon is 26px wide by 25px tall, so these
values ensure a 26px x 25px clickable area for the icon. */
- padding: 2.5px 3px;
+ /* 2.5px at 16px/1em; 3px at 16px/1em */
+ padding: 0.1563em 0.1875em;
&::before {
/* We specify block display so the