Giter Site home page Giter Site logo

Comments (12)

skaz1970 avatar skaz1970 commented on May 12, 2024 1

Is the syntax difference between custom tags and custom functions important for you?

If it is not important for you, you can simply create a popconfirm function and use it like this:

popconfirm(title="Are you sure delete this task?",
           onConfirm=confirm,
           onCancel=cancel,
           okText="Yes",
           cancelText="No") {
  <a href=" ">Delete</a >
}

Please, show the body (with return type) of popconfirm

from binding.scala.

Atry avatar Atry commented on May 12, 2024

Is the syntax difference between custom tags and custom functions important for you?

If it is not important for you, you can simply create a popconfirm function and use it like this:

popconfirm(title="Are you sure delete this task?",
           onConfirm=confirm,
           onCancel=cancel,
           okText="Yes",
           cancelText="No") {
  <a href=" ">Delete</a >
}

from binding.scala.

da-liii avatar da-liii commented on May 12, 2024

I have to admit that the syntax is important for me. I'm not sure for other people whether it is important or not? In my opinion, syntax is one reason why Binding.scala is more charming than other alternatives.

For example, in ScalaTags and HTML literal which one you will choose to use?

Syntax matters a lot. In this particular example, using the popconfirm function is indeed more flexible and general. But custom tags syntax has the power to reduce the flexibility and make it simple and consistent.

As for me, I'm developing a library(https://github.com/sadhen/Binding-SemanticUI) based on Binding.scala and SemanticUI to provide easy-to-use custom tags like Ant Design(http://ant.design), so that programmers already familiar with Ant Design would be happy to use Binding.scala.

from binding.scala.

da-liii avatar da-liii commented on May 12, 2024

I found a more acceptable work around:

<div>
<Popconfirm title="Are you sure delete this task?"
                       onConfirm={confirm}
                       onCancel={cancel}
                       okText="Yes"
                       cancelText="No"
                       inner={
      <a href="#">Delete</a>
}/>
</div>

Comparing with

<div> {
  popconfirm(title="Are you sure delete this task?",
           onConfirm=confirm,
           onCancel=cancel,
           okText="Yes",
           cancelText="No") {
    <a href="#">Delete</a >
  }
} </div>

, which one do you prefer ?

I prefer the former one. However, using the latter one, we would have more IDE support.

from binding.scala.

maxkorolev avatar maxkorolev commented on May 12, 2024

+1, that would be awesome

from binding.scala.

csoren avatar csoren commented on May 12, 2024

This would be great for consuming web components, such as the ones defined by Polymer.

from binding.scala.

Atry avatar Atry commented on May 12, 2024
import com.thoughtworks.binding.dom
import org.scalajs.dom.raw._
import org.scalajs.dom.document

@dom def popconfirm(
  title: String,
  okText: String, cancelText: String,
  onConfirm: Event => Unit, onCancel: Event => Unit
)(
  // For FXML, use `Binding[Node]` instead of `Node`
  message: Node 
) = {
  <section>
    <h3>{ title }</h3>
    <div>
    { message }
    </div>
    <button type="button" onclick={onConfirm}>{
      okText
    }</button>
    <button type="button" onclick={onCancel}>{
      cancelText
    }</button>
  </section>
}

@dom
def render = popconfirm(title="Are you sure delete this task?",
          onConfirm={ _ =>
            println("confirm")
          },
          onCancel={ _ =>
            println("cancel")
          },
          okText="Yes",
          cancelText="No") {
  <a href=" ">Delete</a >
}.bind // .bind should be avoided for FXML

dom.render(document.body, render)

from binding.scala.

skaz1970 avatar skaz1970 commented on May 12, 2024

Thanks a lot!

from binding.scala.

skaz1970 avatar skaz1970 commented on May 12, 2024

But if I'd like to get instead of message: Node different types, Binding[Node], BindingSeq[Node], Binding[Option[Node]]? Can you propose anything? Is there any common type?

from binding.scala.

Atry avatar Atry commented on May 12, 2024

from binding.scala.

skaz1970 avatar skaz1970 commented on May 12, 2024

Thanks, my thought were around BindingSeq[Node], but converting makes code less readable.

from binding.scala.

da-liii avatar da-liii commented on May 12, 2024

I'm trying to implement the inner html feature in https://github.com/sadhen/Binding-SemanticUI

from binding.scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.