diff --git a/gui/ui/examples/design-system/src/main.rs b/gui/ui/examples/design-system/src/main.rs index a9171cf8..56231b2b 100644 --- a/gui/ui/examples/design-system/src/main.rs +++ b/gui/ui/examples/design-system/src/main.rs @@ -2,11 +2,11 @@ mod section; use iced::widget::{button, column, container, row, text, Space}; use iced::{executor, Application, Command, Length, Settings, Subscription}; -use liana_ui::{theme, widget::*}; +use liana_ui::{component::text::*, theme, widget::*}; pub fn main() -> iced::Result { let mut settings = Settings::with_flags(Config {}); - settings.default_text_size = 19; + settings.default_text_size = P1_SIZE; DesignSystem::run(settings) } diff --git a/gui/ui/src/component/text.rs b/gui/ui/src/component/text.rs index b3a428d5..eabe90c1 100644 --- a/gui/ui/src/component/text.rs +++ b/gui/ui/src/component/text.rs @@ -1,22 +1,47 @@ use crate::{font, theme::Theme}; use std::borrow::Cow; +// 40 * 1.2 +pub const H1_SIZE: u16 = 48; +// 29 * 1.2 +pub const H2_SIZE: u16 = 35; +// 24 * 1.2 +pub const H3_SIZE: u16 = 29; +// 20 * 1.2 +pub const H4_SIZE: u16 = 24; +// 18 * 1.2 +pub const H5_SIZE: u16 = 22; +// 16 * 1.2 +pub const P1_SIZE: u16 = 20; +// 14 * 1.2 +pub const P2_SIZE: u16 = 17; +// 12 * 1.2 +pub const CAPTION_SIZE: u16 = 15; + pub fn h1<'a>(content: impl Into>) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::BOLD).size(40) + iced::widget::Text::new(content) + .font(font::BOLD) + .size(H1_SIZE) } pub fn h2<'a>(content: impl Into>) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::BOLD).size(29) + iced::widget::Text::new(content) + .font(font::BOLD) + .size(H2_SIZE) } pub fn h3<'a>(content: impl Into>) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::BOLD).size(24) + iced::widget::Text::new(content) + .font(font::BOLD) + .size(H3_SIZE) } pub fn h4_bold<'a>( content: impl Into>, ) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::BOLD).size(20) + iced::widget::Text::new(content) + .font(font::BOLD) + .size(H4_SIZE) } pub fn h4_regular<'a>( @@ -24,13 +49,15 @@ pub fn h4_regular<'a>( ) -> iced::widget::Text<'a, iced::Renderer> { iced::widget::Text::new(content) .font(font::REGULAR) - .size(20) + .size(H4_SIZE) } pub fn h5_medium<'a>( content: impl Into>, ) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::MEDIUM).size(18) + iced::widget::Text::new(content) + .font(font::MEDIUM) + .size(H5_SIZE) } pub fn h5_regular<'a>( @@ -38,19 +65,23 @@ pub fn h5_regular<'a>( ) -> iced::widget::Text<'a, iced::Renderer> { iced::widget::Text::new(content) .font(font::REGULAR) - .size(18) + .size(H5_SIZE) } pub fn p1_bold<'a>( content: impl Into>, ) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::BOLD).size(16) + iced::widget::Text::new(content) + .font(font::BOLD) + .size(P1_SIZE) } pub fn p1_medium<'a>( content: impl Into>, ) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::MEDIUM).size(16) + iced::widget::Text::new(content) + .font(font::MEDIUM) + .size(P1_SIZE) } pub fn p1_regular<'a>( @@ -58,13 +89,15 @@ pub fn p1_regular<'a>( ) -> iced::widget::Text<'a, iced::Renderer> { iced::widget::Text::new(content) .font(font::REGULAR) - .size(16) + .size(P1_SIZE) } pub fn p2_medium<'a>( content: impl Into>, ) -> iced::widget::Text<'a, iced::Renderer> { - iced::widget::Text::new(content).font(font::MEDIUM).size(14) + iced::widget::Text::new(content) + .font(font::MEDIUM) + .size(P2_SIZE) } pub fn p2_regular<'a>( @@ -72,7 +105,7 @@ pub fn p2_regular<'a>( ) -> iced::widget::Text<'a, iced::Renderer> { iced::widget::Text::new(content) .font(font::REGULAR) - .size(14) + .size(P2_SIZE) } pub fn caption<'a>( @@ -80,7 +113,7 @@ pub fn caption<'a>( ) -> iced::widget::Text<'a, iced::Renderer> { iced::widget::Text::new(content) .font(font::REGULAR) - .size(12) + .size(CAPTION_SIZE) } pub const TEXT_REGULAR_SIZE: u16 = 25;