🚚 Rename HeadingDisplay to HeadingSize
This commit is contained in:
parent
3fd05643b3
commit
9f25695298
5 changed files with 36 additions and 36 deletions
|
|
@ -136,21 +136,21 @@ impl ThemeTrait for Bootsier {
|
|||
}
|
||||
h if Heading::matches_handle(h) => {
|
||||
if let Some(h) = component_as_mut::<Heading>(component) {
|
||||
match h.display() {
|
||||
HeadingDisplay::ExtraLarge => {
|
||||
h.replace_classes(h.display().to_string(), "display-1");
|
||||
match h.size() {
|
||||
HeadingSize::ExtraLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-1");
|
||||
}
|
||||
HeadingDisplay::XxLarge => {
|
||||
h.replace_classes(h.display().to_string(), "display-2");
|
||||
HeadingSize::XxLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-2");
|
||||
}
|
||||
HeadingDisplay::XLarge => {
|
||||
h.replace_classes(h.display().to_string(), "display-3");
|
||||
HeadingSize::XLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-3");
|
||||
}
|
||||
HeadingDisplay::Large => {
|
||||
h.replace_classes(h.display().to_string(), "display-4");
|
||||
HeadingSize::Large => {
|
||||
h.replace_classes(h.size().to_string(), "display-4");
|
||||
}
|
||||
HeadingDisplay::Medium => {
|
||||
h.replace_classes(h.display().to_string(), "display-5");
|
||||
HeadingSize::Medium => {
|
||||
h.replace_classes(h.size().to_string(), "display-5");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ impl ThemeTrait for Bulmix {
|
|||
}
|
||||
h if Heading::matches_handle(h) => {
|
||||
if let Some(h) = component_as_mut::<Heading>(component) {
|
||||
match h.display() {
|
||||
HeadingDisplay::Subtitle => {
|
||||
h.replace_classes(h.display().to_string(), "subtitle")
|
||||
match h.size() {
|
||||
HeadingSize::Subtitle => {
|
||||
h.replace_classes(h.size().to_string(), "subtitle")
|
||||
}
|
||||
_ => h.add_classes("title"),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ fn hello_world() -> Wrapper {
|
|||
.with_size(flex::ItemSize::Percent40)
|
||||
.add_component(
|
||||
Heading::h1(L10n::t("page_title", &LOCALES_HOMEDEMO))
|
||||
.with_display(HeadingDisplay::Medium),
|
||||
.with_size(HeadingSize::Medium),
|
||||
)
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::t("hello_intro", &LOCALES_HOMEDEMO).with_arg(
|
||||
|
|
@ -107,7 +107,7 @@ fn welcome() -> Wrapper {
|
|||
&config::SETTINGS.app.name
|
||||
),
|
||||
))
|
||||
.with_display(HeadingDisplay::Subtitle),
|
||||
.with_size(HeadingSize::Subtitle),
|
||||
)
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::t("welcome_text1", &LOCALES_HOMEDEMO))
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ mod icon;
|
|||
pub use icon::Icon;
|
||||
|
||||
mod heading;
|
||||
pub use heading::{Heading, HeadingDisplay, HeadingType};
|
||||
pub use heading::{Heading, HeadingSize, HeadingType};
|
||||
|
||||
mod paragraph;
|
||||
pub use paragraph::Paragraph;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub enum HeadingType {
|
|||
}
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum HeadingDisplay {
|
||||
pub enum HeadingSize {
|
||||
ExtraLarge,
|
||||
XxLarge,
|
||||
XLarge,
|
||||
|
|
@ -25,16 +25,16 @@ pub enum HeadingDisplay {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl ToString for HeadingDisplay {
|
||||
impl ToString for HeadingSize {
|
||||
fn to_string(&self) -> String {
|
||||
String::from(match self {
|
||||
HeadingDisplay::ExtraLarge => "pt-heading__title-x3l",
|
||||
HeadingDisplay::XxLarge => "pt-heading__title-x2l",
|
||||
HeadingDisplay::XLarge => "pt-heading__title-xl",
|
||||
HeadingDisplay::Large => "pt-heading__title-l",
|
||||
HeadingDisplay::Medium => "pt-heading__title-m",
|
||||
HeadingDisplay::Normal => "",
|
||||
HeadingDisplay::Subtitle => "pt-heading__subtitle",
|
||||
HeadingSize::ExtraLarge => "pt-heading__title-x3l",
|
||||
HeadingSize::XxLarge => "pt-heading__title-x2l",
|
||||
HeadingSize::XLarge => "pt-heading__title-xl",
|
||||
HeadingSize::Large => "pt-heading__title-l",
|
||||
HeadingSize::Medium => "pt-heading__title-m",
|
||||
HeadingSize::Normal => "",
|
||||
HeadingSize::Subtitle => "pt-heading__subtitle",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -47,8 +47,8 @@ pub struct Heading {
|
|||
renderable : Renderable,
|
||||
classes : OptionClasses,
|
||||
heading_type: HeadingType,
|
||||
size : HeadingSize,
|
||||
text : OptionTranslated,
|
||||
display : HeadingDisplay,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Heading {
|
||||
|
|
@ -69,7 +69,7 @@ impl ComponentTrait for Heading {
|
|||
}
|
||||
|
||||
fn setup_before_prepare(&mut self, _cx: &mut Context) {
|
||||
self.add_classes(self.display().to_string());
|
||||
self.add_classes(self.size().to_string());
|
||||
}
|
||||
|
||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||
|
|
@ -151,14 +151,14 @@ impl Heading {
|
|||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_text(&mut self, text: L10n) -> &mut Self {
|
||||
self.text.alter_value(text);
|
||||
pub fn alter_size(&mut self, size: HeadingSize) -> &mut Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_display(&mut self, display: HeadingDisplay) -> &mut Self {
|
||||
self.display = display;
|
||||
pub fn alter_text(&mut self, text: L10n) -> &mut Self {
|
||||
self.text.alter_value(text);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -168,11 +168,11 @@ impl Heading {
|
|||
&self.heading_type
|
||||
}
|
||||
|
||||
pub fn size(&self) -> &HeadingSize {
|
||||
&self.size
|
||||
}
|
||||
|
||||
pub fn text(&self) -> &OptionTranslated {
|
||||
&self.text
|
||||
}
|
||||
|
||||
pub fn display(&self) -> &HeadingDisplay {
|
||||
&self.display
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue