Skip to content

[Task](ui): improve `CodeBlockFooter´ API and copy confirmation #1844

Description

@franzheidl

Summary

This issue deals with two separate, but closely related topics:

Copy confirmation is lost when customizing the footer content

CodeBlockFooter currently does not accept children, so consumers using the codeBlockFooter slot end up re-implementing the Copy button, confirmation etc. themselves. The CustomCodeBlockFooter story illustrates this.

Add children?: ReactNode to CodeBlockFooter. Children render to the left of the Copy button, which is always present and rightmost.
Consumers who want custom footer content pass a <CodeBlockFooter> with children into the codeBlockFooter slot rather than building their own footer from scratch. The copy prop is preserved on the footer and respected, so the Copy button will be rendered as the rightmost button in the footer or not, depending on the value of the copy prop even when customizing the footer.

Update the CustomCodeBlockFooter story accordingly.

Inline "Copied!" confirmation disrupts layout

When preserving the Copy button as described above along with the current in-place confirmation, theer is a conflict, as custom options and the confirmation will need to go to the same location:

The <span> showing "Copied!" shifts footer layout on each copy action and will push custom children around. Replace it with a Tooltip on the Copy button, driven by isCopied, visible for the same 1000 ms. The tooltip floats above the layout and thus does not affect footer dimensions nor interferes with any other (custom) options.

Sub-tasks

  • Add children?: ReactNode prop to CodeBlockFooter; render children left, Copy button (if poresent as per Copy prop) right
  • Replace inline "Copied!" span with a Tooltip "Copied!" on the Copy button
  • Update the CustomCodeBlockFooter story to pass a <CodeBlockFooter> with a Download icon as children, no Copy button
  • Add a CustomCodeBlockFooterWithCopy story that sets Copy to true to illustrate how custom content (can be "Download", too) and Copy button can coexist
  • Update tests to reflect children rendering order and tooltip-based confirmation

Related Issues

This issue is a follow-up to #1829

Metadata

Metadata

Labels

ui-componentsAll tasks related to juno-ui-components library

Type

Projects

Status
New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions