agent: Add design tweaks (#28963)
One more batch of fine-tuning the agent panel's design. Release Notes: - N/A
This commit is contained in:
parent
8117940aca
commit
2a878ee6d0
5 changed files with 161 additions and 87 deletions
|
@ -107,6 +107,7 @@ struct Options {
|
|||
pub enum CodeBlockRenderer {
|
||||
Default {
|
||||
copy_button: bool,
|
||||
border: bool,
|
||||
},
|
||||
Custom {
|
||||
render: CodeBlockRenderFn,
|
||||
|
@ -381,7 +382,10 @@ impl MarkdownElement {
|
|||
Self {
|
||||
markdown,
|
||||
style,
|
||||
code_block_renderer: CodeBlockRenderer::Default { copy_button: true },
|
||||
code_block_renderer: CodeBlockRenderer::Default {
|
||||
copy_button: true,
|
||||
border: false,
|
||||
},
|
||||
on_url_click: None,
|
||||
}
|
||||
}
|
||||
|
@ -748,6 +752,21 @@ impl Element for MarkdownElement {
|
|||
code_block.w_full()
|
||||
}
|
||||
});
|
||||
|
||||
// Apply border if required
|
||||
// Usage examples:
|
||||
// CodeBlockRenderer::Default { copy_button: true, border: true } - Both copy button and border
|
||||
// CodeBlockRenderer::Default { copy_button: false, border: true } - Border only
|
||||
// CodeBlockRenderer::Default { copy_button: true, border: false } - Copy button only (default)
|
||||
if let CodeBlockRenderer::Default { border: true, .. } =
|
||||
&self.code_block_renderer
|
||||
{
|
||||
code_block = code_block
|
||||
.rounded_md()
|
||||
.border_1()
|
||||
.border_color(cx.theme().colors().border_variant);
|
||||
}
|
||||
|
||||
code_block.style().refine(&self.style.code_block);
|
||||
if let Some(code_block_text_style) = &self.style.code_block.text
|
||||
{
|
||||
|
@ -947,10 +966,10 @@ impl Element for MarkdownElement {
|
|||
});
|
||||
}
|
||||
|
||||
if matches!(
|
||||
&self.code_block_renderer,
|
||||
CodeBlockRenderer::Default { copy_button: true }
|
||||
) {
|
||||
if let CodeBlockRenderer::Default {
|
||||
copy_button: true, ..
|
||||
} = &self.code_block_renderer
|
||||
{
|
||||
builder.flush_text();
|
||||
builder.modify_current_div(|el| {
|
||||
let content_range = parser::extract_code_block_content_range(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue