🎨 Mejora la página de bienvenida y el tema básico #6

Merged
manuelcillero merged 37 commits from advanced-welcome-page into main 2025-09-20 12:37:55 +02:00
12 changed files with 29 additions and 29 deletions
Showing only changes of commit ddf78c2de8 - Show all commits

View file

@ -84,7 +84,7 @@ impl Application {
if let Some((Width(term_width), _)) = terminal_size() {
if term_width >= 80 {
let maxlen: usize = ((term_width / 10) - 2).into();
let mut app = app_name.substring(0, maxlen).to_owned();
let mut app = app_name.substring(0, maxlen).to_string();
if app_name.len() > maxlen {
app = format!("{app}...");
}

View file

@ -25,7 +25,7 @@ use crate::prelude::*;
/// use pagetop::prelude::*;
///
/// let component = Html::with(|cx| {
/// let user = cx.param::<String>("username").cloned().unwrap_or(String::from("visitor"));
/// let user = cx.param::<String>("username").cloned().unwrap_or("visitor".to_string());
/// html! {
/// h1 { "Hello, " (user) }
/// }

View file

@ -36,7 +36,7 @@ impl Default for Region {
fn default() -> Self {
Self {
key: REGION_CONTENT,
name: String::from(REGION_CONTENT),
name: REGION_CONTENT.to_string(),
}
}
}

View file

@ -71,11 +71,11 @@ pub type OptionComponent<C: core::component::Component> = core::component::Typed
/// use pagetop::prelude::*;
///
/// // Texto normal, se escapa automáticamente para evitar inyección de HTML.
/// let fragment = PrepareMarkup::Escaped(String::from("Hola <b>mundo</b>"));
/// let fragment = PrepareMarkup::Escaped("Hola <b>mundo</b>".to_string());
/// assert_eq!(fragment.render().into_string(), "Hola &lt;b&gt;mundo&lt;/b&gt;");
///
/// // HTML literal, se inserta directamente, sin escapado adicional.
/// let raw_html = PrepareMarkup::Raw(String::from("<b>negrita</b>"));
/// let raw_html = PrepareMarkup::Raw("<b>negrita</b>".to_string());
/// assert_eq!(raw_html.render().into_string(), "<b>negrita</b>");
///
/// // Fragmento ya preparado con la macro `html!`.

View file

@ -129,7 +129,7 @@ impl Favicon {
icon_color: Option<String>,
) -> Self {
let icon_type = match icon_source.rfind('.') {
Some(i) => match icon_source[i..].to_owned().to_lowercase().as_str() {
Some(i) => match icon_source[i..].to_string().to_lowercase().as_str() {
".avif" => Some("image/avif"),
".gif" => Some("image/gif"),
".ico" => Some("image/x-icon"),

View file

@ -37,7 +37,7 @@ pub enum ClassesOp {
/// .with_value(ClassesOp::Add, "Active")
/// .with_value(ClassesOp::Remove, "btn-primary");
///
/// assert_eq!(classes.get(), Some(String::from("btn active")));
/// assert_eq!(classes.get(), Some("btn active".to_string()));
/// assert!(classes.contains("active"));
/// ```
#[derive(AutoDefault, Clone, Debug)]

View file

@ -17,13 +17,13 @@ use crate::{builder_fn, AutoDefault};
/// // Español disponible.
/// assert_eq!(
/// hello.lookup(&LangMatch::resolve("es-ES")),
/// Some(String::from("¡Hola mundo!"))
/// Some("¡Hola mundo!".to_string())
/// );
///
/// // Japonés no disponible, traduce al idioma de respaldo ("en-US").
/// assert_eq!(
/// hello.lookup(&LangMatch::resolve("ja-JP")),
/// Some(String::from("Hello world!"))
/// Some("Hello world!".to_string())
/// );
///
/// // Uso típico en un atributo:

View file

@ -36,7 +36,7 @@ impl AttrValue {
self.0 = if value.is_empty() {
None
} else {
Some(value.to_owned())
Some(value.to_string())
};
self
}

View file

@ -285,7 +285,7 @@ impl Context {
///
/// let cx = Context::new(None)
/// .with_param("usuario_id", 42_i32)
/// .with_param("titulo", String::from("Hola"));
/// .with_param("titulo", "Hola".to_string());
///
/// let id: &i32 = cx.get_param("usuario_id").unwrap();
/// let titulo: &String = cx.get_param("titulo").unwrap();
@ -318,7 +318,7 @@ impl Context {
///
/// let mut cx = Context::new(None)
/// .with_param("contador", 7_i32)
/// .with_param("titulo", String::from("Hola"));
/// .with_param("titulo", "Hola".to_string());
///
/// let n: i32 = cx.take_param("contador").unwrap();
/// assert!(cx.get_param::<i32>("contador").is_err()); // ya no está
@ -416,7 +416,7 @@ impl Contextual for Context {
///
/// let cx = Context::new(None)
/// .with_param("usuario_id", 42_i32)
/// .with_param("titulo", String::from("Hola"))
/// .with_param("titulo", "Hola".to_string())
/// .with_param("flags", vec!["a", "b"]);
/// ```
#[builder_fn]
@ -484,7 +484,7 @@ impl Contextual for Context {
/// ```rust
/// use pagetop::prelude::*;
///
/// let cx = Context::new(None).with_param("username", String::from("Alice"));
/// let cx = Context::new(None).with_param("username", "Alice".to_string());
///
/// // Devuelve Some(&String) si existe y coincide el tipo.
/// assert_eq!(cx.param::<String>("username").map(|s| s.as_str()), Some("Alice"));
@ -533,7 +533,7 @@ impl Contextual for Context {
.replace(' ', "_")
.to_lowercase();
let prefix = if prefix.is_empty() {
"prefix".to_owned()
"prefix".to_string()
} else {
prefix
};

View file

@ -165,7 +165,7 @@ pub trait LangId {
///
/// // Idioma no soportado.
/// let lang = LangMatch::resolve("ja-JP");
/// assert_eq!(lang, LangMatch::Unsupported(String::from("ja-JP")));
/// assert_eq!(lang, LangMatch::Unsupported("ja-JP".to_string()));
/// ```
///
/// Con la siguiente instrucción siempre se obtiene un [`LanguageIdentifier`] válido, ya sea porque
@ -222,7 +222,7 @@ impl LangMatch {
}
// En caso contrario, indica que el idioma no está soportado.
Self::Unsupported(String::from(language))
Self::Unsupported(language.to_string())
}
/// Devuelve el [`LanguageIdentifier`] si el idioma fue reconocido.

View file

@ -110,15 +110,15 @@ macro_rules! hm {
///
/// // Concatena todos los fragmentos directamente.
/// let result = join!("Hello", " ", "World");
/// assert_eq!(result, String::from("Hello World"));
/// assert_eq!(result, "Hello World".to_string());
///
/// // También funciona con valores vacíos.
/// let result_with_empty = join!("Hello", "", "World");
/// assert_eq!(result_with_empty, String::from("HelloWorld"));
/// assert_eq!(result_with_empty, "HelloWorld".to_string());
///
/// // Un único fragmento devuelve el mismo valor.
/// let single_result = join!("Hello");
/// assert_eq!(single_result, String::from("Hello"));
/// assert_eq!(single_result, "Hello".to_string());
/// ```
#[macro_export]
macro_rules! join {
@ -141,11 +141,11 @@ macro_rules! join {
///
/// // Concatena los fragmentos no vacíos con un espacio como separador.
/// let result_with_separator = join_opt!(["Hello", "", "World"]; " ");
/// assert_eq!(result_with_separator, Some(String::from("Hello World")));
/// assert_eq!(result_with_separator, Some("Hello World".to_string()));
///
/// // Concatena los fragmentos no vacíos sin un separador.
/// let result_without_separator = join_opt!(["Hello", "", "World"]);
/// assert_eq!(result_without_separator, Some(String::from("HelloWorld")));
/// assert_eq!(result_without_separator, Some("HelloWorld".to_string()));
///
/// // Devuelve `None` si todos los fragmentos están vacíos.
/// let result_empty = join_opt!(["", "", ""]);
@ -185,19 +185,19 @@ macro_rules! join_opt {
///
/// // Concatena los dos fragmentos cuando ambos no están vacíos.
/// let result = join_pair!(first, separator, second);
/// assert_eq!(result, String::from("Hello-World"));
/// assert_eq!(result, "Hello-World".to_string());
///
/// // Si el primer fragmento está vacío, devuelve el segundo.
/// let result_empty_first = join_pair!("", separator, second);
/// assert_eq!(result_empty_first, String::from("World"));
/// assert_eq!(result_empty_first, "World".to_string());
///
/// // Si el segundo fragmento está vacío, devuelve el primero.
/// let result_empty_second = join_pair!(first, separator, "");
/// assert_eq!(result_empty_second, String::from("Hello"));
/// assert_eq!(result_empty_second, "Hello".to_string());
///
/// // Si ambos fragmentos están vacíos, devuelve una cadena vacía.
/// let result_both_empty = join_pair!("", separator, "");
/// assert_eq!(result_both_empty, String::from(""));
/// assert_eq!(result_both_empty, "".to_string());
/// ```
#[macro_export]
macro_rules! join_pair {
@ -224,11 +224,11 @@ macro_rules! join_pair {
///
/// // Concatena los fragmentos.
/// let result = join_strict!(["Hello", "World"]);
/// assert_eq!(result, Some(String::from("HelloWorld")));
/// assert_eq!(result, Some("HelloWorld".to_string()));
///
/// // Concatena los fragmentos con un separador.
/// let result_with_separator = join_strict!(["Hello", "World"]; " ");
/// assert_eq!(result_with_separator, Some(String::from("Hello World")));
/// assert_eq!(result_with_separator, Some("Hello World".to_string()));
///
/// // Devuelve `None` si alguno de los fragmentos está vacío.
/// let result_with_empty = join_strict!(["Hello", "", "World"]);

View file

@ -17,7 +17,7 @@ async fn component_html_renders_static_markup() {
#[pagetop::test]
async fn component_html_renders_using_context_param() {
let mut cx = Context::new(None).with_param("username", String::from("Alice"));
let mut cx = Context::new(None).with_param("username", "Alice".to_string());
let component = Html::with(|cx| {
let name = cx.param::<String>("username").cloned().unwrap_or_default();