Files
Chris Troutner 20e67da216 Implement post options menu on every post card
Add a shared PostOptionsMenu component, used by the feed/thread post card and
the profile post card, with a pure post-options service for the block explorer
link and the open/close/focus state. Its first item links to the post
transaction on bch.loping.net in a new tab; the menu opens on the button and
closes on the button again, an outside click, or Escape, with ArrowDown moving
focus to the first item.

By coder.
2026-09-16 09:42:15 -07:00

26 lines
836 B
JavaScript

/*
Acceptance rendering adapter for the shared post options menu.
Renders the same PostOptionsMenu component the browser uses to a static HTML
string, so acceptance assertions can inspect the button and menu markup
without running a browser. The component's open/closed and focused state can
be seeded through props for deterministic rendering.
*/
'use strict'
const React = require('react')
const ReactDOMServer = require('react-dom/server')
const PostOptionsMenu = require('../../src/components/post-feed/post-options-menu')
function renderPostOptions (txid, options = {}) {
const element = React.createElement(PostOptionsMenu, {
txid,
initialOpen: options.open,
initialFocusedIndex: options.focusedIndex
})
return ReactDOMServer.renderToStaticMarkup(element)
}
module.exports = { renderPostOptions }