Skip to content

CodeBlock - empty header/actions elements if no actions are passed #8197

@mcoker

Description

@mcoker

Screen Shot 2022-10-10 at 2 39 21 PM

The border comes from the presence of the header.

@mmenestr @mcarrano according to the design guidelines:

Code blocks can include multiple actions. By default, the copy action is always present and any other actions are optional and customizable.

It isn't built in to the react component - it has to be defined by the user. Does the design doc blurb imply the copy button is required? Or can it be optional? I would lean toward it being optional, in case it does something like show a code example/format that isn't meant to be copied/pasted. If so, I don't think we should render the header/actions block unless something is passed.

<div className={css(styles.codeBlockHeader)}>
<div className={css(styles.codeBlockActions)}>{actions && actions}</div>
</div>

We may also consider adding a __header-main element that is adjacent to the actions block for a user to place other items in the header. Currently it's only setup to accept the actions block. This code language toggle group is a good use case for that? https://codesandbox.io/s/code-editor-language-toggle-group-jcmqlb?file=/toggle.js

Screen Shot 2022-10-10 at 2 56 54 PM

Metadata

Metadata

Assignees

Labels

Breaking change 💥this change requires a major release and has API changes.PF5

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions