From 0ebc0fa64c4fc9f6ee3b4feae50737ceca4ccba0 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 14 Jan 2024 00:32:08 +0800 Subject: [PATCH] First step in introducing actions bar --- src/components/status.css | 58 +++++++++++++++++++++++++++++++++++++ src/components/status.jsx | 61 +++++++++++++++++++++++++++++++++++++-- src/pages/status.jsx | 2 ++ 3 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/components/status.css b/src/components/status.css index eb451353..506eea10 100644 --- a/src/components/status.css +++ b/src/components/status.css @@ -1766,6 +1766,64 @@ a.card:is(:hover, :focus):visited { color: var(--green-color); } +/* ACTIONS */ + +.status-actions { + display: flex; + position: absolute; + top: 4px; + right: 4px; + background-color: var(--bg-color); + border-radius: 8px; + z-index: 1; + border: 1px solid var(--outline-color); + box-shadow: 0 2px 6px -3px var(--drop-shadow-color); + overflow: clip; + opacity: 0; + pointer-events: none; + transform: translateX(8px); + transform-origin: right center; + transition: all 0.1s ease-out 0.3s, border-color 0.3s ease-out; + + button.plain { + color: var(--text-insignificant-color); + backdrop-filter: none; + padding: 10px; + border-radius: 8px; + + &:is(:hover, :focus) { + color: var(--text-color); + background-color: var(--bg-faded-color); + filter: none !important; + box-shadow: inset 0 0 0 2px var(--bg-color); + } + + &.reblog-button.checked { + color: var(--reblog-color); + } + + &.favourite-button.checked { + color: var(--favourite-color); + } + + &.bookmark-button.checked { + color: var(--link-color); + } + } + + &:hover { + border-color: var(--outline-hover-color); + } + + &:hover, + .status:hover &:not(:hover), + &.open { + opacity: 1; + pointer-events: auto; + transform: scale(1); + } +} + /* BADGE */ .status-badge { diff --git a/src/components/status.jsx b/src/components/status.jsx index 6b0922a5..d58db180 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -125,6 +125,7 @@ function Status({ onStatusLinkClick = () => {}, showFollowedTags, allowContextMenu, + showActionsBar, }) { if (skeleton) { return ( @@ -640,7 +641,7 @@ function Status({ }; } - const menuInstanceRef = useRef(); + const actionsRef = useRef(); const StatusMenuItems = ( <> {!isSizeLarge && ( @@ -1317,6 +1318,56 @@ function Status({ {StatusMenuItems} )} + {showActionsBar && size !== 'l' && !previewMode && !readOnly && ( +
+ + + { + if (actionsRef.current) { + actionsRef.current.classList.toggle('open', open); + } + return ( + + ); + }} + > + {StatusMenuItems} + +
+ )} {size !== 'l' && (
{reblogged && } @@ -2212,7 +2263,9 @@ function StatusButton({ class: className, title, alt, + size, icon, + iconSize = 'l', onClick, ...props }) { @@ -2240,7 +2293,9 @@ function StatusButton({