markdown preview: Improve task list visuals (#9695)
Instead of using some arbitrary unicode characters to render a task as completed/not completed, I feel that using an actual checkbox from the components crate makes it look more polished. Before:  After: <img width="883" alt="image" src="https://github.com/zed-industries/zed/assets/53836821/f63d56c3-bfbb-41c8-b150-8ebf973f75e2"> Release Notes: - Improved visuals of task lists inside the markdown preview
This commit is contained in:
parent
5181d3f719
commit
e77d313839
1 changed files with 15 additions and 5 deletions
|
@ -13,7 +13,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use theme::{ActiveTheme, SyntaxTheme};
|
use theme::{ActiveTheme, SyntaxTheme};
|
||||||
use ui::{h_flex, v_flex, Label};
|
use ui::{h_flex, v_flex, Checkbox, Selection};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
pub struct RenderContext {
|
pub struct RenderContext {
|
||||||
|
@ -139,11 +139,21 @@ fn render_markdown_list(parsed: &ParsedMarkdownList, cx: &mut RenderContext) ->
|
||||||
let padding = rems((item.depth - 1) as f32 * 0.25);
|
let padding = rems((item.depth - 1) as f32 * 0.25);
|
||||||
|
|
||||||
let bullet = match item.item_type {
|
let bullet = match item.item_type {
|
||||||
Ordered(order) => format!("{}.", order),
|
Ordered(order) => format!("{}.", order).into_any_element(),
|
||||||
Unordered => "•".to_string(),
|
Unordered => "•".into_any_element(),
|
||||||
Task(checked) => if checked { "☑" } else { "☐" }.to_string(),
|
Task(checked) => div()
|
||||||
|
.mt(px(3.))
|
||||||
|
.child(Checkbox::new(
|
||||||
|
"checkbox",
|
||||||
|
if checked {
|
||||||
|
Selection::Selected
|
||||||
|
} else {
|
||||||
|
Selection::Unselected
|
||||||
|
},
|
||||||
|
))
|
||||||
|
.into_any_element(),
|
||||||
};
|
};
|
||||||
let bullet = div().mr_2().child(Label::new(bullet));
|
let bullet = div().mr_2().child(bullet);
|
||||||
|
|
||||||
let contents: Vec<AnyElement> = item
|
let contents: Vec<AnyElement> = item
|
||||||
.contents
|
.contents
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue