<commit_before>package io.youi.component.extras

import io.youi.component.Component
import io.youi.style.Position
import io.youi.ui
import org.scalajs.dom.html
import reactify.Var

class HTMLComponentPosition(component: Component) extends ComponentPosition(component) {
  private def e: html.Element = HTMLComponent.element(component)

  val `type`: Var[Position] = Var(Position.Absolute)

  if (component != ui) {
    component.connect[Position](
      v = Var(Position.Absolute),
      get = None,
      set = (p: Position) => e.style.position = p.toString.toLowerCase
    )
    component.connect(x, None, (v: Double) => e.style.left = s"${v}px")
    component.connect(y, None, (v: Double) => e.style.top = s"${v}px")
    component.connect(z, None, (i: Int) => e.style.zIndex = i.toString)
  }
}
<commit_msg>Updated HTMLComponentPosition.`type` to default to `Static` until `x` or `y` is set, then switch to `Absolute`<commit_after>package io.youi.component.extras

import io.youi.component.Component
import io.youi.style.Position
import io.youi.ui
import org.scalajs.dom.html
import reactify.Var

class HTMLComponentPosition(component: Component) extends ComponentPosition(component) {
  private def e: html.Element = HTMLComponent.element(component)

  val `type`: Var[Position] = Var(if (x() == 0.0 && y() == 0.0) {
    Position.Static
  } else {
    Position.Absolute
  })

  if (component != ui) {
    component.connect[Position](
      v = Var(Position.Absolute),
      get = None,
      set = (p: Position) => e.style.position = p.toString.toLowerCase
    )
    component.connect(x, None, (v: Double) => e.style.left = s"${v}px")
    component.connect(y, None, (v: Double) => e.style.top = s"${v}px")
    component.connect(z, None, (i: Int) => e.style.zIndex = i.toString)
  }
}

{'fraction_non_alphanumeric': 0.15044742729306487, 'fraction_numerical': 0.0022371364653243847, 'mean_word_length': 3.887978142076503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7152645', 'n_tokens_mistral': 598, 'n_tokens_neox': 593, 'n_words': 136}