mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-22 01:02:01 -07:00
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.
26 lines
836 B
JavaScript
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 }
|