Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Dom component #132

Closed
wants to merge 2 commits into from

Conversation

glmars
Copy link
Contributor

@glmars glmars commented Dec 17, 2018

It's early early early preview of dom component feature (please, see discussion in #128).

The main idea is introducing special syntax to extract peace of a @dom powered code as the separate reusable elements. I'm called it - "dom components".

object Dialog {
  @dom
  def apply(id: Binding[String], children: BindingSeq[Node]): Binding[Div] = <div id={id.bind} class="dialog">{children}</div>
}

implicit final class DialogTags(x: TagsAndTags2.type) {
  @domcomponent
  val dialog = Dialog
}

Which can be used in @dom functions:

@dom val html = <dialog id="123"><button><i>OK</i></button></dialog>

It generates such DOM tree:

<div id="123" class="dialog"><button><i>OK</i></button></div>

❗Hardcode❗ - only dialog tag is considered as a dom component in this preview

/cc @sadhen, @ccamel, @jfilali, @skaz1970, @maxkorolev, @csoren

@Atry
Copy link
Collaborator

Atry commented Dec 17, 2018

I think the efforts of custom components can be split into a separate repository. I had a try in https://github.com/ThoughtWorksInc/dom.scala/

@Atry
Copy link
Collaborator

Atry commented Dec 17, 2018

You may want to fork https://github.com/ThoughtWorksInc/dom.scala and hack on it

@glmars
Copy link
Contributor Author

glmars commented Dec 17, 2018

Unfortunately, your experiment (ThoughtWorksInc/dom.scala@083f8c3#diff-5f9d51a26102bb299d4706844f7678c4R619) breaks mine 😄

@Atry
Copy link
Collaborator

Atry commented Dec 17, 2018 via email

@Atry
Copy link
Collaborator

Atry commented Nov 15, 2021

I think this issue has been solved in the Name based XML proposal. html.scala is implemented based on the Name based XML.

@Atry Atry closed this Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants