Text in the theme's primary text colour unless given another, rather than white
A `Text` given no colour was drawn white, which on a light theme's white surfaces could not be read: Prompt's dialog to share tabs showed neither the code nor the time left in it, and the titles of the clip_path, file_chooser and tab_strip examples, drawn over the theme's background, did not show in the light theme. `Text::new` now takes the theme's `text_primary`, as the toast, the text field and the pickers already do, so a label given no colour reads on light and dark themes alike. Its documentation and the test of its defaults say so.
This commit is contained in:
@@ -66,15 +66,15 @@ pub struct Text
|
|||||||
|
|
||||||
impl Text
|
impl Text
|
||||||
{
|
{
|
||||||
/// A left-aligned, non-wrapping, ellipsis-truncated white label at the
|
/// A left-aligned, non-wrapping, ellipsis-truncated label in the theme's
|
||||||
/// default 16 px size with the canvas default font.
|
/// primary text colour at the default 16 px size with the canvas default font.
|
||||||
pub fn new( content: impl Into<String> ) -> Self
|
pub fn new( content: impl Into<String> ) -> Self
|
||||||
{
|
{
|
||||||
Self
|
Self
|
||||||
{
|
{
|
||||||
content: content.into(),
|
content: content.into(),
|
||||||
size: Length::px( 16.0 ),
|
size: Length::px( 16.0 ),
|
||||||
color: Color::WHITE,
|
color: crate::theme::palette().text_primary,
|
||||||
align: TextAlign::Left,
|
align: TextAlign::Left,
|
||||||
wrap: false,
|
wrap: false,
|
||||||
truncate: true,
|
truncate: true,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fn new_uses_documented_defaults()
|
|||||||
let t = Text::new( "hello" );
|
let t = Text::new( "hello" );
|
||||||
assert_eq!( t.content, "hello" );
|
assert_eq!( t.content, "hello" );
|
||||||
assert_eq!( t.size, crate::Length::px( 16.0 ) );
|
assert_eq!( t.size, crate::Length::px( 16.0 ) );
|
||||||
assert_eq!( t.color, Color::WHITE );
|
assert_eq!( t.color, crate::theme::palette().text_primary );
|
||||||
assert_eq!( t.align, TextAlign::Left );
|
assert_eq!( t.align, TextAlign::Left );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user