mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 12:03:42 +01:00
look-backstage: an empty RecentList says so in a muted line at the reading start, not the start screen's centred notice; trial and story
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e080fa2098
commit
00035d1253
3 files changed
+31
-1
No files matched your search
@@ -7,6 +7,7 @@ use super::start::{
|
||||
};
|
||||
use super::words::ShellWords;
|
||||
use crate::buttons::Button;
|
||||
use crate::display::{Shade, Text};
|
||||
use crate::contract::{
|
||||
ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing,
|
||||
clicked,
|
||||
@@ -83,7 +84,15 @@ impl<'a> RecentList<'a> {
|
||||
let shown = Section::fixed(words.recent.clone())
|
||||
.header_gap(Gap::Section)
|
||||
.command_scope(StartRecentCommands::SCOPE)
|
||||
.show(ui, |ui, cx| recent_body(&page, ui, cx, &files, RecentView::List, &empty));
|
||||
.show(ui, |ui, cx| {
|
||||
// A list on a page says it is empty in a muted line at the reading start under its heading, where its
|
||||
// rows would begin; the start screen's empty state stays the centred notice of `recent_body`.
|
||||
if files.is_empty() {
|
||||
let _ = Text::new(empty.clone()).shade(Shade::Muted).show(ui);
|
||||
} else {
|
||||
recent_body(&page, ui, cx, &files, RecentView::List, &empty);
|
||||
}
|
||||
});
|
||||
StartOutput { response: shown.output.response, actions: actions.into_inner() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,12 @@ fn recent_list(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
RecentList::new(&files).now(Some(NOW)).empty("No recent files").show(ui).into()
|
||||
}
|
||||
|
||||
/// No recent files: the muted line under the heading, at the reading start.
|
||||
#[story(RecentList<'static>, covers = [], drive = Drive::Never)]
|
||||
fn recent_list_empty(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
RecentList::new(&[]).empty("Documents you open will show up here.").show(ui).into()
|
||||
}
|
||||
|
||||
#[story(StartScreen<'static>, covers = [], drive = Drive::Never)]
|
||||
fn start_screen_with_links(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let links = [
|
||||
|
||||
@@ -162,3 +162,18 @@ fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() {
|
||||
assert!(fixture.by_label("Remove from Recent").is_some(), "a right click on a recent file opens its menu");
|
||||
assert_eq!(fixture.by_label("Show in Folder").is_some(), craft_platform::open::CAN_REVEAL);
|
||||
}
|
||||
|
||||
/// An empty recent list on a page says so in a line at the reading start under its heading, where its rows would
|
||||
/// begin, not in the start screen's centred empty state (a File page's Open list).
|
||||
#[trial]
|
||||
fn an_empty_recent_list_says_so_at_the_reading_start() {
|
||||
let files: Vec<RecentFile> = Vec::new();
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let _ = RecentList::new(&files).empty("Nothing opened yet").show(ui);
|
||||
});
|
||||
fixture.room(egui::Vec2::new(700.0, 500.0));
|
||||
fixture.settle();
|
||||
let line = fixture.by_label("Nothing opened yet").expect("the empty line shows");
|
||||
assert!(line.rect.left() < 60.0, "the line starts at the list's start edge: {:?}", line.rect);
|
||||
assert!(line.rect.width() < 300.0, "the line is as wide as its text: {:?}", line.rect);
|
||||
}
|
||||
Reference in new issue
Block a user