pub use crate::node::node_kind::TextOverflow;
use crate::{
  app::theme::TypographyStyle,
  impl_into_node,
  layout::text_style::{TextAlign, TextStyle},
  node::{TextColor, TextTransformMode},
};

impl_into_node!(Text);

impl Text {
  pub fn new(content: &str) -> Self {
    Self::from_node(crate::node::Node::text(content))
  }

  pub fn styled(content: &str, style: TextStyle) -> Self {
    Self::from_node(crate::node::Node::text_styled(content, style))
  }

  pub fn nowrap(mut self) -> Self {
    self.node = self.node.text_wrap(false);
    self
  }

  pub fn selectable(mut self, selectable: bool) -> Self {
    self.node = self.node.selectable(selectable);
    self
  }

  pub fn text_transform_mode(mut self, mode: TextTransformMode) -> Self {
    self.node = self.node.text_transform_mode(mode);
    self
  }

  pub fn variant(mut self, style: impl Into<TypographyStyle>) -> Self {
    self.node = self.node.text_variant(style);
    self
  }

  pub fn text_align(mut self, align: impl Into<TextAlign>) -> Self {
    self.node = self.node.text_align(align);
    self
  }

  pub fn text_overflow(mut self, overflow: TextOverflow) -> Self {
    self.node = self.node.text_overflow(overflow);
    self
  }

  pub fn color(mut self, color: impl Into<TextColor>) -> Self {
    self.node = self.node.text_color(color);
    self
  }

  pub fn caret_color(mut self, color: impl Into<crate::node::TextColor>) -> Self {
    self.node = self.node.caret_color(color);
    self
  }
}

impl Default for Text {
  fn default() -> Self {
    Self::new("")
  }
}
