Skip to content

Commit 2184461

Browse files
committed
Added customization to previews
1 parent 25f31db commit 2184461

4 files changed

Lines changed: 90 additions & 5 deletions

File tree

book/src/configuration/preview/card.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Specific card preview settings.
77
- [Configuration](#configuration)
88
- [show\_image](#show_image)
99
- [round\_image\_corners](#round_image_corners)
10+
- [max\_width](#max_width)
11+
- [description\_max\_height](#description_max_height)
12+
- [image\_max\_height](#image_max_height)
1013
- [include](#include)
1114
- [exclude](#exclude)
1215

@@ -46,6 +49,45 @@ Round the corners of the image in the card preview (if shown).
4649
round_image_corners = true
4750
```
4851

52+
### max_width
53+
54+
Maximum width of the card in pixels.
55+
56+
```toml
57+
# Type: number
58+
# Values: any positive number
59+
# Default: 400.0
60+
61+
[preview.card]
62+
max_width = 400.0
63+
```
64+
65+
### description_max_height
66+
67+
Maximum height of the description text in pixels.
68+
69+
```toml
70+
# Type: number
71+
# Values: any positive number
72+
# Default: 100.0
73+
74+
[preview.card]
75+
description_max_height = 100.0
76+
```
77+
78+
### image_max_height
79+
80+
Maximum height of the image in the card preview in pixels.
81+
82+
```toml
83+
# Type: number
84+
# Values: any positive number
85+
# Default: 200.0
86+
87+
[preview.card]
88+
image_max_height = 200.0
89+
```
90+
4991
### exclude
5092

5193
[Exclusion conditions](/configuration/conditions.md) for when card previews will

book/src/configuration/preview/image.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Specific image preview settings.
77
- [Configuration](#configuration)
88
- [action](#action)
99
- [round\_corners](#round_corners)
10+
- [max\_width](#max_width)
11+
- [max\_height](#max_height)
1012
- [include](#include)
1113
- [exclude](#exclude)
1214

@@ -46,6 +48,32 @@ Round the corners of the image.
4648
round_corners = true
4749
```
4850

51+
### max_width
52+
53+
Maximum width of the image in pixels.
54+
55+
```toml
56+
# Type: number
57+
# Values: any positive number
58+
# Default: 550.0
59+
60+
[preview.image]
61+
max_width = 550.0
62+
```
63+
64+
### max_height
65+
66+
Maximum height of the image in pixels.
67+
68+
```toml
69+
# Type: number
70+
# Values: any positive number
71+
# Default: 350.0
72+
73+
[preview.image]
74+
max_height = 350.0
75+
```
76+
4977
### exclude
5078

5179
[Exclusion conditions](/configuration/conditions.md) for when image previews

data/src/config/preview.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ pub struct Card {
168168
pub include: Option<Inclusivities>,
169169
pub show_image: bool,
170170
pub round_image_corners: bool,
171+
/// Maximum width of the card in pixels
172+
pub max_width: f32,
173+
/// Maximum height of the description in pixels
174+
pub description_max_height: f32,
175+
/// Maximum height of the image in pixels
176+
pub image_max_height: f32,
171177
}
172178

173179
impl Default for Card {
@@ -177,6 +183,9 @@ impl Default for Card {
177183
include: None,
178184
show_image: true,
179185
round_image_corners: true,
186+
max_width: 400.0,
187+
description_max_height: 100.0,
188+
image_max_height: 200.0,
180189
}
181190
}
182191
}
@@ -223,6 +232,10 @@ pub struct Image {
223232
pub exclude: Option<Inclusivities>,
224233
pub include: Option<Inclusivities>,
225234
pub round_corners: bool,
235+
/// Maximum width of the image in pixels
236+
pub max_width: f32,
237+
/// Maximum height of the image in pixels
238+
pub max_height: f32,
226239
}
227240

228241
impl Default for Image {
@@ -232,6 +245,8 @@ impl Default for Image {
232245
exclude: None,
233246
include: None,
234247
round_corners: true,
248+
max_width: 550.0,
249+
max_height: 350.0,
235250
}
236251
}
237252
}

src/buffer/scroll_view.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ fn preview_row<'a>(
14921492
),
14931493
)
14941494
.clip(false)
1495-
.max_height(100.0)
1495+
.max_height(config.preview.card.description_max_height)
14961496
}),
14971497
config.preview.card.show_image.then_some(
14981498
container(
@@ -1511,11 +1511,11 @@ fn preview_row<'a>(
15111511
.content_fit(ContentFit::ScaleDown)
15121512
)
15131513
.padding(Padding::default().top(8))
1514-
.max_height(200)
1514+
.max_height(config.preview.card.image_max_height)
15151515
),
15161516
]
15171517
.spacing(8)
1518-
.max_width(400),
1518+
.max_width(config.preview.card.max_width),
15191519
)
15201520
.padding(8),
15211521
)
@@ -1534,8 +1534,8 @@ fn preview_row<'a>(
15341534
})
15351535
.content_fit(ContentFit::ScaleDown),
15361536
)
1537-
.max_width(550)
1538-
.max_height(350),
1537+
.max_width(config.preview.image.max_width)
1538+
.max_height(config.preview.image.max_height),
15391539
)
15401540
.on_press(match config.preview.image.action {
15411541
data::config::preview::ImageAction::OpenUrl => {

0 commit comments

Comments
 (0)